PacketPlayOutNamedSoundEffect

Discussion in 'Plugin Development' started by Robin Bi, May 31, 2014.

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

    Robin Bi

    So, I'm new to Packets, and i've seen some sourcecodes with those crazy PacketDataSerializers, but those are quite complicated.

    I've been working with the PacketPlayOutPlayerInfo that can change the tablist.
    Code like this worked perfectly fine there:
    Code:java
    1. PacketPlayOutPlayerInfo zelle1 = new PacketPlayOutPlayerInfo("§1", true, 5000);
    2. PacketPlayOutPlayerInfo zelle2 = new PacketPlayOutPlayerInfo("§2", true, 5000);
    3. PacketPlayOutPlayerInfo zelle3 = new PacketPlayOutPlayerInfo(" §aM§cC§eN", true, 5000);
    4. PacketPlayOutPlayerInfo zelle4 = new PacketPlayOutPlayerInfo("§3", true, 5000);
    5. PacketPlayOutPlayerInfo zelle5 = new PacketPlayOutPlayerInfo("§4", true, 5000);
    6.  
    7. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(zelle1);
    8. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(zelle2);
    9. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(zelle3);
    10. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(zelle4);
    11. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(zelle5);


    No complicated PacketDataSerializers at all.

    So i wondered whether it's possible to do stuff like this with other packets as well. I need to play sounds for a player, but the other players should not hear it. A small volume doesn't help because if two players have the exact same location what could be the case here, bothes will hear it.

    And that's where the PacketPlayOutNamedSoundEffect comes in.

    Code:java
    1. PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect();
    2. CraftPlayer cp = (CraftPlayer) p;
    3. cp.getHandle().playerConnection.sendPacket(packet);


    I know that i need some params to construct the Packet, but i don't know which ones. With the PacketPlayOutPlayerInfo it was the text, whether it should be shown or not, and the ping. For the PacketPlayOutNamedSoundEffect though, i only get sources like this where i'd have to learn about Serializers first and i hope this is not necessary.


    Hopefully someone can tell me how to deal with this specific packet or at least where to start learning about the Serializers.



    Thanks :3
     
Thread Status:
Not open for further replies.

Share This Page