38 public function populate(
ChunkManager $world,
int $chunkX,
int $chunkZ,
Random $random) :
void{
39 $chunk = $world->getChunk($chunkX, $chunkZ) ??
throw new \InvalidArgumentException(
"Chunk $chunkX $chunkZ does not yet exist");
40 $factory = RuntimeBlockStateRegistry::getInstance();
41 $biomeRegistry = BiomeRegistry::getInstance();
42 for($x = 0; $x < Chunk::EDGE_LENGTH; ++$x){
43 for($z = 0; $z < Chunk::EDGE_LENGTH; ++$z){
44 $biome = $biomeRegistry->getBiome($chunk->getBiomeId($x, 0, $z));
45 $cover = $biome->getGroundCover();
46 if(count($cover) > 0){
48 if(!$cover[0]->isSolid()){
53 for(; $startY > 0; --$startY){
54 if(!$factory->fromStateId($chunk->getBlockStateId($x, $startY, $z))->isTransparent()){
58 $startY = min(127, $startY + $diffY);
59 $endY = $startY - count($cover);
60 for($y = $startY; $y > $endY && $y >= 0; --$y){
61 $b = $cover[$startY - $y];
62 $id = $factory->fromStateId($chunk->getBlockStateId($x, $y, $z));
63 if($id->getTypeId() === BlockTypeIds::AIR && $b->isSolid()){
66 if($b->canBeFlowedInto() && $id instanceof
Liquid){
70 $chunk->setBlockStateId($x, $y, $z, $b->getStateId());