Solved Spawn fireworks via packets?

Discussion in 'Plugin Development' started by Vexil, Nov 9, 2013.

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

    Vexil

  2. Offline

    RealDope

  3. Offline

    Vexil

    That is an effect (not an entity), and I know that... I'm trying to spawn an entity for one player
     
  4. Offline

    xTrollxDudex

    BenCS_
    Try Packet24MobSpawn
     
  5. Offline

    Vexil

  6. Offline

    xTrollxDudex

    BenCS_
    You don't need to use the constructor, just set the fields

    Edit: How about actually spawning the firework, but send Packet29DestroyEntity to each of the players you don't want seeing the firework except the player that you do want to see the firework?
     
  7. Offline

    Vexil

    Hm.. good idea, I'll try it but I imagine it might flicker just like en.remove();

    EDIT: xTrollxDudex Packet29DestroyEntity works, but it still plays the sound. I'd like it to exclusively spawn to the player, I'll try the Packet24MobSpawn now.

    EDIT 2:
    What I'm doing is fairly simple, I just can't seem to get it to work. I'm making a plugin so you can right click players and shoot them up as if they were fireworks, and I'd like to make it so it launches a few fireworks, shoots the player up, plays the smoke effect, and when the fireworks explode hide the player for the one that right clicked them. I have this so far
    Code:java
    1. @EventHandler
    2. public void FWHit(PlayerInteractEntityEvent e) throws Exception {
    3.  
    4. if(e.getRightClicked() instanceof Player) {
    5.  
    6. Player p = e.getPlayer();
    7. Player en = (Player) e.getRightClicked();
    8.  
    9. Packet63WorldParticles packet = new Packet63WorldParticles();
    10. ReflectionUtil.setValue(packet, "a", "smoke");
    11. ReflectionUtil.setValue(packet, "b", Float.valueOf((float) en.getLocation().getX()));
    12. ReflectionUtil.setValue(packet, "c", Float.valueOf((float) en.getLocation().getY()));
    13. ReflectionUtil.setValue(packet, "d", Float.valueOf((float) en.getLocation().getZ()));
    14. ReflectionUtil.setValue(packet, "e", Float.valueOf(0));
    15. ReflectionUtil.setValue(packet, "f", Float.valueOf(0));
    16. ReflectionUtil.setValue(packet, "g", Float.valueOf(0));
    17. ReflectionUtil.setValue(packet, "h", Float.valueOf(1.0F));
    18. ReflectionUtil.setValue(packet, "i", Integer.valueOf(100));
    19.  
    20. Packet24MobSpawn fwpacket = new Packet24MobSpawn();
    21. ReflectionUtil.setValue(fwpacket, "a", 23);
    22. ReflectionUtil.setValue(fwpacket, "b", EntityType.FIREWORK.getTypeId());
    23. ReflectionUtil.setValue(fwpacket, "c", (int) en.getLocation().getX());
    24. ReflectionUtil.setValue(fwpacket, "d", (int) en.getLocation().getY());
    25. ReflectionUtil.setValue(fwpacket, "e", (int) en.getLocation().getZ());
    26.  
    27. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
    28. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(fwpacket);
    29.  
    30. }
    31.  
    32. }

    I have the thing that shoots the player up using Packet31RelEntityMove in another class (not implemented at the moment because I'm trying to get the fireworks to work). My problem is getting the fireworks to launch and adding firework metadata to said fireworks.
     
  8. Offline

    xTrollxDudex

    BenCS_
    You can actually send the move packet using various fields from the mob spawn packet I believe. As for the metadata, you can just send a separate Packet63WorldParticles for fireworkSpark. I'm not sure to create the custom explosion, my guess is the explosion packet with some particle data
     
  9. Offline

    Vexil

    I don't want to get the effect, I want to spawn actual fireworks to shoot up with the player. I can't get those to spawn (or add the fireworkmeta), the shooting up part I already have.
     
  10. Offline

    xTrollxDudex

    BenCS_
    Actually like server side fireworks, not packets right?
     
  11. Offline

    Vexil

    No, packets. I need them to be exclusive to the player. When a player right clicks a player in the lobby, it shoots the player up like a firework and spawns a few fireworks, but only for that player
     
  12. Offline

    xTrollxDudex

    BenCS_
    So this:
    Player A clicks player B. Player B appears just to Player A to shoot up, and he appears just to Player A to have a firework follow him.

    And your problem is getting the imaginary firework to go up with specific meta? You can't day itemmeta to a packet, if that is your goal. I'm running out of ideas now :p
     
  13. Offline

    Vexil

    Exactly :p And I know it is possible, as I have seen it done before.
     
Thread Status:
Not open for further replies.

Share This Page