This commit is contained in:
Adrian Siekierka 2014-11-11 11:56:09 +01:00
parent b93b1d0d1a
commit 02839ee47a

View file

@ -121,27 +121,29 @@ public class PipeTransportPower extends PipeTransport {
@Override
public void onNeighborBlockChange(int blockId) {
super.onNeighborBlockChange(blockId);
updateTiles();
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
updateTile(side);
}
}
private void updateTiles() {
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = container.getTile(side);
if (container.isPipeConnected(side)) {
tiles[side.ordinal()] = tile;
} else {
tiles[side.ordinal()] = null;
internalPower[side.ordinal()] = 0;
internalNextPower[side.ordinal()] = 0;
displayPower[side.ordinal()] = 0;
}
}
}
private void updateTile(ForgeDirection side) {
TileEntity tile = container.getTile(side);
if (tile != null && container.isPipeConnected(side)) {
tiles[side.ordinal()] = tile;
} else {
tiles[side.ordinal()] = null;
internalPower[side.ordinal()] = 0;
internalNextPower[side.ordinal()] = 0;
displayPower[side.ordinal()] = 0;
}
}
private void init() {
if (needsInit) {
needsInit = false;
updateTiles();
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
updateTile(side);
}
}
}
@ -162,6 +164,12 @@ public class PipeTransportPower extends PipeTransport {
init();
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
if (tiles[side.ordinal()].isInvalid()) {
updateTile(side);
}
}
// Send the power to nearby pipes who requested it
System.arraycopy(displayPower, 0, prevDisplayPower, 0, 6);