Entity doesn't appear after send packet, which spawns that entity

Discussion in 'Plugin Development' started by EastWestFM, Nov 2, 2014.

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

    EastWestFM

    Hello, I have a strange problem. I have a method that I call the command. Same method I calling while player join to the server. When doing it from the command works, but when doing it anywhere else does not work anymore.

    Code (yes I know, is weak :c):
    Code:java
    1. public static void respawnGuild(Player p, Guild g) {
    2. HashMap<Guild, Integer> ids = sends.get(p.getName());
    3. if (ids == null)
    4. ids = new HashMap<>();
    5. Location l = g.getCuboid().getCenter();
    6. l.add(0.5, 2.0, 0.5);
    7.  
    8. double x = l.getX();
    9. double y = l.getY();
    10. double z = l.getZ();
    11. if (ids.containsKey(g)) {
    12. int id = ids.get(g);
    13. int newId = getId();
    14. ids.put(g, newId);
    15. PacketUtil.sendPacket(p, createDespawnPacket(id), createSpawnPacket(newId, x, y, z, 51));
    16. sends.put(p.getName(), ids);
    17. return;
    18. }
    19. int id = getId();
    20. ids.put(g, id);
    21. PacketUtil.sendPacket(p, createSpawnPacket(id, x, y, z, 51));
    22. sends.put(p.getName(), ids);
    23. }


    Sorry for my weak english, I'm Pole! :D
     
  2. Offline

    Jalau


    We need your createDespawn and createSpawn Packet methods ;) Because we can't tell how the packet is constructed just with this information ;)
     
  3. Offline

    EastWestFM

    Ok, I solved the problem. The reason was bad entity id. Thanks for help ;)
     
Thread Status:
Not open for further replies.

Share This Page