Playing Cave Sound Effects

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

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

    smcerm

    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

    chasechocolate

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

    smcerm

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

    MrFigg

  5. Offline

    Icyene

    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

    Loogeh

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

    Jnorr44

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

    Loogeh

    Wow, that's much better.
     
  9. Offline

    cadika_orade

    This is fantastic!

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

    CevinWa

    Just don't steal my things.
     
  11. Offline

    cadika_orade

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

    Icyene

    Short & sweet API for anyone who cares:

    Code:java
    1.  
    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. }
    5.  
    6. public void playSound(Player to, String sound, float pitch, float volume) {
    7. playSound(to, sound, to.getLocation(), pitch, volume);
    8. }
    9.  
    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. }
    15.  


    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 ambient.weather.thunder.

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

    david_rosales

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

Share This Page