diff --git a/resources/assets/enderio/config/SliceAndSpliceRecipes_Core.xml b/resources/assets/enderio/config/SliceAndSpliceRecipes_Core.xml index bf1d7afd..06d7b458 100644 --- a/resources/assets/enderio/config/SliceAndSpliceRecipes_Core.xml +++ b/resources/assets/enderio/config/SliceAndSpliceRecipes_Core.xml @@ -4,8 +4,8 @@ - - + + @@ -19,7 +19,7 @@ - + diff --git a/src/main/java/crazypants/enderio/machine/slicensplice/ContainerSliceAndSplice.java b/src/main/java/crazypants/enderio/machine/slicensplice/ContainerSliceAndSplice.java index d8ad8ce6..bb51779d 100644 --- a/src/main/java/crazypants/enderio/machine/slicensplice/ContainerSliceAndSplice.java +++ b/src/main/java/crazypants/enderio/machine/slicensplice/ContainerSliceAndSplice.java @@ -10,7 +10,7 @@ import crazypants.enderio.machine.AbstractMachineEntity; public class ContainerSliceAndSplice extends AbstractMachineContainer { - private static final Point[] inputLocs = new Point[] { + public static final Point[] INPUT_SLOTS = new Point[] { new Point(44,40), new Point(62,40), new Point(80,40), @@ -21,6 +21,8 @@ public class ContainerSliceAndSplice extends AbstractMachineContainer { new Point(72,16) }; + public static final Point OUTPUT_SLOT = new Point(134, 48); + public ContainerSliceAndSplice(InventoryPlayer playerInv, AbstractMachineEntity te) { super(playerInv, te); } @@ -28,8 +30,8 @@ public class ContainerSliceAndSplice extends AbstractMachineContainer { @Override protected void addMachineSlots(InventoryPlayer playerInv) { - for(int i=0;i getGuiClass() { + return GuiSliceAndSplice.class; + } + + @Override + public String getOverlayIdentifier() { + return "EnderIOSliceAndSplice"; + } + + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(149, 32, 16, 16), "EnderIOSliceAndSplice", new Object[0])); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + + if(result == null) { + return; + } + + List recipes = new ArrayList(SliceAndSpliceRecipeManager.getInstance().getRecipes()); + for (IRecipe recipe : recipes) { + ItemStack output = recipe.getOutputs()[0].getOutput(); + if(result.getItem() == output.getItem() && result.getItemDamage() == output.getItemDamage()) { + SliceAndSpliceRecipe res = new SliceAndSpliceRecipe(recipe); + arecipes.add(res); + } + } + + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if(outputId.equals("EnderIOSliceAndSplice") && getClass() == SliceAndSpliceRecipeHandler.class) { + List recipes = new ArrayList(SliceAndSpliceRecipeManager.getInstance().getRecipes()); + for (IRecipe recipe : recipes) { + SliceAndSpliceRecipe res = new SliceAndSpliceRecipe(recipe); + arecipes.add(res); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + List recipes = new ArrayList(SliceAndSpliceRecipeManager.getInstance().getRecipes()); + for (IRecipe recipe : recipes) { + if(recipe.isValidInput(0, ingredient)) { + SliceAndSpliceRecipe res = new SliceAndSpliceRecipe(recipe); + arecipes.add(res); + } + } + } + + @Override + public void drawExtras(int recipeIndex) { + SliceAndSpliceRecipe recipe = (SliceAndSpliceRecipe) arecipes.get(recipeIndex); + String energyString = PowerDisplayUtil.formatPower(recipe.getEnergy()) + " " + PowerDisplayUtil.abrevation(); + Minecraft.getMinecraft().fontRenderer.drawString(energyString, 100, 58, 0xFFFFFFFF); + } + + public List getInputs(RecipeInput input) { + List result = new ArrayList(); + result.add(input.getInput()); + ItemStack[] equivs = input.getEquivelentInputs(); + if(equivs != null) { + for (ItemStack st : equivs) { + result.add(st); + } + } + return result; + } + + public class SliceAndSpliceRecipe extends TemplateRecipeHandler.CachedRecipe { + + private ArrayList input; + private PositionedStack output; + private int energy; + + public int getEnergy() { + return energy; + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, input); + } + + @Override + public PositionedStack getResult() { + return output; + } + + public SliceAndSpliceRecipe(IRecipe recipe) { + int recipeSize = recipe.getInputs().length; + input = new ArrayList(); + int yOff = 11; + int xOff = 5; + + for(RecipeInput recipeInput : recipe.getInputs()) { + if(recipeInput != null) { + Point pos = ContainerSliceAndSplice.INPUT_SLOTS[recipeInput.getSlotNumber()]; + input.add(new PositionedStack(getInputs(recipeInput), pos.x - xOff, pos.y - yOff)); + } + } + + if(recipe.getOutputs()[0] != null) { + output = new PositionedStack(recipe.getOutputs()[0].getOutput(), ContainerSliceAndSplice.OUTPUT_SLOT.x - xOff, ContainerSliceAndSplice.OUTPUT_SLOT.y - yOff); + } + energy = recipe.getEnergyRequired(); + } + } + +}