42 private int $waterHeight = 32;
43 private int $emptyHeight = 64;
44 private int $emptyAmplitude = 1;
45 private float $density = 0.5;
48 private array $populators = [];
50 private array $generationPopulators = [];
57 parent::__construct($seed, $preset);
59 $this->noiseBase =
new Simplex($this->random, 4, 1 / 4, 1 / 64);
60 $this->random->setSeed($this->seed);
64 new OreType(VanillaBlocks::NETHER_QUARTZ_ORE(), VanillaBlocks::NETHERRACK(), 16, 14, 10, 117)
66 $this->populators[] = $ores;
69 public function generateChunk(
ChunkManager $world,
int $chunkX,
int $chunkZ) : void{
70 $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->seed);
72 $noise = $this->noiseBase->getFastNoise3D(Chunk::EDGE_LENGTH, 128, Chunk::EDGE_LENGTH, 4, 8, 4, $chunkX * Chunk::EDGE_LENGTH, 0, $chunkZ * Chunk::EDGE_LENGTH);
75 $chunk = $world->getChunk($chunkX, $chunkZ) ??
throw new \InvalidArgumentException(
"Chunk $chunkX $chunkZ does not yet exist");
77 $bedrock = VanillaBlocks::BEDROCK()->getStateId();
78 $netherrack = VanillaBlocks::NETHERRACK()->getStateId();
79 $stillLava = VanillaBlocks::LAVA()->getStateId();
81 for($x = 0; $x < Chunk::EDGE_LENGTH; ++$x){
82 for($z = 0; $z < Chunk::EDGE_LENGTH; ++$z){
83 for($y = World::Y_MIN; $y < World::Y_MAX; $y++){
84 $chunk->setBiomeId($x, $y, $z, BiomeIds::HELL);
87 for($y = 0; $y < 128; ++$y){
88 if($y === 0 || $y === 127){
89 $chunk->setBlockStateId($x, $y, $z, $bedrock);
92 $noiseValue = (abs($this->emptyHeight - $y) / $this->emptyHeight) * $this->emptyAmplitude - $noise[$x][$z][$y];
93 $noiseValue -= 1 - $this->density;
96 $chunk->setBlockStateId($x, $y, $z, $netherrack);
97 }elseif($y <= $this->waterHeight){
98 $chunk->setBlockStateId($x, $y, $z, $stillLava);
104 foreach($this->generationPopulators as $populator){
105 $populator->populate($world, $chunkX, $chunkZ, $this->random);
109 public function populateChunk(ChunkManager $world,
int $chunkX,
int $chunkZ) : void{
110 $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->seed);
111 foreach($this->populators as $populator){
112 $populator->populate($world, $chunkX, $chunkZ, $this->random);
115 $chunk = $world->getChunk($chunkX, $chunkZ);
116 $biome = BiomeRegistry::getInstance()->getBiome($chunk->getBiomeId(7, 7, 7));
117 $biome->populateChunk($world, $chunkX, $chunkZ, $this->random);