Triggering Sounds (from Explosions)

Discussion in 'Plugin Development' started by IceReaper, Jun 8, 2011.

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

    IceReaper

    Hello, i just added the following funtion to prevent creepers and tnt to destroy the world. however the explosion sound is not played anymore:
    Code:
        public void onEntityExplode(EntityExplodeEvent event) {
            event.setCancelled(true);
        }
    
    Does any1 know how i can send the explosion sound effect to the players that should hear them?
     
  2. Offline

    DreadKyller

    on the explosion event you could get the blocks destroyed and reset them instead of canceling the event.
     
  3. Offline

    IceReaper

    hm.. possibly.. but that would not remove all dropped material which was destroyed.?
     
  4. Offline

    DreadKyller

    hmm, good point, randomly a lot of dropped blocks will just appear... I'll get back to you...

    I was looking to see if any of the block events had a get cause, but none do except burn.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  5. When the tnt explodes just store the location and then scan through the destroyed blocks. If there is a block of that type on the ground remove it and decrement the list, and so on.
     
  6. Offline

    IceReaper

    ok, think ill have to do it that way. but its a totaly ugly sollution. secondly it would always cause problems. imagine someone drops 10 stacks dirt for some1 else to pickup. in that moment a creeper explodes behind, all their stuff gets deleted too.
     
  7. Offline

    1337

    Im guessing there is a packet that makes the noise. let me have a look in the code be right back :D

    There is a explostion packet, which will play the sound im guessing. but im no good with packets and stuff

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  8. Offline

    Sethcran

    There is some new stuff being pushed to the bukkit github that deals with this, and may be in the next api snapshot.

     
  9. Offline

    desht

    This will do it:

    PHP:
    Packet60Explosion packet = new Packet60Explosion(locX,locY,locZ,(float) 10.0, new HashSet());
    ((
    CraftPlayer)player).getHandle().netServerHandler.sendPacket(packet);
    Alter the location parameters to suit - you can get a suitable location from your event. They are Double, not Integer.

    Not entirely certain on the 10.0 parameter - perhaps the radius within which you will hear the sound? Also not sure on the hashset - passing an empty one appears to work. Anyway, I've tested the above - it plays the explosion sound, but no other explosion effects occur.
     
  10. Offline

    DreadKyller

    @desht what package is that packet in? I searched in craftbukkit and bukkit.
     
  11. Offline

    desht

    net.minecraft.server - from craftbukkit.
     
  12. Offline

    DreadKyller

    ok, it appears to be:

    Packet60Explosion(double x, double y, double z, float radius, Sat<Block> blocks)

    so doing something like:

    Packet60Explosion packet = new Packet60Explosion(x, y, z, radius, null);

    should make the sound but not destroy any blocks, btw, I decompiled the .class file
     
Thread Status:
Not open for further replies.

Share This Page