diff options
author | Elisis <gtandemmodding@gmail.com> | 2022-09-01 17:39:22 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-01 17:39:22 +1000 |
commit | 1cf3f485e9a1f8d05d83a51cb429fbef5da9fa14 (patch) | |
tree | c45e4749fb59a4240eb81626fd72a809647a707c | |
parent | 47fb2b5ee064fd33aa2998d17e4f93706ac28e07 (diff) | |
parent | bed08cddf275c70121e0dbd85a24403995074713 (diff) | |
download | GT5-Unofficial-1cf3f485e9a1f8d05d83a51cb429fbef5da9fa14.tar.gz GT5-Unofficial-1cf3f485e9a1f8d05d83a51cb429fbef5da9fa14.tar.bz2 GT5-Unofficial-1cf3f485e9a1f8d05d83a51cb429fbef5da9fa14.zip |
Merge pull request #30 from GTNewHorizons/cleanup-checkRecipe
Cleanup checkRecipe
-rw-r--r-- | src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java | 37 | ||||
-rw-r--r-- | src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java | 142 |
2 files changed, 80 insertions, 99 deletions
diff --git a/src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java b/src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java index 6f2cc4535f..9342ae3962 100644 --- a/src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java +++ b/src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java @@ -25,11 +25,9 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import java.util.ArrayList; -import java.util.Arrays; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -93,41 +91,38 @@ public class Digester extends GT_MetaTileEntity_EnhancedMultiBlockBase<Digester> @Override public boolean checkRecipe(ItemStack itemStack) { - GT_Log.out.print("Digester: in checkRecipe\n"); + // GT_Log.out.print("Digester: in checkRecipe\n"); ArrayList<FluidStack> tFluidInputs = this.getStoredFluids(); FluidStack[] tFluidInputArray = tFluidInputs.toArray(new FluidStack[0]); ItemStack[] tItems = this.getStoredInputs().toArray(new ItemStack[0]); long tVoltage = this.getMaxInputVoltage(); - GT_Log.out.print("Digester: " + Arrays.toString(mInventory)); + // GT_Log.out.print("Digester: " + Arrays.toString(mInventory)); // Collection<GT_Recipe> tRecipes = RecipeAdder.instance.DigesterRecipes.mRecipeList; GT_Recipe tRecipe = RecipeAdder.instance.DigesterRecipes.findRecipe( getBaseMetaTileEntity(), false, tVoltage, tFluidInputArray, tItems); - if (tRecipe == null) return false; + if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluidInputArray, tItems)) return false; // GT_Log.out.print("Recipe not null\n"); - if (tRecipe.isRecipeInputEqual(true, tFluidInputArray, tItems)) { - // GT_Log.out.print("in isRecipeInputEqual\n"); - this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - this.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; + this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + this.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); - if (this.mEUt > 0) this.mEUt = (-this.mEUt); - // GT_Log.out.print("valid values"); + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; - if (tRecipe.mSpecialValue > this.getCoilLevel().getHeat()) return false; - // GT_Log.out.print("Coils good\n"); - // GT_Log.out.print(tRecipe.getFluidOutput(0).getLocalizedName()); - this.mOutputFluids = new FluidStack[] {tRecipe.getFluidOutput(0)}; + if (this.mEUt > 0) this.mEUt = (-this.mEUt); + // GT_Log.out.print("valid values"); - this.mOutputItems = new ItemStack[] {tRecipe.getOutput(0)}; - return true; - } - return false; + if (tRecipe.mSpecialValue > this.getCoilLevel().getHeat()) return false; + // GT_Log.out.print("Coils good\n"); + // GT_Log.out.print(tRecipe.getFluidOutput(0).getLocalizedName()); + this.mOutputFluids = tRecipe.mFluidOutputs; + this.mOutputItems = tRecipe.mOutputs; + this.updateSlots(); + return true; } @Override diff --git a/src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java b/src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java index 08af3b5549..46d9a49b3d 100644 --- a/src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java +++ b/src/main/java/com/elisis/gtnhlanth/common/tileentity/DissolutionTank.java @@ -28,7 +28,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMul import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; -import java.util.ArrayList; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -87,96 +87,82 @@ public class DissolutionTank extends GT_MetaTileEntity_EnhancedMultiBlockBase<Di @Override public boolean checkRecipe(ItemStack itemStack) { - // GT_Log.out.print("in checkRecipe"); - ArrayList<FluidStack> tFluidInputs = this.getStoredFluids(); + List<FluidStack> tFluidInputs = this.getStoredFluids(); FluidStack[] tFluidInputArray = tFluidInputs.toArray(new FluidStack[0]); ItemStack[] tItems = this.getStoredInputs().toArray(new ItemStack[0]); long tVoltage = this.getMaxInputVoltage(); - // Collection<GT_Recipe> tRecipes = RecipeAdder.instance.DigesterRecipes.mRecipeList; GT_Recipe tRecipe = RecipeAdder.instance.DissolutionTankRecipes.findRecipe( getBaseMetaTileEntity(), false, tVoltage, tFluidInputArray, tItems); - if (tRecipe == null) return false; - + if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluidInputArray, tItems)) return false; // GT_Log.out.print("Recipe not null\n"); - if (tRecipe.isRecipeInputEqual(true, tFluidInputArray, tItems)) { - - this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - this.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); - - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; - - if (this.mEUt > 0) this.mEUt = (-this.mEUt); - - FluidStack majorGenericFluid = tRecipe.mFluidInputs[0]; - FluidStack minorGenericFluid = tRecipe.mFluidInputs[1]; - - FluidStack majorInput = null; - FluidStack minorInput = null; - - int majorAmount = 0; - int minorAmount = 0; - - FluidStack fluidInputOne = tFluidInputs.get(0); - FluidStack fluidInputTwo = tFluidInputs.get(1); - - majorInput = ((fluidInputOne.getUnlocalizedName().equals(majorGenericFluid.getUnlocalizedName())) - ? fluidInputOne - : fluidInputTwo); - // GT_Log.out.print(majorInput.getLocalizedName()); - if (fluidInputOne.getUnlocalizedName().equals(majorGenericFluid.getUnlocalizedName())) { - if (fluidInputTwo.getUnlocalizedName().equals(minorGenericFluid.getUnlocalizedName())) { - majorInput = fluidInputOne; - majorAmount = fluidInputOne.amount; - minorInput = fluidInputTwo; - minorAmount = fluidInputTwo.amount; - // GT_Log.out.print("in first IF"); - } else return false; // No valid other input - - } else if (fluidInputTwo.getUnlocalizedName().equals(majorGenericFluid.getUnlocalizedName())) { - if (fluidInputOne.getUnlocalizedName().equals(minorGenericFluid.getUnlocalizedName())) { - majorInput = fluidInputTwo; - majorAmount = fluidInputTwo.amount; - minorInput = fluidInputOne; - minorAmount = fluidInputOne.amount; - // GT_Log.out.print("in second if"); - } else return false; - } else return false; + this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + this.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; + if (this.mEUt > 0) this.mEUt = (-this.mEUt); - // GT_Log.out.print("out of switch weirdness"); - - /* - for (FluidStack fluid : tFluidInputs) { - String name = fluid.getUnlocalizedName(); - if (name == majorGenericFluid.getUnlocalizedName()) - majorInput = fluid; - - else if (name == minorGenericFluid.getUnlocalizedName()) - minorInput = fluid; - } - */ - if (majorInput == null || minorInput == null) return false; - - // GT_Log.out.print("major " + majorInput.getLocalizedName()); - // GT_Log.out.print("minor " + minorInput.getLocalizedName()); - - // GT_Log.out.print("mjrinputamt " + majorInput.amount); - /* - if ((majorInput.amount / tRecipe.mSpecialValue) != (minorInput.amount)) - return false; - */ - if ((majorAmount / tRecipe.mSpecialValue) != (minorAmount)) return false; - - this.mOutputFluids = new FluidStack[] {tRecipe.getFluidOutput(0)}; - this.mOutputItems = new ItemStack[] {tRecipe.getOutput(0)}; - return true; + this.updateSlots(); + + if (!checkRatio(tRecipe, tFluidInputs)) { + stopMachine(); + return false; } - return false; + + this.mOutputFluids = new FluidStack[] {tRecipe.getFluidOutput(0)}; + this.mOutputItems = tRecipe.mOutputs; + return true; + } + + private boolean checkRatio(GT_Recipe tRecipe, List<FluidStack> tFluidInputs) { + FluidStack majorGenericFluid = tRecipe.mFluidInputs[0]; + FluidStack minorGenericFluid = tRecipe.mFluidInputs[1]; + + // FluidStack majorInput = null; + // FluidStack minorInput = null; + + int majorAmount; + int minorAmount; + + FluidStack fluidInputOne = tFluidInputs.get(0); + FluidStack fluidInputTwo = tFluidInputs.get(1); + + // majorInput = ((fluidInputOne.getUnlocalizedName().equals(majorGenericFluid.getUnlocalizedName())) + // ? fluidInputOne + // : fluidInputTwo); + // GT_Log.out.print(majorInput.getLocalizedName()); + if (fluidInputOne.getUnlocalizedName().equals(majorGenericFluid.getUnlocalizedName())) { + if (fluidInputTwo.getUnlocalizedName().equals(minorGenericFluid.getUnlocalizedName())) { + // majorInput = fluidInputOne; + majorAmount = fluidInputOne.amount; + // minorInput = fluidInputTwo; + minorAmount = fluidInputTwo.amount; + // GT_Log.out.print("in first IF"); + } else return false; // No valid other input + + } else if (fluidInputTwo.getUnlocalizedName().equals(majorGenericFluid.getUnlocalizedName())) { + if (fluidInputOne.getUnlocalizedName().equals(minorGenericFluid.getUnlocalizedName())) { + // majorInput = fluidInputTwo; + majorAmount = fluidInputTwo.amount; + // minorInput = fluidInputOne; + minorAmount = fluidInputOne.amount; + // GT_Log.out.print("in second if"); + } else return false; + + } else return false; + + // GT_Log.out.print("out of switch weirdness"); + + // GT_Log.out.print("major " + majorInput.getLocalizedName()); + // GT_Log.out.print("minor " + minorInput.getLocalizedName()); + + // GT_Log.out.print("mjrinputamt " + majorInput.amount); + return majorAmount / tRecipe.mSpecialValue == minorAmount; } @Override |