public void populate(Chunk chunk, Random random) {
if (chunk.getY() != 4) {
return;
}
final World world = chunk.getWorld();
final CactusStackObject cactus = new CactusStackObject();
cactus.setRandom(random);
final int amount = getAmount(random);
for (byte count = 0; count < amount; count++) {
final int x = chunk.getBlockX(random);
final int z = chunk.getBlockZ(random);
final int y = getHighestWorkableBlock(world, x, z);
cactus.randomize();
if (y != -1 && cactus.canPlaceObject(world, x, y, z)) {
cactus.placeObject(world, x, y, z);
}
}
}