aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authorMaya <10861407+serenibyss@users.noreply.github.com>2024-12-02 08:12:05 -0600
committerGitHub <noreply@github.com>2024-12-02 08:12:05 -0600
commit62b6fc8498d754ae388f92b933b656da5f38dee0 (patch)
tree42668955cd42c2bdbd86f55ab860089dd6019341 /src/main/java/gregtech/api/util
parent8380ef61ad9e688a2d05a9db70aa55b54288fae6 (diff)
downloadGT5-Unofficial-62b6fc8498d754ae388f92b933b656da5f38dee0.tar.gz
GT5-Unofficial-62b6fc8498d754ae388f92b933b656da5f38dee0.tar.bz2
GT5-Unofficial-62b6fc8498d754ae388f92b933b656da5f38dee0.zip
Fix ME output hatch void protection again (#3594)HEADmaster
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/OutputHatchWrapper.java5
-rw-r--r--src/main/java/gregtech/api/util/VoidProtectionHelper.java23
2 files changed, 22 insertions, 6 deletions
diff --git a/src/main/java/gregtech/api/util/OutputHatchWrapper.java b/src/main/java/gregtech/api/util/OutputHatchWrapper.java
index d570780317..5c3d64f938 100644
--- a/src/main/java/gregtech/api/util/OutputHatchWrapper.java
+++ b/src/main/java/gregtech/api/util/OutputHatchWrapper.java
@@ -63,8 +63,7 @@ public class OutputHatchWrapper implements IFluidStore {
return outputHatch.canStoreFluid(fluidStack) && filter.test(fluidStack);
}
- @Override
- public int getAvailableSpace() {
- return outputHatch.getAvailableSpace();
+ public MTEHatchOutput unwrap() {
+ return outputHatch;
}
}
diff --git a/src/main/java/gregtech/api/util/VoidProtectionHelper.java b/src/main/java/gregtech/api/util/VoidProtectionHelper.java
index 227601113b..97728d14fd 100644
--- a/src/main/java/gregtech/api/util/VoidProtectionHelper.java
+++ b/src/main/java/gregtech/api/util/VoidProtectionHelper.java
@@ -17,6 +17,7 @@ import gregtech.api.interfaces.fluid.IFluidStore;
import gregtech.api.interfaces.tileentity.IVoidable;
import gregtech.api.logic.FluidInventoryLogic;
import gregtech.api.logic.ItemInventoryLogic;
+import gregtech.common.tileentities.machines.MTEHatchOutputME;
/**
* Helper class to calculate how many parallels of items / fluids can fit in the output buses / hatches.
@@ -214,7 +215,7 @@ public class VoidProtectionHelper {
return;
}
}
- if (protectExcessFluid && fluidOutputs.length > 0) {
+ if (protectExcessFluid && fluidOutputs.length > 0 && !machine.canDumpFluidToME()) {
maxParallel = Math.min(calculateMaxFluidParallels(), maxParallel);
if (maxParallel <= 0) {
isFluidFull = true;
@@ -255,7 +256,14 @@ public class VoidProtectionHelper {
}
for (IFluidStore tHatch : hatches) {
- int tSpaceLeft = tHatch.getAvailableSpace();
+ int tSpaceLeft;
+ if (tHatch instanceof MTEHatchOutputME tMEHatch) {
+ tSpaceLeft = tMEHatch.canAcceptFluid() ? Integer.MAX_VALUE : 0;
+ } else if (tHatch instanceof OutputHatchWrapper w && w.unwrap() instanceof MTEHatchOutputME tMEHatch) {
+ tSpaceLeft = tMEHatch.canAcceptFluid() ? Integer.MAX_VALUE : 0;
+ } else {
+ tSpaceLeft = tHatch.getCapacity() - tHatch.getFluidAmount();
+ }
// check if hatch filled
if (tSpaceLeft <= 0) continue;
@@ -289,7 +297,16 @@ public class VoidProtectionHelper {
ParallelStackInfo<FluidStack> tParallel = aParallelQueue.poll();
assert tParallel != null; // will always be true, specifying assert here to avoid IDE/compiler warnings
Integer tCraftSize = tFluidOutputMap.get(tParallel.stack);
- int tSpaceLeft = tHatch.getAvailableSpace();
+
+ int tSpaceLeft;
+ if (tHatch instanceof MTEHatchOutputME tMEHatch) {
+ tSpaceLeft = tMEHatch.canAcceptFluid() ? Integer.MAX_VALUE : 0;
+ } else if (tHatch instanceof OutputHatchWrapper w && w.unwrap() instanceof MTEHatchOutputME tMEHatch) {
+ tSpaceLeft = tMEHatch.canAcceptFluid() ? Integer.MAX_VALUE : 0;
+ } else {
+ tSpaceLeft = tHatch.getCapacity();
+ }
+
tParallel.batch += (tParallel.partial + tSpaceLeft) / tCraftSize;
tParallel.partial = (tParallel.partial + tSpaceLeft) % tCraftSize;
aParallelQueue.add(tParallel);