@Override public void onBlockAdded(World par1World, int x, int y, int z) { super.onBlockAdded(par1World, x, y, z); for (byte i = 0; i < 6; i++) { Vector3 neighborPosition = new Vector3(x, y, z); neighborPosition.modifyPositionFromSide(ForgeDirection.getOrientation(i)); int neighborBlockID = par1World.getBlockId( neighborPosition.intX(), neighborPosition.intY(), neighborPosition.intZ()); if (neighborBlockID == Block.fire.blockID || neighborBlockID == Block.lavaMoving.blockID || neighborBlockID == Block.lavaStill.blockID) { par1World.setBlockWithNotify(x, y, z, Block.fire.blockID); par1World.playSoundEffect( (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F); par1World.spawnParticle( "largesmoke", (double) x + Math.random(), (double) y + 1.2D, (double) z + Math.random(), 0.0D, 0.0D, 0.0D); return; } } }
/** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed * (coordinates passed are their own) Args: x, y, z, neighbor blockID */ @Override public void onNeighborBlockChange(World par1World, int x, int y, int z, int neighborBlockID) { super.onNeighborBlockChange(par1World, x, y, z, neighborBlockID); if (par1World.getBlockId(x, y, z) == this.blockID) { this.setNotStationary(par1World, x, y, z); } else if (neighborBlockID == Block.fire.blockID || neighborBlockID == Block.lavaMoving.blockID || neighborBlockID == Block.lavaStill.blockID) { par1World.setBlockWithNotify(x, y, z, Block.fire.blockID); par1World.playSoundEffect( (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F); par1World.spawnParticle( "largesmoke", (double) x + Math.random(), (double) y + 1.2D, (double) z + Math.random(), 0.0D, 0.0D, 0.0D); } }
@Override public void updateTick(World world, int x, int y, int z, Random random) { if (!world.isRemote) { Aurus.bogWaterUpdates++; boolean airAround = false; boolean waterNearby = false; boolean changedToWater = false; if (((x + 2 * z) % 5 == 0 && world.isAirBlock(x, y + 1, z)) || world.getClosestPlayer(x, y, z, 64) != null) { super.updateTick(world, x, y, z, random); int chance = 50; if (world.getBlockId(x - 1, y, z) == Block.waterMoving.blockID || world.getBlockId(x - 1, y, z) == Block.waterStill.blockID) { if (random.nextInt(100) < chance) { world.setBlock(x, y, z, Block.waterMoving.blockID, world.getBlockMetadata(x, y, z), 3); changedToWater = true; } else { int b = world.getBlockMetadata(x - 1, y, z); world.setBlock(x - 1, y, z, Aurus.bogWaterFlowingID, b, 3); } waterNearby = true; } if (world.getBlockId(x + 1, y, z) == Block.waterMoving.blockID || world.getBlockId(x + 1, y, z) == Block.waterStill.blockID) { if (random.nextInt(100) < chance) { world.setBlock(x, y, z, Block.waterMoving.blockID, world.getBlockMetadata(x, y, z), 3); changedToWater = true; } else { int b = world.getBlockMetadata(x + 1, y, z); world.setBlock(x + 1, y, z, Aurus.bogWaterFlowingID, b, 3); } waterNearby = true; } if (world.getBlockId(x, y - 1, z) == Block.waterMoving.blockID || world.getBlockId(x, y - 1, z) == Block.waterStill.blockID) { if (random.nextInt(100) < 1) { world.setBlock(x, y, z, Block.waterMoving.blockID, world.getBlockMetadata(x, y, z), 3); changedToWater = true; } else { int b = world.getBlockMetadata(x, y - 1, z); world.setBlock(x, y - 1, z, Aurus.bogWaterFlowingID, b, 3); } waterNearby = true; } if (world.getBlockId(x, y + 1, z) == Block.waterMoving.blockID || world.getBlockId(x, y + 1, z) == Block.waterStill.blockID) { if (random.nextInt(100) < 99) { world.setBlock(x, y, z, Block.waterMoving.blockID, world.getBlockMetadata(x, y, z), 3); changedToWater = true; } else { int b = world.getBlockMetadata(x, y + 1, z); world.setBlock(x, y + 1, z, Aurus.bogWaterFlowingID, b, 3); } waterNearby = true; } if (world.getBlockId(x, y, z - 1) == Block.waterMoving.blockID || world.getBlockId(x, y, z - 1) == Block.waterStill.blockID) { if (random.nextInt(100) < chance) { world.setBlock(x, y, z, Block.waterMoving.blockID, world.getBlockMetadata(x, y, z), 3); changedToWater = true; } else { int b = world.getBlockMetadata(x, y, z - 1); world.setBlock(x, y, z - 1, Aurus.bogWaterFlowingID, b, 3); } waterNearby = true; } if (world.getBlockId(x, y, z + 1) == Block.waterMoving.blockID || world.getBlockId(x, y, z + 1) == Block.waterStill.blockID) { if (random.nextInt(100) < chance) { world.setBlock(x, y, z, Block.waterMoving.blockID, world.getBlockMetadata(x, y, z), 3); changedToWater = true; } else { int b = world.getBlockMetadata(x, y, z + 1); world.setBlock(x, y, z + 1, Aurus.bogWaterFlowingID, b, 3); } waterNearby = true; } if (random.nextInt(5) == 0) { if (world.isAirBlock(x, y + 1, z)) world.setBlock(x, y + 1, z, Aurus.bogGasID); if (world.isAirBlock(x - 1, y + 1, z)) world.setBlock(x - 1, y + 1, z, Aurus.bogGasID); if (world.isAirBlock(x + 1, y + 1, z)) world.setBlock(x + 1, y + 1, z, Aurus.bogGasID); if (world.isAirBlock(x, y + 1, z - 1)) world.setBlock(x, y + 1, z - 1, Aurus.bogGasID); if (world.isAirBlock(x, y + 1, z + 1)) { world.setBlock(x, y + 1, z + 1, Aurus.bogGasID); } } if (world.isAirBlock(x - 1, y, z) || world.isAirBlock(x + 1, y, z) || world.isAirBlock(x, y, z - 1) || world.isAirBlock(x, y, z + 1)) { airAround = true; } if (airAround) { return; } else if ((waterNearby && !changedToWater) || ((x + 2 * z) % 5 == 0 && world.isAirBlock(x, y + 1, z))) { world.scheduleBlockUpdate(x, y, z, Aurus.bogWaterFlowingID, 200); } else { world.scheduleBlockUpdate(x, y, z, Aurus.bogWaterFlowingID, 600); } } } }