diff options
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r-- | src/main/java/gregtech/api/util/OutputHatchWrapper.java | 5 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/VoidProtectionHelper.java | 23 |
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); |