aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java37
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) {