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

Custom NPC name for each player

Discussion in 'Development' started by Error202, Apr 20, 2019.

  1. Error202

    Error202 Spider Jockey

    Messages:
    39
    For set custom entity name for current player I use:
    PHP:
    $pk = new SetEntityDataPacket();
            
    $pk->entityRuntimeId $entity->getId();
            
    $pk->metadata = [
                
    Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING$name]
            ];
            
    $player->dataPacket($pk);
    All ok, if player and entity in one chunk, otherwise the name does not change.
    How I can check if entity and player in one chunk? (Ex.: on move event)
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    This wouldn't work as your expecting it to even if you figure out how you can check if two entities are in the same chunk.

    You'll need to intercept all SetEntityDataPackets the server is sending the player and do the modifications.

    One way is by overriding the setNameTag function using a custom player class if it isn't hurting anyone.
     
    Error202 likes this.
  3. Error202

    Error202 Spider Jockey

    Messages:
    39
    Thanks!

    Do you have info or links on how to do this? (intercept all SetEntityDataPackets or content for new setNameTag)
     
  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.