diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2021-02-25 05:30:25 +0800 |
---|---|---|
committer | Glease <4586901+Glease@users.noreply.github.com> | 2021-02-25 05:31:19 +0800 |
commit | 50b05babb741306c1f14ac59b63b7b97b9f8a976 (patch) | |
tree | fa7f6f5743ac821a2a542ae0d822622bf7bd3e40 | |
parent | 3fa7666b23d3761f2157c0190aa86d00eb676557 (diff) | |
download | GT5-Unofficial-50b05babb741306c1f14ac59b63b7b97b9f8a976.tar.gz GT5-Unofficial-50b05babb741306c1f14ac59b63b7b97b9f8a976.tar.bz2 GT5-Unofficial-50b05babb741306c1f14ac59b63b7b97b9f8a976.zip |
Prevent retract pipe when drill tip can move down
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java | 28 |
1 files changed, 25 insertions, 3 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 0eb4092e26..52a256f5a3 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 @@ -215,9 +215,16 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { if (!this.wasPumping) { tMovedOneDown = moveOneDown(); if (!tMovedOneDown) { - getBaseMetaTileEntity().disableWorking(); - if (debugBlockPump) { - GT_Log.out.println("PUMP: Can't move. Retracting in next few ticks"); + if (canMoveDown(getBaseMetaTileEntity().getXCoord(), Math.max(getYOfPumpHead() - 1, 1), getBaseMetaTileEntity().getZCoord())) { + if (debugBlockPump) { + GT_Log.out.println("PUMP: No pipe left. Idle for a little longer."); + } + this.mPumpTimer = 160; + } else { + getBaseMetaTileEntity().disableWorking(); + if (debugBlockPump) { + GT_Log.out.println("PUMP: Can't move. Retracting in next few ticks"); + } } } else if (debugBlockPump) { GT_Log.out.println("PUMP: Moved down"); @@ -530,6 +537,21 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { this.mSecondaryPumpedBlock = null; } + /** only check if block below can be replaced with pipe tip. pipe stockpile condition is ignored */ + private boolean canMoveDown(int aX, int aY, int aZ) { + if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), aX, aY, aZ, true)) return false; + + Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ); + + return GT_Utility.isBlockValid(aBlock) && + (aBlock == Blocks.water || + aBlock == Blocks.flowing_water || + aBlock == Blocks.lava || + aBlock == Blocks.flowing_lava || + aBlock instanceof IFluidBlock || + aBlock.isAir(getBaseMetaTileEntity().getWorld(), aX, aY, aZ)); + } + private boolean consumeFluid(int aX, int aY, int aZ) { // Try to consume a fluid at a location // Returns true if something was consumed, otherwise false |