Flood Gate now shuts off on redstone signal
This commit is contained in:
parent
ddd2c0f3a1
commit
617d06c3b0
2 changed files with 24 additions and 0 deletions
|
@ -82,6 +82,15 @@ public class BlockFloodGate extends BlockContainer {
|
||||||
return false;
|
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"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
@Override
|
@Override
|
||||||
public void addCreativeItems(ArrayList itemList) {
|
public void addCreativeItems(ArrayList itemList) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
||||||
private final Tank tank;
|
private final Tank tank;
|
||||||
private int rebuildDelay;
|
private int rebuildDelay;
|
||||||
private int tick = Utils.RANDOM.nextInt();
|
private int tick = Utils.RANDOM.nextInt();
|
||||||
|
private boolean powered = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
REBUILD_DELAY[0] = 128;
|
REBUILD_DELAY[0] = 128;
|
||||||
|
@ -61,6 +62,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
||||||
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
if (CoreProxy.proxy.isRenderWorld(worldObj))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (powered)
|
||||||
|
return;
|
||||||
|
|
||||||
tick++;
|
tick++;
|
||||||
if (tick % 16 == 0) {
|
if (tick % 16 == 0) {
|
||||||
FluidStack fluidtoFill = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false);
|
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);
|
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
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound data) {
|
public void readFromNBT(NBTTagCompound data) {
|
||||||
super.readFromNBT(data);
|
super.readFromNBT(data);
|
||||||
tank.readFromNBT(data);
|
tank.readFromNBT(data);
|
||||||
rebuildDelay = data.getByte("rebuildDelay");
|
rebuildDelay = data.getByte("rebuildDelay");
|
||||||
|
powered = data.getBoolean("powered");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -191,6 +205,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
||||||
super.writeToNBT(data);
|
super.writeToNBT(data);
|
||||||
tank.writeToNBT(data);
|
tank.writeToNBT(data);
|
||||||
data.setByte("rebuildDelay", (byte) rebuildDelay);
|
data.setByte("rebuildDelay", (byte) rebuildDelay);
|
||||||
|
data.setBoolean("powered", powered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue