diff options
author | miozune <miozune@gmail.com> | 2023-11-14 15:24:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 15:24:00 +0900 |
commit | f3a11f7eac8a3489d3649bfe2abcbaa659af7a7d (patch) | |
tree | 85ce0103216396f7b54e2d360b73612fb25597c8 /src | |
parent | 825151fe803929abbd4ea9e8e1cad66fc09086a4 (diff) | |
download | GT5-Unofficial-f3a11f7eac8a3489d3649bfe2abcbaa659af7a7d.tar.gz GT5-Unofficial-f3a11f7eac8a3489d3649bfe2abcbaa659af7a7d.tar.bz2 GT5-Unofficial-f3a11f7eac8a3489d3649bfe2abcbaa659af7a7d.zip |
Update chemplant logic to catch up with new parallel helper logic (#782)
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java | 49 |
1 files changed, 17 insertions, 32 deletions
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); } |