Prevent EnderDragon sound from being played on all worlds

Discussion in 'Plugin Development' started by iamdansker, Jul 23, 2013.

Thread Status:
Not open for further replies.
  1. When an enderdragon dies, it doesn't just play the death sound in the end world, but in every other world, this is pretty annoying as everyone else have no idea that they are about to have their pants scared off them.

    My guess would be that it is related to the entity status package sent to the client about an entity's death. but i have never really puzzled around with protocollib, so if anyone already had a solution, it would be great :p
     
  2. Offline

    Comphenix

    This sound is triggered by a Packet61WorldEvent with the effect ID 1018, relative disable volume set to TRUE, and the coordinates of the Ender Dragon being destroyed.

    So, something like this should work (download):
    Code:java
    1. public class ExampleMod extends JavaPlugin {
    2. @Override
    3. public void onEnable() {
    4. ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ConnectionSide.SERVER_SIDE, Packets.Server.WORLD_EVENT) {
    5. @Override
    6. public void onPacketSending(PacketEvent event) {
    7. String worldName = event.getPlayer().getWorld().getName();
    8. int effectId = event.getPacket().getIntegers().read(0);
    9.  
    10. if (effectId == 1018) {
    11. if ("world_the_end".equals(worldName)) {
    12. event.setCancelled(true);
    13. }
    14. }
    15. }
    16. });
    17. }
    18. }
     
    micahdg, Bammerbom and desht like this.
  3. Thanks man
    Btw how did you know that the effect id is 1018? just set up a listener and checked for every effect package and killed a dragon? because i can't seem to find it anywhere
     
  4. Offline

    LandonTheGeek

    Comphenix
    Great code. :) I don't understand how some people do this. Lol
     
  5. Offline

    Necrodoom

    should belong to plugin development.

    HelpfulBeast
    Comphenix is a genius, he can practically do this in his sleep.

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

    desht

    Well I'm not Comphenix, but one way would be to use ProtocolLib's packet command, e.g.
    Code:
    /packet add server 61 detailed
    
    will dump information to the console about all Packet61 data going from the server to the client. E.g.:
    Code:
    08:54:25 [INFO] [ProtocolLib] Sent WORLD_EVENT (61) to desht:
    { a = 1003, b = 0, c = -305, d = 72, e = -138, f = false }
    
    a is the effect ID (1003 is a door opening/closing - I'm standing in a village right now :) ) So have that listener active and go kill the ender dragon!

    Alternatively hunt through the CraftBukkit code for where the ender dragon dies and the effect is triggered (it's here: https://github.com/Bukkit/CraftBukk.../minecraft/server/EntityEnderDragon.java#L530)
     
    Comphenix likes this.
  7. Offline

    xTrollxDudex

    At least you are yet another genius.
     
    desht likes this.
  8. Offline

    desht

    Heh, not sure about that! ProtocolLib is the real work of genius here.
     
  9. Offline

    xTrollxDudex

    desht
    Cmon! You can code 100 times better than most people, that isnt a genius?
     
  10. Offline

    rsod

    xTrollxDudex
    Everyone can code 100 times better than most people, just because most people don't even know what is programming language
     
  11. Offline

    Samthelord1

    I think it's obvious that he means 100x better than the people on this forum, ex. Me, you.
     
  12. Offline

    xTrollxDudex

    rsod
    Eheheh nice loophole :p
     
Thread Status:
Not open for further replies.

Share This Page