Play Custom Sounds

Discussion in 'Plugin Development' started by xMakerx, Aug 19, 2014.

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

    xMakerx

    Hi there, I'm interested in trying to add custom sounds to a client-side resource package which the server can tell the clients to play at a certain time and at a certain location, but I have no idea how to implement it. I'd be grateful if someone could help me out with this one. Thanks!

    Edit: I'd prefer a method without having the web browser open in the background.
     
  2. Offline

    mythbusterma

    xMakerx

    Create a resource pack with new sounds (google it), then use World#playSound (Location, <thesoundyoureplaced> float, float) to play it to them.
     
  3. Offline

    xMakerx


    I don't want to replace sounds though, I just want to add new ones. If possible can you or someone else explain this to me: https://forums.bukkit.org/threads/custom-sounds.267725/.
     
  4. Offline

    mythbusterma

    xMakerx

    Hmmm, well I would say copy that code and use it, but it was of exceptionally low quality and I'm constantly told you shouldn't be using reflection for this anyway, so I'd recommend examining that and creating maven modules to allow abstraction between versions etc.
     
  5. Offline

    xMakerx


    I don't understand his code at all, could you explain it to me?
     
  6. Offline

    mythbusterma

    xMakerx

    I didn't bother to read it all, and I can't examine it as I'm on my phone, but what you would basically have to do is change how the server hands the playong of a sound to allow for a custom path (alternatively, and this is the nastier approach, add a member to the enum using reflection that has the path to your sound).
     
  7. Offline

    SpaceManiac

  8. Offline

    xMakerx


    Thanks, but how would this be done? Can you post some code when you can access a computer?


    Can you write me some code as an example? That would be really helpful as I'm not understanding.

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

    mythbusterma

  10. Offline

    SpaceManiac

    It's a method on Player which takes a Location, sound name, volume, and pitch in that order.
    player.playSound(location, "path.to.sound", 1.0f, 1.0f)
     
  11. Offline

    xMakerx


    So how would I point to my resource path? Let's say I have a folder named "myplugin" in the sound folder of my resource package, and a folder named "boss01" inside of that, would my path be: "sound/myplugin/boss01"?
     
Thread Status:
Not open for further replies.

Share This Page