diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2018-12-22 13:17:31 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2018-12-22 13:17:31 +0800 |
| commit | 15f6cc9eb567b6ef685bc6c1a6f3364270300914 (patch) | |
| tree | 3c2911284faccd10f97e3aa307719ec12efd4b53 /src/main/java/me/shedaniel/plugin/crafting | |
| parent | 449fc73beb20ceda44a12422129151a88306fac8 (diff) | |
| download | RoughlyEnoughItems-15f6cc9eb567b6ef685bc6c1a6f3364270300914.tar.gz RoughlyEnoughItems-15f6cc9eb567b6ef685bc6c1a6f3364270300914.tar.bz2 RoughlyEnoughItems-15f6cc9eb567b6ef685bc6c1a6f3364270300914.zip | |
from aei but like jei now
Diffstat (limited to 'src/main/java/me/shedaniel/plugin/crafting')
4 files changed, 234 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java new file mode 100755 index 000000000..e064f05a4 --- /dev/null +++ b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java @@ -0,0 +1,106 @@ +package me.shedaniel.plugin.crafting; + +import me.shedaniel.api.IDisplayCategory; +import me.shedaniel.gui.widget.AEISlot; +import me.shedaniel.gui.widget.Control; +import me.shedaniel.gui.widget.WidgetArrow; +import net.minecraft.client.MainWindow; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +public class VanillaCraftingCategory implements IDisplayCategory<VanillaCraftingRecipe> { + MainWindow mainWindow = Minecraft.getInstance().mainWindow; + private List<VanillaCraftingRecipe> recipes; + + @Override + public String getId() { + return "vanilla"; + } + + @Override + public String getDisplayName() { + return "Crafting"; + } + + @Override + public void addRecipe(VanillaCraftingRecipe recipe) { + if (this.recipes == null) + this.recipes = new ArrayList<>(); + this.recipes.add(recipe); + } + + @Override + public void resetRecipes() { + this.recipes = new ArrayList<>(); + } + + @Override + public List<AEISlot> setupDisplay(int number) { + List<AEISlot> slots = new LinkedList<>(); + int count = 0; + List<List<ItemStack>> input = recipes.get(number).getInput(); + for(int y = 0; y < 3; y++) { + for(int x = 0; x < 3; x++) { + AEISlot slot = new AEISlot(20 + x * 18, 75 + y * 18 + number * 75); + slot.setDrawBackground(true); + slots.add(slot); + count++; + } + } + for(int i = 0; i < input.size(); i++) { + if (recipes.get(number) instanceof VanillaShapedCraftingRecipe) { + if (!input.get(i).isEmpty()) + slots.get(getSlotWithSize(number, i)).setStackList(input.get(i)); + } else if (!input.get(i).isEmpty()) + slots.get(i).setStackList(input.get(i)); + } + AEISlot slot = new AEISlot(130, 75 + 18 + number * 75); + + slot.setDrawBackground(true); + slot.setStack(recipes.get(number).getOutput().get(0).copy()); + slots.add(slot); + return slots; + } + + @Override + public boolean canDisplay(VanillaCraftingRecipe recipe) { + return false; + } + + @Override + public void drawExtras() { + + } + + @Override + public void addWidget(List<Control> controls, int number) { + WidgetArrow wa = new WidgetArrow(90, 70 + 22 + number * 75, false); + controls.add(wa); + } + + private int getSlotWithSize(int number, int num) { + if (recipes.get(number).getWidth() == 1) { + if (num == 1) + return 3; + if (num == 2) + return 6; + } + + if (recipes.get(number).getWidth() == 2) { + if (num == 2) + return 3; + if (num == 3) + return 4; + if (num == 4) + return 6; + if (num == 5) + return 7; + + } + return num; + } +} diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingRecipe.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingRecipe.java new file mode 100755 index 000000000..f39b5d695 --- /dev/null +++ b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingRecipe.java @@ -0,0 +1,16 @@ +package me.shedaniel.plugin.crafting; + +import me.shedaniel.api.IRecipe; +import net.minecraft.item.ItemStack; + +public abstract class VanillaCraftingRecipe implements IRecipe<ItemStack> { + + public int getWidth() { + return 2; + } + + public int getHeight() { + return 2; + } + +} diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaShapedCraftingRecipe.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaShapedCraftingRecipe.java new file mode 100755 index 000000000..1c537b2a7 --- /dev/null +++ b/src/main/java/me/shedaniel/plugin/crafting/VanillaShapedCraftingRecipe.java @@ -0,0 +1,55 @@ +package me.shedaniel.plugin.crafting; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.item.crafting.ShapedRecipe; + +import java.util.LinkedList; +import java.util.List; + +public class VanillaShapedCraftingRecipe extends VanillaCraftingRecipe { + + private final ShapedRecipe recipe; + + public VanillaShapedCraftingRecipe(ShapedRecipe recipe) { + + this.recipe = recipe; + } + + @Override + public int getWidth() { + return recipe.getWidth(); + } + + @Override + public int getHeight() { + return recipe.getHeight(); + } + + @Override + public String getId() { + return "vanilla"; + } + + @Override + public List<ItemStack> getOutput() { + List<ItemStack> output = new LinkedList<>(); + output.add(recipe.getRecipeOutput()); + return output; + } + + @Override + public List<List<ItemStack>> getInput() { + List<List<ItemStack>> input = new LinkedList<>(); + int count = 0; + for(Ingredient ingredient : recipe.getIngredients()) { + List<ItemStack> ingList = new LinkedList<>(); + for(ItemStack matchingStack : ingredient.getMatchingStacks()) { + ingList.add(matchingStack); + } + input.add(ingList); + count++; + } + return input; + } +} diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaShapelessCraftingRecipe.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaShapelessCraftingRecipe.java new file mode 100755 index 000000000..034ac77b0 --- /dev/null +++ b/src/main/java/me/shedaniel/plugin/crafting/VanillaShapelessCraftingRecipe.java @@ -0,0 +1,57 @@ +package me.shedaniel.plugin.crafting; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.item.crafting.ShapelessRecipe; + +import java.util.LinkedList; +import java.util.List; + +public class VanillaShapelessCraftingRecipe extends VanillaCraftingRecipe { + + private final ShapelessRecipe recipe; + + public VanillaShapelessCraftingRecipe(ShapelessRecipe recipe) { + + this.recipe = recipe; + } + + @Override + public String getId() { + return "vanilla"; + } + + @Override + public List<ItemStack> getOutput() { + List<ItemStack> output = new LinkedList<>(); + output.add(recipe.getRecipeOutput()); + return output; + } + + @Override + public List<List<ItemStack>> getInput() { + List<List<ItemStack>> input = new LinkedList<>(); + for(Ingredient ingredient : recipe.getIngredients()) { + List<ItemStack> ingList = new LinkedList<>(); + for(ItemStack matchingStack : ingredient.getMatchingStacks()) { + ingList.add(matchingStack); + } + input.add(ingList); + } + return input; + } + + @Override + public int getWidth() { + if (recipe.getIngredients().size() > 4) + return 3; + return 2; + } + + @Override + public int getHeight() { + if (recipe.getIngredients().size() > 4) + return 3; + return 2; + } +} |
