I want to load chunks only 40 blocks around of my spawn because when pmmp load more chunks I get structures like this in my void world: Spoiler ChunkLoadEvent is not cancellable and also it has only isNewChunk function, so how I do it then? I don't have any tries to do it at all..
I've tried this, but don't work PHP: public function onChunkLoad(\pocketmine\event\level\ChunkLoadEvent $e){ $chunk = $e->getChunk(); if($e->getChunk()->getZ() > 150){ echo 'UNLOADING CHUNK'; $chunk->unload(false, false); } }
Unloading chunks from inside the chunk does not unload them from the level, just like unloading a level from inside the level does not unload the level from the server. To fix this, try instead to unload the chunk from the level: https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/level/Level.php#L2545