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

Solved Creating Entity Problem

Discussion in 'Development' started by Kyd, Apr 14, 2017.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Hello I adding entity on position 155, 65, 96 it is on stone slab (in my screen), but it spawn entity near stone slabs:/ I think you do not want code i basically spawning entity with createEntity function.

    I dont know why I can not upload screen here :/
    If you understand my problem please help me.

    EDIT: I adding it in PlayerJoinEvent and spawning only for my current player.
     
    Last edited: Apr 14, 2017
  2. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    If it's a plugin problem, then the code is required.

    Please put your code within [php ] [/php] tags.
     
  3. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    public function addAllNPC(Player $p){
        
    $nbt $this->makeNBT($p131631270180);
        
    $entity Entity::createEntity("Human"$p->getLevel(), $nbt);
        
    $entity->setNameTag("text");
        
    $entity->setNameTagVisible(true);
        
    $entity->setNameTagAlwaysVisible(true);
        
    $entity->spawnTo($p);
        
    $nbt $this->addNBT($p15565963600);
        
    $entity Entity::createEntity("Human"$p->getLevel(), $nbt);
        
    $entity->setNameTag("ss");
        
    $entity->setNameTagVisible(true);
        
    $entity->setNameTagAlwaysVisible(true);
        
    $entity->spawnTo($p);

    public function 
    makeNBT(Player $player$x$y$z$yaw$pitch){
        
    $nbt = new CompoundTag;
        
    $nbt->Pos = new ListTag("Pos", [
            new 
    DoubleTag(0$x),
            new 
    DoubleTag(1$y),
            new 
    DoubleTag(2$z)
        ]);
        
    $nbt->Motion = new ListTag("Motion", [
            new 
    DoubleTag(00),
            new 
    DoubleTag(10),
            new 
    DoubleTag(20)
        ]);
        
    $nbt->Rotation = new ListTag("Rotation", [
            new 
    FloatTag(0$yaw),
            new 
    FloatTag(1$pitch)
        ]);
        
    $nbt->Health = new ShortTag("Health"10);
            
    $player->saveNBT();
            
    $nbt->Skin = new CompoundTag("Skin", ["Data" => new StringTag("Data"$player->getSkinData()), "Name" => new StringTag("Name"$player->getSkinId())]);
        return 
    $nbt;
    }

    }
     
    Last edited: Apr 15, 2017
  4. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Can we see the "addNBT" function?
     
  5. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    It was makeNBT Sorry:D I edited.
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Ah, I solved i have
    PHP:
    $nbt $this->makeNBT($p131.563127.50180);
    instead of
    PHP:
    $nbt $this->makeNBT($p131631270180);
    And working now!
     
  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.