aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/GT_ParallelHelper.java49
-rw-r--r--src/main/java/gregtech/api/util/VoidProtectionHelper.java48
2 files changed, 77 insertions, 20 deletions
diff --git a/src/main/java/gregtech/api/util/GT_ParallelHelper.java b/src/main/java/gregtech/api/util/GT_ParallelHelper.java
index 04218f4566..ff45f8213b 100644
--- a/src/main/java/gregtech/api/util/GT_ParallelHelper.java
+++ b/src/main/java/gregtech/api/util/GT_ParallelHelper.java
@@ -7,6 +7,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockB
import gregtech.api.multitileentity.multiblock.base.Controller;
import gregtech.api.objects.XSTR;
+@SuppressWarnings({ "unused", "UnusedReturnValue" })
public class GT_ParallelHelper {
/**
@@ -55,9 +56,13 @@ public class GT_ParallelHelper {
*/
private FluidStack[] mFluidOutputs;
/**
- * Does the multi have void protection enabled
+ * Does the multi have void protection enabled for items
*/
- private boolean mVoidProtection;
+ private boolean protectExcessItem;
+ /**
+ * Does the multi have void protection enabled for fluids
+ */
+ private boolean protectExcessFluid;
/**
* Should the Parallel Helper automatically consume for the multi
*/
@@ -87,20 +92,38 @@ public class GT_ParallelHelper {
public GT_ParallelHelper() {}
/**
- * Enables void protection on a metatile multiblock.
+ * Sets MetaTE controller, with current configuration for void protection mode.
+ */
+ public GT_ParallelHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta) {
+ return setController(machineMeta, machineMeta.protectsExcessItem(), machineMeta.protectsExcessFluid());
+ }
+
+ /**
+ * Sets MetaTE controller, with void protection mode forcibly.
*/
- public GT_ParallelHelper enableVoidProtection(GT_MetaTileEntity_MultiBlockBase aMachineMeta) {
- mVoidProtection = true;
- mMachineMeta = aMachineMeta;
+ public GT_ParallelHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta, boolean protectExcessItem,
+ boolean protectExcessFluid) {
+ this.protectExcessItem = protectExcessItem;
+ this.protectExcessFluid = protectExcessFluid;
+ this.mMachineMeta = machineMeta;
return this;
}
/**
- * Enables void protection on a multitile multiblock.
+ * Sets MuTE controller, with current configuration for void protection mode.
+ */
+ public GT_ParallelHelper setController(Controller<?> machineMulti) {
+ return setController(machineMulti, machineMulti.protectsExcessItem(), machineMulti.protectsExcessFluid());
+ }
+
+ /**
+ * Sets MuTE controller, with void protection mode forcibly.
*/
- public GT_ParallelHelper enableVoidProtection(Controller<?> aMachineMulti) {
- mVoidProtection = true;
- mMachineMulti = aMachineMulti;
+ public GT_ParallelHelper setController(Controller<?> machineMulti, boolean protectExcessItem,
+ boolean protectExcessFluid) {
+ this.protectExcessItem = protectExcessItem;
+ this.protectExcessFluid = protectExcessFluid;
+ this.mMachineMulti = machineMulti;
return this;
}
@@ -273,12 +296,12 @@ public class GT_ParallelHelper {
mMaxParallel *= mBatchModifier;
}
// Let's look at how many parallels we can get with void protection
- if (mVoidProtection) {
+ if (protectExcessItem || protectExcessFluid) {
VoidProtectionHelper voidProtectionHelper = new VoidProtectionHelper();
if (mMachineMeta != null) {
- voidProtectionHelper.setController(mMachineMeta);
+ voidProtectionHelper.setController(mMachineMeta, protectExcessItem, protectExcessFluid);
} else if (mMachineMulti != null) {
- voidProtectionHelper.setController(mMachineMulti);
+ voidProtectionHelper.setController(mMachineMulti, protectExcessItem, protectExcessFluid);
}
voidProtectionHelper.setItemOutputs(mRecipe.mOutputs)
.setFluidOutputs(mRecipe.mFluidOutputs)
diff --git a/src/main/java/gregtech/api/util/VoidProtectionHelper.java b/src/main/java/gregtech/api/util/VoidProtectionHelper.java
index 8b09cd5a3d..9a66a55874 100644
--- a/src/main/java/gregtech/api/util/VoidProtectionHelper.java
+++ b/src/main/java/gregtech/api/util/VoidProtectionHelper.java
@@ -38,6 +38,14 @@ public class VoidProtectionHelper {
*/
private Controller<?> machineMulti;
/**
+ * Does void protection enabled for items
+ */
+ private boolean protectExcessItem;
+ /**
+ * Does void protection enabled for fluids
+ */
+ private boolean protectExcessFluid;
+ /**
* The maximum possible parallel possible for the multiblock
*/
private int maxParallel = 1;
@@ -57,17 +65,37 @@ public class VoidProtectionHelper {
public VoidProtectionHelper() {}
/**
- * Sets MetaTE controller to use for calculation
+ * Sets MetaTE controller, with current configuration for void protection mode.
*/
public VoidProtectionHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta) {
+ return setController(machineMeta, machineMeta.protectsExcessItem(), machineMeta.protectsExcessFluid());
+ }
+
+ /**
+ * Sets MetaTE controller, with void protection mode forcibly.
+ */
+ public VoidProtectionHelper setController(GT_MetaTileEntity_MultiBlockBase machineMeta, boolean protectExcessItem,
+ boolean protectExcessFluid) {
+ this.protectExcessItem = protectExcessItem;
+ this.protectExcessFluid = protectExcessFluid;
this.machineMeta = machineMeta;
return this;
}
/**
- * Sets MuTE controller to use for calculation
+ * Sets MuTE controller, with current configuration for void protection mode.
*/
public VoidProtectionHelper setController(Controller<?> machineMulti) {
+ return setController(machineMulti, machineMulti.protectsExcessItem(), machineMulti.protectsExcessFluid());
+ }
+
+ /**
+ * Sets MuTE controller, with void protection mode forcibly.
+ */
+ public VoidProtectionHelper setController(Controller<?> machineMulti, boolean protectExcessItem,
+ boolean protectExcessFluid) {
+ this.protectExcessItem = protectExcessItem;
+ this.protectExcessFluid = protectExcessFluid;
this.machineMulti = machineMulti;
return this;
}
@@ -123,6 +151,8 @@ public class VoidProtectionHelper {
fluidOutputs = new FluidStack[0];
}
+ // Don't check ControllerWithOptionalFeatures#protectsExcessItem nor #protectsExcessFluid here,
+ // to allow more involved setting for void protections (see ComplexParallelProcessingLogic)
if (machineMeta != null) {
boolean tMEOutputBus = false;
boolean tMEOutputHatch = false;
@@ -139,16 +169,20 @@ public class VoidProtectionHelper {
break;
}
}
- if (!tMEOutputBus) {
+
+ if (protectExcessItem && itemOutputs.length > 0 && !tMEOutputBus) {
maxParallel = Math.min(calculateMaxItemParallelsForMetaTEs(), maxParallel);
}
-
- if (!tMEOutputHatch) {
+ if (protectExcessFluid && fluidOutputs.length > 0 && !tMEOutputHatch) {
maxParallel = Math.min(calculateMaxFluidParallelsForMetaTEs(), maxParallel);
}
} else if (machineMulti != null) {
- maxParallel = Math.min(calculateMaxItemParallelsForMuTEs(), maxParallel);
- maxParallel = Math.min(calculateMaxFluidParallelsForMuTEs(), maxParallel);
+ if (protectExcessItem && itemOutputs.length > 0) {
+ maxParallel = Math.min(calculateMaxItemParallelsForMuTEs(), maxParallel);
+ }
+ if (protectExcessFluid && fluidOutputs.length > 0) {
+ maxParallel = Math.min(calculateMaxFluidParallelsForMuTEs(), maxParallel);
+ }
}
}