}
@Override
public byte[] generate(World world, Random random, int chunkX, int chunkZ) {
Map<String, OctaveGenerator> octaves = getWorldOctaves(world);
OctaveGenerator noiseFloor = octaves.get("floor");
OctaveGenerator noiseCeiling = octaves.get("ceiling");
OctaveGenerator noiseJitter1 = octaves.get("jitter1");
OctaveGenerator noiseJitter2 = octaves.get("jitter2");
OctaveGenerator noiseStalactite = octaves.get("stalactite");
OctaveGenerator noiseStalagmite = octaves.get("stalagmite");
OctaveGenerator noisePlatform1 = octaves.get("platform1");
OctaveGenerator noisePlatform2 = octaves.get("platform2");
chunkX <<= 4;
chunkZ <<= 4;
Material stone = world.getEnvironment() == Environment.NETHER ? Material.NETHERRACK : Material.STONE;
int height = WORLD_DEPTH;
byte[] buf = start(stone);
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
int min = (int) (Math.abs(noiseFloor.noise(x + chunkX, z + chunkZ, 0.5, 0.5) * 3)
+ 5 + noiseJitter1.noise(x + chunkX, z + chunkZ, 0.5, 0.5) * 2
+ convertPointyThings(noiseStalagmite, x + chunkX, z + chunkZ, height));
int max = (int) (height - Math.abs(noiseCeiling.noise(x + chunkX, z + chunkZ, 0.5, 0.5) * 3)
- 5 + noiseJitter2.noise(x + chunkX, z + chunkZ, 0.5, 0.5) * 2 - random.nextInt(5)
- convertPointyThings(noiseStalactite, x + chunkX, z + chunkZ, height));
if (min > 20) {
min -= random.nextInt(5);
}
if (min >= max) {
set(buf, x, 0, z, Material.BEDROCK);
set(buf, x, height - 1, z, Material.BEDROCK);
continue;
}
for (int y = min; y <= max; y++) {
set(buf, x, y, z, Material.AIR);
}
int platform = (int) (noisePlatform1.noise(x + chunkX, z + chunkZ, 0.5, 0.5, true) * 20 - 4);
if (platform > 5) {
platform -= random.nextInt(3);
}
while (platform-- > 0) {
set(buf, x, height / 2 - platform - 1, z, stone);
}
platform = (int) (noisePlatform2.noise(x + chunkX, z + chunkZ, 0.5, 0.5, true) * 30 - 6);
if (platform > 5) {
platform -= random.nextInt(3);
}
while (platform-- > 0) {
set(buf, x, height / 4 - platform - 1, z, stone);