1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Load only chunks around spawn

Discussion in 'Development' started by Kyd, Dec 31, 2017.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    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:
    upload_2017-12-31_13-12-58.png
    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..
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    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(falsefalse);
            }
           
      }
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You must be using a custom world generator?
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    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
     
    Kyd likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.