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

Solved How do I spawn a mob with code

Discussion in 'Development' started by YogaLose, Apr 17, 2021.

  1. YogaLose

    YogaLose Spider

    Messages:
    10
    How to spawn mob in the player position
    -- With CustomName
    -- Without showing the mob (size 0)
     
    Last edited: Apr 17, 2021
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    What's the point of spawning in a chicken if it's gonna be invisible..???

    You first have to register the chicken entity
    then do
    PHP:
    $entity->setDataFlag(Entity::DATA_FLAGSEntity::DATA_FLAG_INVISIBLEtrue);
    to make the entity invisible.

    Then do
    PHP:
    $entity->setNameTagAlwaysVisible(True);
    $entity->setNameTag("CUSTOM NAME");
    to make the entity have a custom name
     
  3. YogaLose

    YogaLose Spider

    Messages:
    10
    PHP:
    $entity = new Zombie($this->getLevel(), Zombie::createBaseNBT($position));
    $entity->spawnToAll();
     
    Last edited: Apr 17, 2021
  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.