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

AddEntityPacket

Discussion in 'Development' started by LCraftPE, Jan 19, 2017.

  1. LCraftPE

    LCraftPE Silverfish

    Messages:
    20
    GitHub:
    LCraftPE
    Hello,
    I have a problem: I use a Task to add an EntityPacket, but sometimes the nametag changes its position (it shifts from a block)... How can it keep the position that I put in my code ($x/$y/$z) ?
    PHP:
        $spawn = new AddEntityPacket();
        
    $spawn->type $type;
        
    $spawn->eid $eid;
        
    $spawn->$x;
        
    $spawn->$y;
        
    $spawn->$z;
        
    $spawn->speedX 0;
        
    $spawn->speedY 0;
        
    $spawn->speedZ 0;
        
    $spawn->yaw 0;
        
    $spawn->pitch 0;
        
    $spawn->metadata = [
        
    Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG$flags],
        
    Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING$string],
        
    38 => [Entity::DATA_TYPE_LONG, -1]];
        foreach(
    $this->owner->getServer()->getOnlinePlayers() as $player){
          
    $player->dataPacket($spawn);
        }
    Thank you.
     
    Last edited: Jan 19, 2017
  2. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    The namedtag (NBT tags) are processed server side, the position specified in NBT should not affect the position displayed to the client. I don't see why you need to directly send packets when you can easily extend PocketMine's Entity classes to achieve what you're trying to do.

    Just a quick note for your future posts, it'd be easier to help you achieve what you want if you provide us with the full code (or at least the class).
     
  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.