Updating entity skin with PlayerListPacket not showing the skin's 3d layer

Discussion in 'Development' started by SpopovabgS, Feb 11, 2019.

  1. SpopovabgS

    SpopovabgS Witch

    Messages:
    54
    GitHub:
    hartleyterw
    PHP:
            $add = new PlayerListPacket();
            
    $add->type PlayerListPacket::TYPE_ADD;
            
    $add->entries = [PlayerListEntry::createAdditionEntry($uuid$npc->getId(), ''$skin)];
            
    $p[] = $add;

            
    $pk = new AddPlayerPacket();
            
    $pk->uuid $uuid;
            
    $pk->username $name;
            
    $pk->entityRuntimeId $npc->getId();
            
    $pk->position $npc->asVector3(); //TODO: check offset
            
    $pk->item ItemFactory::get(Item::AIR00);
            
    $flags = (<< Entity::DATA_FLAG_IMMOBILE);
            
    $pk->metadata = [Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG$flags]];
            
    $p[] = $pk;

            
    $remove = new PlayerListPacket();
            
    $remove->type PlayerListPacket::TYPE_REMOVE;
            
    $remove->entries = [PlayerListEntry::createRemovalEntry($uuid)];
            
    $p[] = $remove;
    (code taken from FloatingTextParticle)
    When the NPC is created it has the 3d layer but not when I update the skin.
     
    Last edited: Feb 11, 2019
  2. KielKing

    KielKing Zombie

    Messages:
    233
    GitHub:
    kielking
    what is $npc? if NPC is an entity, just set it's skin before spawning it.
     
  3. SpopovabgS

    SpopovabgS Witch

    Messages:
    54
    GitHub:
    hartleyterw
    I have to update the NPC's skin to another skin at a later point.
     
  4. KielKing

    KielKing Zombie

    Messages:
    233
    GitHub:
    kielking
    despawn it and respawn it with the same data except the skin
     
  5. wolfdale

    wolfdale Zombie

    Messages:
    285
    Use PlayerSkinPacket?
     
  6. KielKing

    KielKing Zombie

    Messages:
    233
    GitHub:
    kielking
    hacky, not handled by PMMP
     
  7. wolfdale

    wolfdale Zombie

    Messages:
    285
    What do you mean? It is a legitimate packet used by PMMP. Have a look at Human::sendSkin()
     
  8. KielKing

    KielKing Zombie

    Messages:
    233
    GitHub:
    kielking
    i mean you would need to send the packet to every player including joining players yourself
     
  9. Muqsit

    Muqsit Chicken Verified

    Messages:
    1,519
    GitHub:
    muqsit
    The same goes for the other packets OP is sending. It's a small part of Entity handling rewritten.
     
  10. KielKing

    KielKing Zombie

    Messages:
    233
    GitHub:
    kielking
    ah I see. using purely packets to create an NPC, doesn't seem like a great idea imo, it's better to make your own entity class
     

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.