*/
public class DungeonPopulator extends BlockPopulator {
@Override
public void populate(World world, Random random, Chunk source) {
SimplexNoiseGenerator noise = new SimplexNoiseGenerator(world);
ChunkSnapshot snapshot = source.getChunkSnapshot();
// Randomly turn exposed stone to treasure
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
int y = snapshot.getHighestBlockYAt(x, z);
Block block = source.getBlock(x, y - 1, z);
if (block.getType() == Material.STONE
&& random.nextInt(1024) == 0) {
placeChest(random, block);
}
}
}
// Go go dungeons
double density = noise.noise(source.getX(), source.getZ());
if (density > 0.8) {
int roomCount = (int) (density * 10) - 3;
for (int i = 0; i < roomCount; i++) {
if (random.nextBoolean()) {