@Override
public final void updateEntity(World world, int x, int y, int z, int meta) {
this.getLiq(world, x, y, z, meta);
if (this.canPerformEffects()) {
this.performEffects(world, x, y, z);
soundTimer.update();
if (soundTimer.checkCap()) {
SoundRegistry.SPRINKLER.playSoundAtBlock(world, x, y, z, 1, 1);
}
liquid -= this.getWaterConsumption();
}
}
private void getLiq(World world, int x, int y, int z, int metadata) {
int oldLevel = 0;
ForgeDirection dir = this.getPipeDirection();
int dx = x+dir.offsetX;
int dy = y+dir.offsetY;
int dz = z+dir.offsetZ;
if (MachineRegistry.getMachine(world, dx, dy, dz) == MachineRegistry.PIPE) {
TileEntityPipe tile = (TileEntityPipe)world.getBlockTileEntity(dx, dy, dz);
if (tile != null && tile.contains(FluidRegistry.WATER) && tile.getFluidLevel() > 0) {
if (liquid < this.getCapacity()) {
oldLevel = tile.getFluidLevel();
int toremove = tile.getFluidLevel()/4+1;
tile.removeLiquid(toremove);
liquid = ReikaMathLibrary.extrema(liquid+oldLevel/4+1, 0, "max");
}
pressure = tile.getPressure();
}
}
if (liquid > this.getCapacity())
liquid = this.getCapacity();
}