tcr/java/src/game/worldgen/GeneratorDestroyed.java
2025-03-12 18:13:11 +01:00

38 lines
1.3 KiB
Java
Executable file

package game.worldgen;
import game.init.Blocks;
import game.rng.Random;
import game.world.State;
import game.world.WorldServer;
public class GeneratorDestroyed implements ChunkGenerator
{
private final State block = Blocks.coal_block.getState();
private final State alt = Blocks.soul_sand.getState();
private final State gap = Blocks.air.getState();
private final State liquid = Blocks.lava.getState();
private final State top = Blocks.obsidian.getState();
private final int height;
private final Random rand = new Random(); // NON-DETERMINISTIC!!
public GeneratorDestroyed(int height) {
this.height = height;
}
public int getMaximumHeight() {
return this.height;
}
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
{
for(int by = 0; by < this.height; ++by) {
for(int bx = 0; bx < 16; ++bx) {
for(int bz = 0; bz < 16; ++bz) {
primer.set(bx, by, bz, by >= this.height - this.rand.zrange(3) ? this.gap :
(by == this.height - 1 ? this.top : this.rand.chance(this.block, (by == this.height - 3 ?
this.liquid : this.alt), 15)));
}
}
}
}
}