Flood Gate now shuts off on redstone signal

This commit is contained in:
CovertJaguar 2013-07-31 15:42:00 -07:00
parent ddd2c0f3a1
commit 617d06c3b0
2 changed files with 24 additions and 0 deletions

View file

@ -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) {

View file

@ -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