From 4bfbdcdb1dea4d4e4786e351b591096fb7646351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=A4=C3=9Fler?= Date: Tue, 1 Aug 2017 11:20:55 +0200 Subject: [PATCH] Made it so that if two inputs are equal an Integr. Circuit (0) is added --- .../GT_MetaTileEntity_BasicMachine.java | 27 +++++++++++-------- .../postload/GT_MachineRecipeLoader.java | 4 +-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 545c41ec..2980a22a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -602,24 +602,29 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } protected ItemStack[] getAllInputs() { - ItemStack[] rInputs = new ItemStack[mInputSlotCount]; - int emptySlotLocation = -1; + ItemStack[] rInputs = new ItemStack[mInputSlotCount + 1]; + boolean foundEmptySlotOrAreTwoInputsEqual = false; boolean foundIntegratedCircuit = false; for (int i = 0; i < mInputSlotCount; i++){ ItemStack currentInput = getInputAt(i); - if (emptySlotLocation == -1) { - if (currentInput == null) { - emptySlotLocation = i; - continue; - } - } + if (currentInput == null) { + foundEmptySlotOrAreTwoInputsEqual = true; + continue; + } + rInputs[i] = currentInput; if (!foundIntegratedCircuit && currentInput != null && currentInput.getItem() instanceof GT_IntegratedCircuit_Item) { foundIntegratedCircuit = true; } - rInputs[i] = currentInput; + if (!foundEmptySlotOrAreTwoInputsEqual) { + for (int j = 0; j < i; j++) { + if (GT_Utility.areStacksEqual(rInputs[i], rInputs[j])) { + foundEmptySlotOrAreTwoInputsEqual = true; + } + } + } } - if (emptySlotLocation != -1 && !foundIntegratedCircuit) { - rInputs[emptySlotLocation] = GT_Utility.getIntegratedCircuit(0); + if (!foundIntegratedCircuit && foundEmptySlotOrAreTwoInputsEqual) { + rInputs[mInputSlotCount] = GT_Utility.getIntegratedCircuit(0); } return rInputs; } diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index 99ef4d74..6aecc966 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2542,8 +2542,8 @@ if(Loader.isModLoaded("Railcraft")){ GT_Values.RA.addUniversalDistillationRecipe(FluidRegistry.getFluidStack("potion.vinegar", 40), new FluidStack[]{Materials.AceticAcid.getFluid(5), Materials.Water.getFluid(35)}, GT_Values.NI, 20, 64); GT_Values.RA.addMixerRecipe(Materials.Calcite.getDust(1), GT_Utility.getIntegratedCircuit(0), GT_Values.NI, GT_Values.NI, Materials.AceticAcid.getFluid(2000), Materials.CalciumAcetateSolution.getFluid(1000), GT_Values.NI, 240, 16); GT_Values.RA.addMixerRecipe(Materials.Calcium.getDust(1), GT_Utility.getIntegratedCircuit(0), GT_Values.NI, GT_Values.NI, Materials.AceticAcid.getFluid(2000), Materials.CalciumAcetateSolution.getFluid(1000), GT_Values.NI, 80, 16); - GT_Values.RA.addMixerRecipe(Materials.Calcite.getDust(1), Materials.Empty.getCells(1), GT_Utility.getIntegratedCircuit(10), GT_Values.NI, Materials.AceticAcid.getFluid(2000), Materials.CalciumAcetateSolution.getFluid(1000), GT_Values.NI, 240, 16); - GT_Values.RA.addMixerRecipe(Materials.Calcium.getDust(1), Materials.Empty.getCells(1), GT_Utility.getIntegratedCircuit(10), GT_Values.NI, Materials.AceticAcid.getFluid(2000), Materials.CalciumAcetateSolution.getFluid(1000), GT_Values.NI, 80, 16); + GT_Values.RA.addMixerRecipe(Materials.Calcite.getDust(1), Materials.Empty.getCells(1), GT_Utility.getIntegratedCircuit(10), GT_Values.NI, Materials.AceticAcid.getFluid(2000), GT_Values.NF, Materials.CalciumAcetateSolution.getCells(1), 240, 16); + GT_Values.RA.addMixerRecipe(Materials.Calcium.getDust(1), Materials.Empty.getCells(1), GT_Utility.getIntegratedCircuit(10), GT_Values.NI, Materials.AceticAcid.getFluid(2000), GT_Values.NF, Materials.CalciumAcetateSolution.getCells(1), 80, 16); GameRegistry.addSmelting(Materials.CalciumAcetateSolution.getCells(1), Materials.Acetone.getCells(1), 0); GT_Values.RA.addFluidHeaterRecipe(GT_Utility.getIntegratedCircuit(0), Materials.CalciumAcetateSolution.getFluid(1000), Materials.Acetone.getFluid(1000), 80, 30); GT_Values.RA.addUniversalDistillationRecipe(Materials.CalciumAcetateSolution.getFluid(1000), new FluidStack[]{Materials.Acetone.getFluid(1000)}, Materials.Calcite.getDustSmall(3), 80, 480);