Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Load Chunks?

Comments in 'Plugin Development' started by Legoboy0215, Jun 27, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    How do I load chunks from a world I specified in my config?
    I just randomly tried this but is this right?
    PHP:
            $lvl$this->getServer()->getLevelByName($this->config->get("world-name"));
            
    $lvl->loadChunks();
            foreach(
    $lvl->getTiles() as $tiles){ //Blah Blah here
    It will answer something on null...
    If not, what is the right code?
    Last edited: Jun 27, 2015
  2. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    if the the error is " call to loadChunks() on null " the level is null
    try to read that thread : https://forums.pocketmine.net/threa...ject-knowing-only-the-name-of-the-world.9280/
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PocketMine doesn't let you load all chunks in once, and you shouldn't do so.

    And loadChunks method does NOT exist in Level.

    You should process the tiles when a chunk is loaded.

    PHP:
    public function onLoadChunk(ChunkLoadEvent $event){
      
    $chunk $event->getChunk();
      if(
    $chunk->getLevel()->getName()  === $this->getConfig()->get("world-name")){
        
    $tiles $chunk->getTiles();
        foreach(
    $tiles as $tile){
          
    // manage tiles
        
    }
      }
    }
    Svile and Legoboy0215 like this.
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    But my code is in another function...public function refillChest
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then only refill the chests that are in loaded chunks.
  6. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    you can load chunks using :
    PHP:
    $level->loadChunk x);
    PEMapModder likes this.
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    what is x z.. Is it the mcr files?
  8. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    the x and z are the coordinates

Share This Page

Advertisement