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

Solved $level->getEntites() returns nothing

Comments in 'Plugin Development' started by Samueljh1H8sLag, Dec 30, 2015.

  1. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Hi, I'm trying to remove all the entities in a world when the server starts. The level is correctly loaded, but when I try to do
    PHP:
    $level->getEntities()
    It just returns a blank array.

    Once a player has been in the map, the function works correctly. Do I need to load chunks? I've tried that but it failed too.
    Legoboy0215 likes this.
  2. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Solved, you gotta check for a specific chunk if it isn't loaded:
    PHP:
    $this->lobby->getChunk($x >> 4$z >> 4)->getEntities();
    Vaivez66 and Legoboy0215 like this.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    What is $x and $z? Player coords?
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $x and $z are sample coordinates inside the chunk. >> 4 deletes the last four bits, so it becomes like divided by four and then floored, which is the chunk number.
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Thaks!

Share This Page

Advertisement