Playing Cave Sound Effects

Discussion in 'Plugin Development' started by smcerm, Sep 29, 2012.

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


    Hi all,

    Is there a way to play the spooky cave noises with a server plugin? I know of World.playEffect(), but it doesn't seem to include these sounds. Is there another method, or is this only possible on the client side?

    Thank you.
  2. Offline


    I think that this would require Spout, but I am not 100% sure...
  3. Offline


    Ah. That's what I was afraid of. I don't really want to add a dependency...
  4. Offline


  5. Offline


    Orrrrr, use a prebuilt MC method. Get the net.minecraft.server.World equivalent of a Bukkit world, and call . makeSound(l + 0.5D, j1 + 0.5D, i1 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.random.nextFloat() * 0.2F); on it. l = x, ji = y, and i1 = y.

    If its something controlled by the server in the first place, Spout is not required.

    Fun Fact: There are many different strings you could put in place of ambient.cave.cave. Putting random.explosion would make the explosion sound, if I remember correctly!
  6. Offline


    How do we initialize the world variable for that?
  7. Offline


    yes... player.playSound(playerlocation, Sound.CAVE_AMBIENCE, 7, 1);
    MinopolisMc and lol768 like this.
  8. Offline


    Wow, that's much better.
  9. Offline


    This is fantastic!

    I love being able to add more special effects!
  10. Offline


    Just don't steal my things.
  11. Offline


    Wouldn't think of it! Just want to spook the becreepers out of my players. xD
  12. Offline


    Short & sweet API for anyone who cares:

    2. public void playSound(Player to, String sound, Location loc, float pitch, float volume) {
    3. ((CraftPlayer) to).getHandle().netServerHandler.sendPacket(new Packet62NamedSoundEffect(sound, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), pitch, volume));
    4. }
    6. public void playSound(Player to, String sound, float pitch, float volume) {
    7. playSound(to, sound, to.getLocation(), pitch, volume);
    8. }
    10. public void playSoundNearby(Location origin, double radius, String sound, float pitch, float volume) {
    11. for (Player p : getNearbyPlayers(origin, radius)) {
    12. playSound(p, sound, origin, pitch, volume);
    13. }
    14. }

    Allows you to play any sound in .minecraft/resources/sound3, with folders defined by a '.'. So, playing the portal trigger effect would be portal.trigger as the sound, and playing the thunder sound would be

    The cave sound is ambient.cave.cave
  13. Offline


    Dont Use EndermanScream... lol. scares me.
Thread Status:
Not open for further replies.

Share This Page