Hi All, I'm looking on how, when using a Generator (inside generateChunk), i can do to write 'correctly' in another chunk. Basicaly, Generator is like : PHP: public function generateChunk(int $chunkX, int $chunkZ): void { $this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed()); /** @phpstan-var Chunk $chunk */ $chunk = $this->level->getChunk($chunkX, $chunkZ); When i try to do as below, it return NULL PHP: //level = ChunkManager//$this->level->getChunk($x,$z) If i try to do getBlockId() on the current chuck, to get data outside the chunk, it return 0. If i want to create a large structure, hole, bridge ... I'm not able to check if there is block. I've tried to set blocks, but some other 'rendering chunks' seems to override the data : I've tried to check in generator if the current chunk contain data before adding block, with something like PHP: if($chunk->getBlockId($x, $y, $z) != 0) continue; It do not work, like it do not 'see' the block populated by the other thread. https://github.com/CzechPMDevs/Mult...rld/generator/normal/NormalGenerator.php#L176 Questions : # How i can avoid my corridor to be overrided ? (See image upper) # Is there a way to render the chuck before populating it ? (To be able to check block ID inside it) # Could it be done using the "ChunkPopulateEvent" ? Source of Generator : https://github.com/CzechPMDevs/Mult...ltiworld/generator/normal/NormalGenerator.php Source of Populator : https://github.com/Ad5001/BetterGen...01/BetterGen/populator/MineshaftPopulator.php Thanks, and correct me if i'm wrong
I don't think i could be possible because make running the populator at the end of the chuck generation won't make it able to have information on ungenerated chuck. (Could be possible if it was able to ask or launch this generation, and wait it) World Gereration could be initiated one time per world and (I think) generateChunk is called Async and multiples times simultaneously. Extract of 'pocketmine.yml' config file : Code: chunk-generation: #Max. amount of chunks in the waiting queue to be populated population-queue-size: 32 I don't know how one thread can write in other chunks (see previous screenshot) but it seems to do it How i can do to prevent currently running, or next thread to not replace block already placed Ex: if one thread write an other chunk, and if it know a block is already populated: do not touch it. But as air is 0 and ungenerated chuck return 0 too when using getBlockId() if not existing yet .... Could be possible if it was returning NULL instead See: https://github.com/pmmp/PocketMine-...c/pocketmine/level/SimpleChunkManager.php#L53 If i'm wrong somewhere please tell me.
I once was planning to implement mineshafts myself, didn't get to it. I did however implement something else you might find useful: https://github.com/BlockHorizons/BlockGenerator I would be more than happy to help you with this, however, I no longer develop such things and I might misguide. You might have a better chance if you asked in the discord server.
Thanks for the answer, i've already tried in Discord I've found interesting things in your previous link in ravine populator, for the chunk management, but it is disabled. Do you know why ? [EDIT] First investigation show that Init() in generator is called : - 6 times when level is created - 6 times too when loaded and chunk not existing generated manually - 6 times when player TP into the world unloaded [EDIT2] Each Generation initiated are used to generate chunk. So i'm thinking that each generator can generate a set of chunks, and maybe be able to write more in these chunks.