diff options
-rw-r--r-- | dependencies.gradle | 2 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java | 49 |
2 files changed, 18 insertions, 33 deletions
diff --git a/dependencies.gradle b/dependencies.gradle index 7f1fd88ed9..22f0a1ec63 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,5 +1,5 @@ dependencies { - api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.79:dev') + api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.80:dev') api("com.github.GTNewHorizons:bartworks:0.8.10:dev") implementation('curse.maven:cofh-core-69162:2388751') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 01454f5b91..670c070d81 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -18,13 +18,13 @@ import java.util.HashMap; import java.util.stream.Collectors; import java.util.stream.IntStream; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.NotNull; @@ -539,7 +539,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt } } - private void damageCatalyst(ItemStack aStack, int minParallel) { + private void damageCatalyst(@Nonnull ItemStack aStack, int minParallel) { // Awakened Draconium Coils with Tungstensteel Pipe Casings (or above) no longer consume catalysts. if (!isCatalystDamageable()) return; for (int i = 0; i < minParallel; i++) { @@ -564,7 +564,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt return new ProcessingLogic() { ItemStack catalystRecipe; - int maxParallelCatalyst; @NotNull @Override @@ -591,37 +590,24 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt } // checks if it has enough catalyst durability - maxParallelCatalyst = maxParallel; if (catalystRecipe != null) { - maxParallelCatalyst = getCatalysts(inputItems, catalystRecipe, maxParallel); + maxParallel = getParallelLimitedByCatalyst(inputItems, catalystRecipe, maxParallel); } - maxParallel = Math.min(maxParallel, maxParallelCatalyst); return CheckRecipeResultRegistry.SUCCESSFUL; } @NotNull @Override protected GT_ParallelHelper createParallelHelper(@NotNull GT_Recipe recipe) { - return new GT_ParallelHelper() { - - @Override - protected boolean tryConsumeRecipeInputs(GT_Recipe recipe, FluidStack[] fluids, ItemStack[] items, - int minParallel) { - if (catalystRecipe != null && getDamage(catalystRecipe) >= getMaxCatalystDurability()) { - return false; - } - boolean hasInputs = super.tryConsumeRecipeInputs(recipe, fluids, items, minParallel); - if (hasInputs && catalystRecipe != null) { - damageCatalyst(catalystRecipe, minParallel); - } - return hasInputs; - } - }.setRecipe(recipe).setItemInputs(inputItems).setFluidInputs(inputFluids) - .setAvailableEUt(availableVoltage * availableAmperage) - .setMachine(machine, protectItems, protectFluids) - .setRecipeLocked(recipeLockableMachine, isRecipeLocked).setMaxParallel(maxParallel) - .setEUtModifier(euModifier).enableBatchMode(batchSize).setConsumption(true) - .setOutputCalculation(true); + return super.createParallelHelper(recipe) + .setInputConsumer((recipeToConsume, amountMultiplier, aFluidInputs, aInputs) -> { + // Correct parallel is already calculated by ProcessingLogic#validateRecipe, + // so we don't need to set MaxParallelCalculator + recipeToConsume.consumeInput(amountMultiplier, aFluidInputs, aInputs); + if (catalystRecipe != null) { + damageCatalyst(catalystRecipe, amountMultiplier); + } + }); } }.setMaxParallelSupplier(this::getMaxParallelRecipes); } @@ -641,18 +627,17 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt } } - private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParallel) { + private int getParallelLimitedByCatalyst(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParallel) { if (!isCatalystDamageable()) { - return getMaxParallelRecipes(); + return aMaxParallel; } - int allowedParallel = 0; for (final ItemStack aInput : aItemInputs) { if (aRecipeCatalyst.isItemEqual(aInput)) { int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); return Math.min(aMaxParallel, aDurabilityRemaining); } } - return allowedParallel; + return 0; } private ItemStack findCatalyst(ItemStack[] aItemInputs, ItemStack[] aRecipeInputs) { @@ -672,11 +657,11 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt return null; } - private int getDamage(ItemStack aStack) { + private int getDamage(@Nonnull ItemStack aStack) { return ItemGenericChemBase.getCatalystDamage(aStack); } - private void setDamage(ItemStack aStack, int aAmount) { + private void setDamage(@Nonnull ItemStack aStack, int aAmount) { ItemGenericChemBase.setCatalystDamage(aStack, aAmount); } |