@Override public boolean canBlockStay(World world, int x, int y, int z) { if (world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) { return true; } for (ForgeDirection d : _attachDirections) { BlockPosition bp = new BlockPosition(x, y, z, d); for (int i = 0; i < _attachDistance; i++) { bp.moveForwards(1); if (world.getBlock(bp.x, bp.y, bp.z).equals(this)) { if (world.isSideSolid(bp.x, bp.y - 1, bp.z, ForgeDirection.UP)) { return true; } } else break; } } return false; }
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { if (!canBlockStay(world, x, y, z)) { for (int e = world.getActualHeight(); y < e; ++y) { block = world.getBlock(x, y, z); if (!block.equals(this)) break; dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); world.setBlock(x, y, z, Blocks.air, 0, 2); for (ForgeDirection d : _attachDirections) { BlockPosition bp = new BlockPosition(x, y, z, d); for (int i = 0; i < _attachDistance; i++) { bp.moveForwards(1); block = world.getBlock(bp.x, bp.y, bp.z); if (block.equals(this)) { world.func_147446_b(bp.x, bp.y, bp.z, block, 0, 0); } else break; } } } } }