22declare(strict_types=1);
38 private array $populators = [];
46 parent::__construct($seed, $preset !==
"" ? $preset :
"2;bedrock,2xdirt,grass;1;");
49 if(isset($this->options->getExtraOptions()[
"decoration"])){
51 $stone = VanillaBlocks::STONE();
53 new OreType(VanillaBlocks::COAL_ORE(), $stone, 20, 16, 0, 128),
54 new OreType(VanillaBlocks::IRON_ORE(), $stone, 20, 8, 0, 64),
55 new OreType(VanillaBlocks::REDSTONE_ORE(), $stone, 8, 7, 0, 16),
56 new OreType(VanillaBlocks::LAPIS_LAZULI_ORE(), $stone, 1, 6, 0, 32),
57 new OreType(VanillaBlocks::GOLD_ORE(), $stone, 2, 8, 0, 32),
58 new OreType(VanillaBlocks::DIAMOND_ORE(), $stone, 1, 7, 0, 16),
59 new OreType(VanillaBlocks::DIRT(), $stone, 20, 32, 0, 128),
60 new OreType(VanillaBlocks::GRAVEL(), $stone, 10, 16, 0, 128)
62 $this->populators[] = $ores;
65 $this->generateBaseChunk();
68 protected function generateBaseChunk() : void{
69 $this->chunk = new
Chunk([], false);
71 $structure = $this->options->getStructure();
72 $count = count($structure);
73 for($sy = 0; $sy < $count; $sy += SubChunk::EDGE_LENGTH){
74 $subchunk = $this->chunk->getSubChunk($sy >> SubChunk::COORD_BIT_SIZE);
75 for($y = 0; $y < SubChunk::EDGE_LENGTH && isset($structure[$y | $sy]); ++$y){
76 $id = $structure[$y | $sy];
78 for($Z = 0; $Z < SubChunk::EDGE_LENGTH; ++$Z){
79 for($X = 0; $X < SubChunk::EDGE_LENGTH; ++$X){
80 $subchunk->setBlockStateId($X, $y, $Z, $id);
87 public function generateChunk(ChunkManager $world,
int $chunkX,
int $chunkZ) : void{
88 $world->setChunk($chunkX, $chunkZ, clone $this->chunk);
91 public function populateChunk(ChunkManager $world,
int $chunkX,
int $chunkZ) : void{
92 $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->seed);
93 foreach($this->populators as $populator){
94 $populator->populate($world, $chunkX, $chunkZ, $this->random);
static parsePreset(string $presetString)
__construct(int $seed, string $preset)