aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech
diff options
context:
space:
mode:
authorreobf <117543727+reobf@users.noreply.github.com>2024-09-26 23:20:46 +0800
committerGitHub <noreply@github.com>2024-09-26 15:20:46 +0000
commit302a698ae45397a4ccbe7e844e6f523c62b9f6c0 (patch)
treea6e4ddfb772f14837478943e1c36ba786811480b /src/main/java/gtPlusPlus/xmod/gregtech
parent05f8dd49f6117444ecd09679d278c2b37d22102a (diff)
downloadGT5-Unofficial-302a698ae45397a4ccbe7e844e6f523c62b9f6c0.tar.gz
GT5-Unofficial-302a698ae45397a4ccbe7e844e6f523c62b9f6c0.tar.bz2
GT5-Unofficial-302a698ae45397a4ccbe7e844e6f523c62b9f6c0.zip
Fix Heat Exchanger interaction with Stocking Input Hatch(ME) (#3271)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java
index 0779c03183..5ebf5d1659 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/MTEAdvHeatExchanger.java
@@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
+import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -35,6 +36,8 @@ import gregtech.api.util.GTLog;
import gregtech.api.util.GTModHandler;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
+import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch;
+import gregtech.common.tileentities.machines.MTEHatchInputME;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.block.base.BasicBlock.BlockTypes;
import gtPlusPlus.core.block.base.BlockBaseModular;
@@ -168,9 +171,18 @@ public class MTEAdvHeatExchanger extends GTPPMultiBlockBase<MTEAdvHeatExchanger>
@Override
public @NotNull CheckRecipeResult checkProcessing() {
- if (mInputHotFluidHatch.getFluid() == null) return CheckRecipeResultRegistry.SUCCESSFUL;
+ FluidStack hotFluid = null;
+ if (mInputHotFluidHatch instanceof MTEHatchInputME inputME) {
+ FluidStack[] fluids = inputME.getStoredFluids();
+ if (fluids.length > 0) {
+ hotFluid = fluids[0];
+ }
+ } else {
+ hotFluid = mInputHotFluidHatch.getFluid();
+ }
+ if (hotFluid == null) return CheckRecipeResultRegistry.SUCCESSFUL;
- int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch
+ int fluidAmountToConsume = hotFluid.amount; // how much fluid is in hatch
// The XL LHE works as fast as 32 regular LHEs. These are the comments from the original LHE,
// with changes where the values needed to change for the 32x speed multiplier
@@ -193,9 +205,7 @@ public class MTEAdvHeatExchanger extends GTPPMultiBlockBase<MTEAdvHeatExchanger>
efficiency -= penalty;
- var coolant = LHECoolantRegistry.getCoolant(
- mInputHotFluidHatch.getFluid()
- .getFluid());
+ var coolant = LHECoolantRegistry.getCoolant(hotFluid.getFluid());
if (coolant == null) {
superheated_threshold = 0;
@@ -210,8 +220,9 @@ public class MTEAdvHeatExchanger extends GTPPMultiBlockBase<MTEAdvHeatExchanger>
// Don't consume too much hot fluid per second, maximum is 2x SH threshold.
fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2);
-
- mInputHotFluidHatch.drain(fluidAmountToConsume, true);
+ // the 3-arg drain will work on both normal hatch and ME hatch
+ mInputHotFluidHatch
+ .drain(ForgeDirection.UNKNOWN, new FluidStack(hotFluid.getFluid(), fluidAmountToConsume), true);
mOutputColdFluidHatch.fill(coolant.getColdFluid(fluidAmountToConsume), true);
this.mMaxProgresstime = 20;
@@ -242,6 +253,7 @@ public class MTEAdvHeatExchanger extends GTPPMultiBlockBase<MTEAdvHeatExchanger>
// 1:160 ratio with distilled water consumption
FluidStack distilledStack = GTModHandler.getDistilledWater(distilledConsumed);
+ startRecipeProcessing();
if (depleteInput(distilledStack)) // Consume the distilled water
{
if (superheated) {
@@ -255,6 +267,7 @@ public class MTEAdvHeatExchanger extends GTPPMultiBlockBase<MTEAdvHeatExchanger>
GTLog.exp.println(this.mName + " had no more Distilled water!");
explodeMultiblock(); // Generate crater
}
+ endRecipeProcessing();
}
return true;
}
@@ -393,4 +406,20 @@ public class MTEAdvHeatExchanger extends GTPPMultiBlockBase<MTEAdvHeatExchanger>
}
return sFrame;
}
+
+ @Override
+ public void startRecipeProcessing() {
+ super.startRecipeProcessing();
+ if (mInputHotFluidHatch instanceof IRecipeProcessingAwareHatch aware && mInputHotFluidHatch.isValid()) {
+ aware.startRecipeProcessing();
+ }
+ }
+
+ @Override
+ public void endRecipeProcessing() {
+ super.endRecipeProcessing();
+ if (mInputHotFluidHatch instanceof IRecipeProcessingAwareHatch aware && mInputHotFluidHatch.isValid()) {
+ aware.endRecipeProcessing(this);
+ }
+ }
}