aboutsummaryrefslogtreecommitdiff
path: root/src/main
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
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')
-rw-r--r--src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java27
-rw-r--r--src/main/java/gregtech/api/interfaces/fluid/IFluidStore.java7
-rw-r--r--src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java7
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java18
-rw-r--r--src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java5
-rw-r--r--src/main/java/gregtech/api/util/OutputHatchWrapper.java5
-rw-r--r--src/main/java/gregtech/api/util/VoidProtectionHelper.java23
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/MTEHatchOutputME.java10
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/MTEDistillationTower.java10
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java10
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java4
11 files changed, 100 insertions, 26 deletions
diff --git a/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java
index e98158ec7f..4c3199f33f 100644
--- a/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java
+++ b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java
@@ -56,6 +56,7 @@ import gregtech.api.recipe.RecipeMaps;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
+import gregtech.common.tileentities.machines.MTEHatchOutputME;
public class MTEMegaDistillTower extends MegaMultiBlockBase<MTEMegaDistillTower> implements ISurvivalConstructable {
@@ -392,6 +393,32 @@ public class MTEMegaDistillTower extends MegaMultiBlockBase<MTEMegaDistillTower>
}
@Override
+ public boolean canDumpFluidToME() {
+
+ // All fluids can be dumped to ME only if each layer contains a ME Output Hatch.
+ for (List<MTEHatchOutput> tLayerOutputHatches : this.mOutputHatchesByLayer) {
+
+ boolean foundMEHatch = false;
+
+ for (IFluidStore tHatch : tLayerOutputHatches) {
+ if (tHatch instanceof MTEHatchOutputME tMEHatch) {
+ if (tMEHatch.canAcceptFluid()) {
+ foundMEHatch = true;
+ break;
+ }
+ }
+ }
+
+ // Exit if we didn't find a valid hatch on this layer.
+ if (!foundMEHatch) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @Override
protected void addFluidOutputs(FluidStack[] outputFluids) {
for (int i = 0; i < outputFluids.length && i < this.mOutputHatchesByLayer.size(); i++) {
FluidStack tStack = outputFluids[i].copy();
diff --git a/src/main/java/gregtech/api/interfaces/fluid/IFluidStore.java b/src/main/java/gregtech/api/interfaces/fluid/IFluidStore.java
index 5b5bb08c87..047cf4df5b 100644
--- a/src/main/java/gregtech/api/interfaces/fluid/IFluidStore.java
+++ b/src/main/java/gregtech/api/interfaces/fluid/IFluidStore.java
@@ -19,11 +19,4 @@ public interface IFluidStore extends IFluidTank {
* @return Whether to allow given fluid to be inserted into this.
*/
boolean canStoreFluid(@Nonnull FluidStack fluidStack);
-
- /**
- * @return The amount of fluid that can be stored in this.
- */
- default int getAvailableSpace() {
- return getCapacity() - getFluidAmount();
- }
}
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java b/src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java
index f55d71debc..841fd07bba 100644
--- a/src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java
+++ b/src/main/java/gregtech/api/interfaces/tileentity/IVoidable.java
@@ -79,4 +79,11 @@ public interface IVoidable {
* as this might be called every tick and cause lag.
*/
boolean canDumpItemToME();
+
+ /**
+ * @return If this machine has ability to dump fluid outputs to ME network.
+ * This doesn't need to check if it can actually dump to ME,
+ * as this might be called every tick and cause lag.
+ */
+ boolean canDumpFluidToME();
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java
index 2a5e3c1552..4a8f69fe9a 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java
@@ -109,6 +109,7 @@ import gregtech.common.tileentities.machines.MTEHatchCraftingInputME;
import gregtech.common.tileentities.machines.MTEHatchInputBusME;
import gregtech.common.tileentities.machines.MTEHatchInputME;
import gregtech.common.tileentities.machines.MTEHatchOutputBusME;
+import gregtech.common.tileentities.machines.MTEHatchOutputME;
import gregtech.common.tileentities.machines.multi.MTELargeTurbine;
import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
@@ -1321,6 +1322,11 @@ public abstract class MTEMultiBlockBase extends MetaTileEntity
continue;
}
if (!tHatch.canStoreFluid(copiedFluidStack)) continue;
+
+ if (tHatch instanceof MTEHatchOutputME tMEHatch) {
+ if (!tMEHatch.canAcceptFluid()) continue;
+ }
+
int tAmount = tHatch.fill(copiedFluidStack, false);
if (tAmount >= copiedFluidStack.amount) {
boolean filled = tHatch.fill(copiedFluidStack, true) >= copiedFluidStack.amount;
@@ -2290,6 +2296,18 @@ public abstract class MTEMultiBlockBase extends MetaTileEntity
}
@Override
+ public boolean canDumpFluidToME() {
+ for (IFluidStore tHatch : getFluidOutputSlots(new FluidStack[0])) {
+ if (tHatch instanceof MTEHatchOutputME) {
+ if ((((MTEHatchOutputME) tHatch).canAcceptFluid())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
public Pos2d getVoidingModeButtonPos() {
return new Pos2d(8, 91);
}
diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java
index c0fb6cedb4..d6b4ef7fe3 100644
--- a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java
+++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java
@@ -915,6 +915,11 @@ public abstract class Controller<C extends Controller<C, P>, P extends MuTEProce
}
@Override
+ public boolean canDumpFluidToME() {
+ return false;
+ }
+
+ @Override
public boolean supportsInputSeparation() {
return true;
}
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);
diff --git a/src/main/java/gregtech/common/tileentities/machines/MTEHatchOutputME.java b/src/main/java/gregtech/common/tileentities/machines/MTEHatchOutputME.java
index b502ad54d3..7ddf136a72 100644
--- a/src/main/java/gregtech/common/tileentities/machines/MTEHatchOutputME.java
+++ b/src/main/java/gregtech/common/tileentities/machines/MTEHatchOutputME.java
@@ -161,16 +161,6 @@ public class MTEHatchOutputME extends MTEHatchOutput implements IPowerChannelSta
}
/**
- * Get the available fluid space, up to max int.
- */
- @Override
- public int getAvailableSpace() {
- long availableSpace = getCacheCapacity() - getCachedAmount();
- if (availableSpace > Integer.MAX_VALUE) availableSpace = Integer.MAX_VALUE;
- return (int) availableSpace;
- }
-
- /**
* Attempt to store fluid in connected ME network. Returns how much fluid is accepted (if the network was down e.g.)
*
* @param aFluid input fluid
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEDistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEDistillationTower.java
index bbba029449..93b64c16a8 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEDistillationTower.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEDistillationTower.java
@@ -47,6 +47,7 @@ import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.MultiblockTooltipBuilder;
+import gregtech.common.tileentities.machines.MTEHatchOutputME;
public class MTEDistillationTower extends MTEEnhancedMultiBlockBase<MTEDistillationTower>
implements ISurvivalConstructable {
@@ -293,6 +294,15 @@ public class MTEDistillationTower extends MTEEnhancedMultiBlockBase<MTEDistillat
}
@Override
+ public boolean canDumpFluidToME() {
+ // All fluids can be dumped to ME only if each layer contains a ME Output Hatch.
+ return this.mOutputHatchesByLayer.stream()
+ .allMatch(
+ tLayerOutputHatches -> tLayerOutputHatches.stream()
+ .anyMatch(tHatch -> (tHatch instanceof MTEHatchOutputME tMEHatch) && (tMEHatch.canAcceptFluid())));
+ }
+
+ @Override
public void construct(ItemStack stackSize, boolean hintsOnly) {
buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 1, 0, 0);
int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java
index 81a8c12573..46a8d8fe3d 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvDistillationTower.java
@@ -53,6 +53,7 @@ import gregtech.api.recipe.RecipeMaps;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.common.pollution.PollutionConfig;
+import gregtech.common.tileentities.machines.MTEHatchOutputME;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;
@@ -435,6 +436,15 @@ public class MTEAdvDistillationTower extends GTPPMultiBlockBase<MTEAdvDistillati
}
@Override
+ public boolean canDumpFluidToME() {
+ // All fluids can be dumped to ME only if each layer contains a ME Output Hatch.
+ return this.mOutputHatchesByLayer.stream()
+ .allMatch(
+ tLayerOutputHatches -> tLayerOutputHatches.stream()
+ .anyMatch(tHatch -> (tHatch instanceof MTEHatchOutputME tMEHatch) && (tMEHatch.canAcceptFluid())));
+ }
+
+ @Override
public void setItemNBT(NBTTagCompound aNBT) {
if (mUpgraded) aNBT.setBoolean("mUpgraded", true);
super.setItemNBT(aNBT);
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java
index 9e902d666a..5be5801097 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTENuclearReactor.java
@@ -47,7 +47,6 @@ import gregtech.api.util.GTRecipe;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.OverclockCalculator;
import gregtech.api.util.shutdown.ShutDownReasonRegistry;
-import gregtech.common.tileentities.machines.MTEHatchOutputME;
import gtPlusPlus.api.recipe.GTPPRecipeMaps;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.material.MaterialsElements;
@@ -260,8 +259,7 @@ public class MTENuclearReactor extends GTPPMultiBlockBase<MTENuclearReactor> imp
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
mCasing = 0;
if (checkPiece(mName, 3, 3, 0) && mCasing >= 27) {
- if ((mOutputHatches.size() >= 3 || mOutputHatches.stream()
- .anyMatch(h -> h instanceof MTEHatchOutputME)) && !mInputHatches.isEmpty()
+ if ((mOutputHatches.size() >= 3 || canDumpFluidToME()) && !mInputHatches.isEmpty()
&& mDynamoHatches.size() == 4
&& mMufflerHatches.size() == 4) {
this.turnCasingActive(false);