diff options
author | D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> | 2024-04-13 09:37:56 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 17:37:56 +0200 |
commit | c5fe120671d60206d811fc432ff2e144bf266cf7 (patch) | |
tree | 0542a05a13e0ac0e8012968944bb955b066e7e48 /src/main/java/gregtech/common | |
parent | cb72bf38931af5efeb86b1ba546192fc8e3caa8f (diff) | |
download | GT5-Unofficial-c5fe120671d60206d811fc432ff2e144bf266cf7.tar.gz GT5-Unofficial-c5fe120671d60206d811fc432ff2e144bf266cf7.tar.bz2 GT5-Unofficial-c5fe120671d60206d811fc432ff2e144bf266cf7.zip |
Allow single-block pump to ignore replaceable blocks, and water (#2568)
* Allow single-block pump to ignore fire
* Use `isReplaceable` and replace water
* Update comments
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java index 58e8be1c6f..8cac0c3df7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java @@ -530,11 +530,15 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_BasicMachine { int x = getBaseMetaTileEntity().getXCoord(), z = getBaseMetaTileEntity().getZCoord(); - if ((!consumeFluid(x, yHead - 1, z)) && (!getBaseMetaTileEntity().getBlock(x, yHead - 1, z) - .isAir(getBaseMetaTileEntity().getWorld(), x, yHead - 1, z))) { - // Either we didn't consume a fluid, or it's a non Air block + Block aBlock = getBaseMetaTileEntity().getBlock(x, yHead - 1, z); + boolean canReplaceBlock = aBlock.isReplaceable(getBaseMetaTileEntity().getWorld(), x, yHead - 1, z); + + // We specifically allow replacing water even if we can't consume it + // (e.g. pump holds a different fluid) to help avoid getting stuck on random water pockets. + if (!canReplaceBlock || (isFluid(aBlock) && !consumeFluid(x, yHead - 1, z) && !isWater(aBlock))) { + // Either we didn't consume a fluid, or it's a non-replaceable block, or it's water. if (debugBlockPump) { - GT_Log.out.println("PUMP: Did not consume fluid, or non-airblock found"); + GT_Log.out.println("PUMP: Did not consume fluid, or non-replaceable block found"); } return false; } @@ -700,12 +704,12 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_BasicMachine { Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); if (aBlock != null) { - if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) { + if (isWater(aBlock)) { this.mPrimaryPumpedBlock = Blocks.water; this.mSecondaryPumpedBlock = Blocks.flowing_water; return; } - if ((aBlock == Blocks.lava) || (aBlock == Blocks.flowing_lava)) { + if (isLava(aBlock)) { this.mPrimaryPumpedBlock = Blocks.lava; this.mSecondaryPumpedBlock = Blocks.flowing_lava; return; @@ -726,11 +730,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_BasicMachine { Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); - return aBlock != null && (aBlock == Blocks.water || aBlock == Blocks.flowing_water - || aBlock == Blocks.lava - || aBlock == Blocks.flowing_lava - || aBlock instanceof IFluidBlock - || aBlock.isAir(getBaseMetaTileEntity().getWorld(), aX, aY, aZ)); + return aBlock != null && aBlock.isReplaceable(getBaseMetaTileEntity().getWorld(), aX, aY, aZ); } private boolean consumeFluid(int aX, int aY, int aZ) { @@ -739,6 +739,9 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_BasicMachine { if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), aX, aY, aZ, true)) return false; Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); + if (!isFluid(aBlock)) { + return false; + } if (aBlock != null && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) { boolean isWaterOrLava = ((this.mPrimaryPumpedBlock == Blocks.water @@ -788,6 +791,18 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_BasicMachine { return false; } + private static boolean isWater(Block aBlock) { + return aBlock == Blocks.water || aBlock == Blocks.flowing_water; + } + + private static boolean isLava(Block aBlock) { + return aBlock == Blocks.lava || aBlock == Blocks.flowing_lava; + } + + private static boolean isFluid(Block aBlock) { + return isWater(aBlock) || isLava(aBlock) || aBlock instanceof IFluidBlock; + } + @Override public ArrayList<String> getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) { |