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

How to spawn an entity.

Discussion in 'Development' started by Minetron26, Jul 10, 2019.

  1. Minetron26

    Minetron26 Witch

    Messages:
    55
    GitHub:
    minetron26
    Hello, I would like to know, how to generate an entity, I have already tried it, but it says: Call to a member function spawnTo() on null.
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Can you show your attempt? Most likely you got the wrong entity id
     
    Minetron26 likes this.
  3. Minetron26

    Minetron26 Witch

    Messages:
    55
    GitHub:
    minetron26
    Yes, maybe, here is my attempt:
    PHP:
    $position = new Position($x$y$z$player->getLevel());
    $nbt Entity::createBaseNBT($position);
    $entity Entity::createEntity(10$player->getLevel(), $nbt);
    $entity->spawnToAll();
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Are you sure entity id 10 is registered? PocketMine is missing most entities, so mobs are not registered by default
     
  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.