From 617d06c3b067996a0907d03e1351d3baa63fde1a Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 31 Jul 2013 15:42:00 -0700 Subject: [PATCH] Flood Gate now shuts off on redstone signal --- common/buildcraft/factory/BlockFloodGate.java | 9 +++++++++ common/buildcraft/factory/TileFloodGate.java | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/common/buildcraft/factory/BlockFloodGate.java b/common/buildcraft/factory/BlockFloodGate.java index 5177ca8a..cd123bd4 100644 --- a/common/buildcraft/factory/BlockFloodGate.java +++ b/common/buildcraft/factory/BlockFloodGate.java @@ -82,6 +82,15 @@ public class BlockFloodGate extends BlockContainer { return false; } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { + super.onNeighborBlockChange(world, x, y, z, id); + TileEntity tile = world.getBlockTileEntity(x, y, z); + if (tile instanceof TileFloodGate) { + ((TileFloodGate) tile).onNeighborBlockChange(id); + } + } + @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void addCreativeItems(ArrayList itemList) { diff --git a/common/buildcraft/factory/TileFloodGate.java b/common/buildcraft/factory/TileFloodGate.java index 854be302..f9cd8223 100644 --- a/common/buildcraft/factory/TileFloodGate.java +++ b/common/buildcraft/factory/TileFloodGate.java @@ -38,6 +38,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { private final Tank tank; private int rebuildDelay; private int tick = Utils.RANDOM.nextInt(); + private boolean powered = false; static { REBUILD_DELAY[0] = 128; @@ -61,6 +62,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { if (CoreProxy.proxy.isRenderWorld(worldObj)) return; + if (powered) + return; + tick++; if (tick % 16 == 0) { FluidStack fluidtoFill = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false); @@ -179,11 +183,21 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { return BlockUtil.isSoftBlock(blockId, worldObj, x, y, z) && !BlockUtil.isFullFluidBlock(blockId, worldObj, x, y, z); } + public void onNeighborBlockChange(int id) { + boolean p = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); + if (powered != p) { + powered = p; + if (!p) + rebuildQueue(); + } + } + @Override public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); tank.readFromNBT(data); rebuildDelay = data.getByte("rebuildDelay"); + powered = data.getBoolean("powered"); } @Override @@ -191,6 +205,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { super.writeToNBT(data); tank.writeToNBT(data); data.setByte("rebuildDelay", (byte) rebuildDelay); + data.setBoolean("powered", powered); } @Override