[NMS/ProtocolLib] Detonating a Firework (per-player)

Discussion in 'Plugin Development' started by LugnutsK, Jul 22, 2014.

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

    LugnutsK

    Hello all
    I am currently trying to use ProtocolLib and PacketWrapper (ty aadnk) to spawn and detonate a firework for a specific player. Here is my code:
    Code:java
    1. int id = 0;
    2. try {
    3. entity = new WrapperPlayServerSpawnEntity(ReflectionUtil.getCBFireworkInstance(loc), ObjectTypes.FIREWORK, 0);
    4. id = entity.getEntityID();
    5. entity.sendPacket(player);
    6. }
    7. catch (ReflectiveOperationException e) {
    8. LOG.log(Level.SEVERE, "Could not instantize firework classes", e);
    9. }
    10.  
    11. WrapperPlayServerEntityStatus explode = new WrapperPlayServerEntityStatus();
    12. explode.setEntityId(id);
    13. explode.setEntityStatus(Status.FIREWORK_EXPLODING);
    14. explode.sendPacket(player);

    (ReflectionUtil is a class that I made that generates a CraftFirework)
    (Wrapper classes can be found here)

    When running this code, it successfully spawns a firework for the player. However, the firework does not disappear, but continues to fly upward and away in a random direction. It then causes the client to freeze up over the course of 2-3 seconds. If anyone with knowledge of the protocols could help with this problem, that would be great.

    Thanks,
    LugnutsK
     
  2. Offline

    mine-care

    I don't REALY know about nms but I would sugest spawning a firework at their location with power 0 it explodes pretty well and it flys for only ~2 blocks so I don't think they will notice it. Other than that idk :( sorry if I didn't help that much
     
Thread Status:
Not open for further replies.

Share This Page