aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2023-06-05 13:52:07 +0900
committerGitHub <noreply@github.com>2023-06-05 06:52:07 +0200
commit04c229a76d91f822a9c534341bcddbc2edf8b43e (patch)
treef7e21c339067c85b3479c5887c79ca86e664e189 /src/main/java/gregtech
parentdb089891a20e5696096907864578e39586035e6e (diff)
downloadGT5-Unofficial-04c229a76d91f822a9c534341bcddbc2edf8b43e.tar.gz
GT5-Unofficial-04c229a76d91f822a9c534341bcddbc2edf8b43e.tar.bz2
GT5-Unofficial-04c229a76d91f822a9c534341bcddbc2edf8b43e.zip
Use IVoidable for GT_ParallelHelper (#2053)
Diffstat (limited to 'src/main/java/gregtech')
-rw-r--r--src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java2
-rw-r--r--src/main/java/gregtech/api/util/GT_ParallelHelper.java47
-rw-r--r--src/main/java/gregtech/api/util/VoidProtectionHelper.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java2
4 files changed, 25 insertions, 28 deletions
diff --git a/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java b/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java
index 07c9f94101..65d7ea5397 100644
--- a/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java
+++ b/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java
@@ -125,7 +125,7 @@ public class ComplexParallelProcessingLogic {
.setItemInputs(inputItems[index])
.setFluidInputs(inputFluids[index])
.setAvailableEUt(availableEut[index])
- .setController(tileEntity, isItemVoidProtected[index], isFluidVoidProtected[index])
+ .setMachine(tileEntity, isItemVoidProtected[index], isFluidVoidProtected[index])
.enableConsumption()
.enableOutputCalculation();
diff --git a/src/main/java/gregtech/api/util/GT_ParallelHelper.java b/src/main/java/gregtech/api/util/GT_ParallelHelper.java
index 66f1bac8b8..9ceec7af44 100644
--- a/src/main/java/gregtech/api/util/GT_ParallelHelper.java
+++ b/src/main/java/gregtech/api/util/GT_ParallelHelper.java
@@ -3,21 +3,17 @@ package gregtech.api.util;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
+import gregtech.api.interfaces.tileentity.IVoidable;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import gregtech.api.multitileentity.multiblock.base.Controller;
import gregtech.api.objects.XSTR;
@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class GT_ParallelHelper {
/**
- * A MetaTileEntity Controller
+ * Machine used for calculation
*/
- private GT_MetaTileEntity_MultiBlockBase mMachineMeta;
- /**
- * A MultiTileEntity Controller
- */
- private Controller<?> mMachineMulti;
+ private IVoidable machine;
/**
* Recipe used when trying to calculate parallels
*/
@@ -93,37 +89,39 @@ public class GT_ParallelHelper {
/**
* Sets MetaTE controller, with current configuration for void protection mode.
+ *
+ * @deprecated Use {@link #setMachine(IVoidable)}
*/
+ @Deprecated
public GT_ParallelHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta) {
- return setController(machineMeta, machineMeta.protectsExcessItem(), machineMeta.protectsExcessFluid());
+ return setMachine(machineMeta, machineMeta.protectsExcessItem(), machineMeta.protectsExcessFluid());
}
/**
* Sets MetaTE controller, with void protection mode forcibly.
+ *
+ * @deprecated Use {@link #setMachine(IVoidable, boolean, boolean)}
*/
+ @Deprecated
public GT_ParallelHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta, boolean protectExcessItem,
boolean protectExcessFluid) {
- this.protectExcessItem = protectExcessItem;
- this.protectExcessFluid = protectExcessFluid;
- this.mMachineMeta = machineMeta;
- return this;
+ return setMachine(machineMeta, protectExcessItem, protectExcessFluid);
}
/**
- * Sets MuTE controller, with current configuration for void protection mode.
+ * Sets machine, with current configuration for void protection mode.
*/
- public GT_ParallelHelper setController(Controller<?> machineMulti) {
- return setController(machineMulti, machineMulti.protectsExcessItem(), machineMulti.protectsExcessFluid());
+ public GT_ParallelHelper setMachine(IVoidable machine) {
+ return setMachine(machine, machine.protectsExcessItem(), machine.protectsExcessFluid());
}
/**
- * Sets MuTE controller, with void protection mode forcibly.
+ * Sets machine, with void protection mode forcibly.
*/
- public GT_ParallelHelper setController(Controller<?> machineMulti, boolean protectExcessItem,
- boolean protectExcessFluid) {
+ public GT_ParallelHelper setMachine(IVoidable machine, boolean protectExcessItem, boolean protectExcessFluid) {
this.protectExcessItem = protectExcessItem;
this.protectExcessFluid = protectExcessFluid;
- this.mMachineMulti = machineMulti;
+ this.machine = machine;
return this;
}
@@ -297,13 +295,12 @@ public class GT_ParallelHelper {
}
// Let's look at how many parallels we can get with void protection
if (protectExcessItem || protectExcessFluid) {
- VoidProtectionHelper voidProtectionHelper = new VoidProtectionHelper();
- if (mMachineMeta != null) {
- voidProtectionHelper.setMachine(mMachineMeta, protectExcessItem, protectExcessFluid);
- } else if (mMachineMulti != null) {
- voidProtectionHelper.setMachine(mMachineMulti, protectExcessItem, protectExcessFluid);
+ if (machine == null) {
+ throw new IllegalStateException("Tried to calculate void protection, but machine is not set");
}
- voidProtectionHelper.setItemOutputs(mRecipe.mOutputs)
+ VoidProtectionHelper voidProtectionHelper = new VoidProtectionHelper();
+ voidProtectionHelper.setMachine(machine)
+ .setItemOutputs(mRecipe.mOutputs)
.setFluidOutputs(mRecipe.mFluidOutputs)
.setMaxParallel(mMaxParallel)
.build();
diff --git a/src/main/java/gregtech/api/util/VoidProtectionHelper.java b/src/main/java/gregtech/api/util/VoidProtectionHelper.java
index fe80bc97b4..94c2dfcaaf 100644
--- a/src/main/java/gregtech/api/util/VoidProtectionHelper.java
+++ b/src/main/java/gregtech/api/util/VoidProtectionHelper.java
@@ -58,7 +58,7 @@ public class VoidProtectionHelper {
*/
@Deprecated
public VoidProtectionHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta) {
- return setController(machineMeta, machineMeta.protectsExcessItem(), machineMeta.protectsExcessFluid());
+ return setMachine(machineMeta, machineMeta.protectsExcessItem(), machineMeta.protectsExcessFluid());
}
/**
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java
index 04b62d40f6..8605f3643f 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java
@@ -584,7 +584,7 @@ public class GT_MetaTileEntity_PCBFactory extends
if (recipeAllowed) {
GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe)
- .setController(this)
+ .setMachine(this)
.setItemInputs(aItemInputs)
.setFluidInputs(aFluidInputs)
.setMaxParallel(aMaxParallel)