public void populate(Chunk chunk, Random random) {
if (chunk.getY() != 4) {
return;
}
final World world = chunk.getWorld();
final HugeMushroomObject mushroom;
if (random.nextBoolean()) {
mushroom = new HugeMushroomObject(HugeMushroomType.RED);
} else {
mushroom = new HugeMushroomObject(HugeMushroomType.BROWN);
}
mushroom.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);
mushroom.randomize();
if (y != -1 && mushroom.canPlaceObject(world, x, y, z)) {
mushroom.placeObject(world, x, y, z);
}
}
}