Solved Creating Npc

Discussion in 'Development' started by azk_, Aug 21, 2018.

  1. azk_

    azk_ Spider Jockey

    Messages:
    49
    PHP:
    $nbt Entity::createBaseNBT($sender, new Vector3((int) $sender->getX(),(int) $sender->getY(),(int) $sender->getZ()), $sender->getYaw(), $sender->getPitch());
                    
    $nbt->setShort("Health"20);
                    
    $nbt->setString("MenuName""");
                    
    $nbt->setString("CustomName""NPC");
                   
                    
    $nbt->setTag(new CompoundTag("Skin", [
                        new 
    StringTag("Name"$sender->getSkin()->getSkinId()),
                        new 
    ByteArrayTag("Data"$sender->getSkin()->getSkinData()),
                        new 
    ByteArrayTag("CapeData"$sender->getSkin()->getCapeData()),
                        new 
    StringTag("GeometryName"$sender->getSkin()->getGeometryName()),
                        new 
    ByteArrayTag("GeometryData"$sender->getSkin()->getGeometryData())
                    ]));
                    
                    
    $entity Entity::createEntity("Human"$sender->getLevel(), $nbt);
                    
    $entity->spawnToAll();
    What is wrong with my code?
    No errors but not working
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,560
    GitHub:
    muqsit
    Uh, the Human class doesn't have a valid network id which is why you can't "see" the entity.
     
  3. azk_

    azk_ Spider Jockey

    Messages:
    49
    Can you tell me how to fix this?
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,560
    GitHub:
    muqsit
    Actually, I might be wrong. Are you sure the code is executing?
     
  5. azk_

    azk_ Spider Jockey

    Messages:
    49
    Just like i said it before
     
  6. azk_

    azk_ Spider Jockey

    Messages:
    49
    nvm i just solved it myself
     
    Last edited: Aug 21, 2018
  7. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,373
    GitHub:
    robske110
    please share your solution, so others viewing this thread can learn.
     
    HimbeersaftLP, Muqsit and Qeis2007 like this.
  8. Jules

    Jules Spider Jockey

    Messages:
    49
    GitHub:
    Julooooos
    I have exactly the same issue ? Any ideas to fix it ?
     

Share This Page

  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.