diff options
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_ParallelHelper.java')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_ParallelHelper.java | 77 |
1 files changed, 75 insertions, 2 deletions
diff --git a/src/main/java/gregtech/api/util/GT_ParallelHelper.java b/src/main/java/gregtech/api/util/GT_ParallelHelper.java index 6ec736b15f..ff739664f4 100644 --- a/src/main/java/gregtech/api/util/GT_ParallelHelper.java +++ b/src/main/java/gregtech/api/util/GT_ParallelHelper.java @@ -13,6 +13,8 @@ import net.minecraftforge.fluids.FluidStack; import gregtech.api.interfaces.tileentity.IRecipeLockable; import gregtech.api.interfaces.tileentity.IVoidable; +import gregtech.api.logic.FluidInventoryLogic; +import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.objects.XSTR; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResult; @@ -61,6 +63,14 @@ public class GT_ParallelHelper { */ private ItemStack[] itemInputs; /** + * The inputs of the machine for current recipe check + */ + private ItemInventoryLogic itemInputInventory; + /** + * The output item inventory of the machine + */ + private ItemInventoryLogic itemOutputInventory; + /** * The outputs of the recipe with the applied parallel */ private ItemStack[] itemOutputs; @@ -69,6 +79,14 @@ public class GT_ParallelHelper { */ private FluidStack[] fluidInputs; /** + * The inputs of the machine for the current recipe check + */ + private FluidInventoryLogic fluidInputInventory; + /** + * The output fluid inventory of the machine; + */ + private FluidInventoryLogic fluidOutputInventory; + /** * The outputs of the recipe with the applied parallel */ private FluidStack[] fluidOutputs; @@ -117,18 +135,25 @@ public class GT_ParallelHelper { * Calculator to use for overclocking */ private GT_OverclockCalculator calculator; - + @Nonnull private CheckRecipeResult result = CheckRecipeResultRegistry.NONE; private Function<Integer, ItemStack[]> customItemOutputCalculation; private Function<Integer, FluidStack[]> customFluidOutputCalculation; + /** + * MuTE Mode this is a mode for changing how the GT_ParallelHelper works as Mutes don't use ItemStack and FluidStack + * arrays for inputs + */ + private boolean muteMode = false; + public GT_ParallelHelper() {} /** * Sets machine, with current configuration for void protection mode. */ + @Nonnull public GT_ParallelHelper setMachine(IVoidable machine) { return setMachine(machine, machine.protectsExcessItem(), machine.protectsExcessFluid()); } @@ -136,6 +161,7 @@ public class GT_ParallelHelper { /** * Sets machine, with void protection mode forcibly. */ + @Nonnull public GT_ParallelHelper setMachine(IVoidable machine, boolean protectExcessItem, boolean protectExcessFluid) { this.protectExcessItem = protectExcessItem; this.protectExcessFluid = protectExcessFluid; @@ -146,11 +172,13 @@ public class GT_ParallelHelper { /** * Sets the recipe, which will be used for the parallel calculation */ + @Nonnull public GT_ParallelHelper setRecipe(@Nonnull GT_Recipe aRecipe) { recipe = Objects.requireNonNull(aRecipe); return this; } + @Nonnull public GT_ParallelHelper setRecipeLocked(IRecipeLockable singleRecipeMachine, boolean isRecipeLocked) { this.singleRecipeMachine = singleRecipeMachine; this.isRecipeLocked = isRecipeLocked; @@ -160,6 +188,7 @@ public class GT_ParallelHelper { /** * Sets the items available for the recipe check */ + @Nonnull public GT_ParallelHelper setItemInputs(ItemStack... aItemInputs) { this.itemInputs = aItemInputs; return this; @@ -168,6 +197,7 @@ public class GT_ParallelHelper { /** * Sets the fluid inputs available for the recipe check */ + @Nonnull public GT_ParallelHelper setFluidInputs(FluidStack... aFluidInputs) { this.fluidInputs = aFluidInputs; return this; @@ -176,6 +206,7 @@ public class GT_ParallelHelper { /** * Sets the available eut when trying for more parallels */ + @Nonnull public GT_ParallelHelper setAvailableEUt(long aAvailableEUt) { this.availableEUt = aAvailableEUt; return this; @@ -184,11 +215,13 @@ public class GT_ParallelHelper { /** * Sets the modifier for recipe eut. 1 does nothing 0.9 is 10% less. 1.1 is 10% more */ + @Nonnull public GT_ParallelHelper setEUtModifier(float aEUtModifier) { this.eutModifier = aEUtModifier; return this; } + @Nonnull public GT_ParallelHelper setCalculator(GT_OverclockCalculator calculator) { this.calculator = calculator; return this; @@ -199,6 +232,7 @@ public class GT_ParallelHelper { * * @param consume Should we consume inputs */ + @Nonnull public GT_ParallelHelper setConsumption(boolean consume) { this.consume = consume; return this; @@ -207,6 +241,7 @@ public class GT_ParallelHelper { /** * Sets the MaxParallel a multi can handle */ + @Nonnull public GT_ParallelHelper setMaxParallel(int maxParallel) { this.maxParallel = maxParallel; return this; @@ -216,6 +251,7 @@ public class GT_ParallelHelper { * Enables Batch mode. Can do up to an additional processed recipes of mCurrentParallel * mBatchModifier A batch * modifier of 1 does nothing */ + @Nonnull public GT_ParallelHelper enableBatchMode(int batchModifier) { this.batchMode = batchModifier > 1; this.batchModifier = batchModifier; @@ -227,6 +263,7 @@ public class GT_ParallelHelper { * * @param calculateOutputs Should we calculate outputs with the helper or not */ + @Nonnull public GT_ParallelHelper setOutputCalculation(boolean calculateOutputs) { this.calculateOutputs = calculateOutputs; return this; @@ -236,6 +273,7 @@ public class GT_ParallelHelper { * Set a custom way to calculate item outputs. You are given the amount of parallels and must return an ItemStack * array */ + @Nonnull public GT_ParallelHelper setCustomItemOutputCalculation(Function<Integer, ItemStack[]> custom) { customItemOutputCalculation = custom; return this; @@ -245,11 +283,30 @@ public class GT_ParallelHelper { * Set a custom way to calculate item outputs. You are given the amount of parallels and must return a FluidStack * array */ + @Nonnull public GT_ParallelHelper setCustomFluidOutputCalculation(Function<Integer, FluidStack[]> custom) { customFluidOutputCalculation = custom; return this; } + @Nonnull + public GT_ParallelHelper setMuTEMode(boolean muteMode) { + this.muteMode = muteMode; + return this; + } + + @Nonnull + public GT_ParallelHelper setItemInputInventory(ItemInventoryLogic itemInputInventory) { + this.itemInputInventory = itemInputInventory; + return this; + } + + @Nonnull + public GT_ParallelHelper setFluidInputInventory(FluidInventoryLogic fluidInputInventory) { + this.fluidInputInventory = fluidInputInventory; + return this; + } + /** * Sets method for calculating max parallel from given inputs. */ @@ -266,9 +323,22 @@ public class GT_ParallelHelper { return this; } + @Nonnull + public GT_ParallelHelper setItemOutputInventory(ItemInventoryLogic itemOutputInventory) { + this.itemOutputInventory = itemOutputInventory; + return this; + } + + @Nonnull + public GT_ParallelHelper setFluidOutputInventory(FluidInventoryLogic fluidOutputInventory) { + this.fluidOutputInventory = fluidOutputInventory; + return this; + } + /** * Finishes the GT_ParallelHelper. Anything changed after this will not effect anything */ + @Nonnull public GT_ParallelHelper build() { if (built) { throw new IllegalStateException("Tried to build twice"); @@ -407,7 +477,7 @@ public class GT_ParallelHelper { // Let's look at how many parallels we can get with void protection if (protectExcessItem || protectExcessFluid) { - if (machine == null) { + if (machine == null && !muteMode) { throw new IllegalStateException("Tried to calculate void protection, but machine is not set"); } VoidProtectionHelper voidProtectionHelper = new VoidProtectionHelper(); @@ -415,6 +485,9 @@ public class GT_ParallelHelper { .setItemOutputs(truncatedItemOutputs) .setFluidOutputs(truncatedFluidOutputs) .setMaxParallel(maxParallel) + .setItemOutputInventory(itemOutputInventory) + .setFluidOutputInventory(fluidOutputInventory) + .setMuTEMode(muteMode) .build(); maxParallel = Math.min(voidProtectionHelper.getMaxParallel(), maxParallel); if (voidProtectionHelper.isItemFull()) { |