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

Chunks

Discussion in 'Development' started by LucGamesDE, Mar 14, 2017.

  1. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    I tried to get the chunk where a player is. But it isn't working. I think they changed something with the chunks?!
    PHP:
    $chunk $source->getLevel()->getChunk($source->>> 4$source->>> 4true);
    //$source is the player
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    That code should work.
    what does var_dump($chunk) say?
     
  3. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    This is the error:
    (Vardump looks normal)
    PHP:
     Argument 2 passed to pocketmine\entity\Entity::createEntity() mu
    st be an instance of pocketmine
    \level\Levelinstance of pocketmine\level\format\Chunk given
     
  4. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
  5. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
  6. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    please read the commit description in the link.
    quote: All entity and tile constructors now require a \pocketmine\level\Level instead of a \pocketmine\level\format\Chunk.
    okay, if that's too complicated for you how about:
    https://github.com/pmmp/PocketMine-...c00#diff-9649873f1670ddd60984257dd0380943R524


    still not clear?
    PHP:
    /** @var $source pocketmine\entity\Entity */
    Level::createEntity($blah1$source->getLevel()->getChunk($source->>> 4$source->>> 4true), $blah2);
    //is now
    Level::createEntity($blah1$source->getLevel(), $blah2);
     
  7. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Yes. Now it works for me. And how can I give for example a silverfish a Nametag?
     
  8. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    For setting nametags:
    PHP:
     /** @var Entity $entity */
     
    $entity->setNameTag("Silverfish");
     
  9. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    I already tried that...
     
  10. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Were there any errors? You may need to use this to get it to display:
    PHP:
     $entity->setNameTagVisible(true); 
     
  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.