Solved Show fake npc player without any entity?

Discussion in 'Plugin Development' started by connor stone, Feb 26, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    connor stone

    I've been messing around with packets trying to show my client a player, thats fake like an npc, but without any actually entity on the server. The npc doesn't have to move or react in any way, just be shown to the player.

    This is what i have so far, it does nothing :( (I'm using bkcommonlib for the packet stuff)

    2. int nextId = Short.MAX_VALUE;
    4. CommonPacket packet = new CommonPacket(PacketType.OUT_ENTITY_SPAWN_NAMED);
    6. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.entityId, nextId++);
    7. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.profile, "npc");
    8. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.x, (int) x);
    9. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.y, (int) pLoc.getY());
    10. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.z, (int) z);
    11. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.yaw, (byte) 45);
    12. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.pitch, (byte) 45);
    13. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.heldItemId, 0);
    15. DataWatcher dw = new DataWatcher();
    16. dw.set(0, (byte) 0);
    17. dw.set(12, (int) 0);
    18. packet.write(PacketType.OUT_ENTITY_SPAWN_NAMED.dataWatcher, dw);
    20. PacketUtil.broadcastPacket(packet, false);
  2. Offline

    connor stone

  3. Offline

    connor stone

  4. Offline

    connor stone


    Does no one know how to help me?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 6, 2016
  5. Offline


  6. connor stone I think you should put the location * 32, so like z * 32 , x * 32, y *32
  7. Offline

    connor stone

    Someone_Like_You Heirteir I need to be able to have a fake player be shown in the game, like an npc, but I dont want to have an actual entity on the server. Also what eould miltiplying by 32 do? The x and z varaiable are not in this code but they are just a player coords

    I also dont need it to like move or anything, just have client think its there whenever I want

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 6, 2016
  8. connor stone Listen to me again, first - if you send it on player login event, put it in delayed task, second... for the locations (x, y, z) MULTIPLY it by 32, thats how the packet work, I forgot how that number called but thats how its works... try it before comment that it didnt work please.
  9. Offline

    connor stone

    Someone_Like_You okay I will when I get home, its just confuses me becasue I work with packets alot and never had to do that with coords
  10. connor stone You work with packets but do not know whats fixed-point number? makes no sense.
    Heres what you would found on the protocol wiki. :
    try google stuff before you coming here to ask help.
    Garris0n likes this.
  11. Offline


    If you take a look at the actual packet, you'll see that all the coords are fixed-point numbers. Without sending them to the client like that, the NPC won't appear in the right spot :)
    Garris0n likes this.
  12. Offline

    connor stone

  13. connor stone Np, few stuff you might want to know, if youre sending the packet on player login/death/respawn, be sure to put it in delay of 1 tick, else the npc wont showup for the player.
Thread Status:
Not open for further replies.

Share This Page