aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2023-05-26 21:09:03 +0900
committerGitHub <noreply@github.com>2023-05-26 14:09:03 +0200
commitd0e291fa8cb31cedcf9ef8fbafb536f19b216907 (patch)
tree2e7474220b3f7cbeeb9db8717f010786397934e9 /src/main/java/gregtech/api/metatileentity
parent497080d591db8af491ece783bf9a480b50a7c16b (diff)
downloadGT5-Unofficial-d0e291fa8cb31cedcf9ef8fbafb536f19b216907.tar.gz
GT5-Unofficial-d0e291fa8cb31cedcf9ef8fbafb536f19b216907.tar.bz2
GT5-Unofficial-d0e291fa8cb31cedcf9ef8fbafb536f19b216907.zip
Add void protection mode to fluid and ore drillers (#2023)
* Refactor GT_ParallelHelper part 1 * Refactor GT_ParallelHelper part 2 * Move void protection logic to separated class * Clean doc * Fix inverted logic in VoidProtectionHelper * Add void protection mode to fluid and ore drillers
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index 94392d089c..7eacf05b4e 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -9,6 +9,8 @@ import static mcp.mobius.waila.api.SpecialChars.RESET;
import java.util.ArrayList;
import java.util.List;
+import javax.annotation.Nullable;
+
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -120,6 +122,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
.get(ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorLow", 5);
this.damageFactorHigh = (float) GregTech_API.sMachineFile
.get(ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorHigh", 0.6f);
+ voidExcess = !isVoidExcessButtonEnabled();
}
public static boolean isValidMetaTileEntity(MetaTileEntity aMetaTileEntity) {
@@ -933,12 +936,19 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
}
public boolean depleteInput(FluidStack aLiquid) {
+ return depleteInput(aLiquid, false);
+ }
+
+ public boolean depleteInput(FluidStack aLiquid, boolean simulate) {
if (aLiquid == null) return false;
for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
tHatch.mRecipeMap = getRecipeMap();
if (isValidMetaTileEntity(tHatch)) {
FluidStack tLiquid = tHatch.drain(ForgeDirection.UNKNOWN, aLiquid, false);
if (tLiquid != null && tLiquid.amount >= aLiquid.amount) {
+ if (simulate) {
+ return true;
+ }
tLiquid = tHatch.drain(ForgeDirection.UNKNOWN, aLiquid, true);
return tLiquid != null && tLiquid.amount >= aLiquid.amount;
}
@@ -1512,6 +1522,38 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
return true;
}
+ /**
+ * Checks if items can fit in the output buses. If your outputs come from GT_Recipe,
+ * {@link GT_ParallelHelper} will work better.
+ */
+ protected boolean canFitOutput(ItemStack[] items) {
+ return canFitOutput(items, null);
+ }
+
+ /**
+ * Checks if fluids can fit in the output hatches. If your outputs come from GT_Recipe,
+ * {@link GT_ParallelHelper} will work better.
+ */
+ protected boolean canFitOutput(FluidStack[] fluids) {
+ return canFitOutput(null, fluids);
+ }
+
+ /**
+ * Checks if items / fluids can fit in the output buses / hatches. If your outputs come from GT_Recipe,
+ * {@link GT_ParallelHelper} will work better.
+ */
+ protected boolean canFitOutput(@Nullable ItemStack[] items, @Nullable FluidStack[] fluids) {
+ VoidProtectionHelper voidProtectionHelper = new VoidProtectionHelper().setController(this);
+ if (items != null) {
+ voidProtectionHelper.setItemOutputs(items);
+ }
+ if (fluids != null) {
+ voidProtectionHelper.setFluidOutputs(fluids);
+ }
+ voidProtectionHelper.build();
+ return voidProtectionHelper.getMaxParallel() > 0;
+ }
+
@Override
public boolean useModularUI() {
return true;