1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Call Custom Sound from Server Resource Pack?

Discussion in 'Development' started by David Flash, Dec 11, 2020.

  1. David Flash

    David Flash Spider Jockey

    Messages:
    26
    GitHub:
    davidflashcz
    Hello, I've been trying to play a custom sound from my server resource pack but it just doesn't work. I suppose that I have to use PlaySoundPacket, but how do I get the location of the sound there first?
     
  2. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    I think you should modify existing ones, not custom sound support yet I think
     
  3. David Flash

    David Flash Spider Jockey

    Messages:
    26
    GitHub:
    davidflashcz
    Found the solution myself. You have to make a sound_definitions.json and define the custom sound names there and their location. Apply the texture pack and force it to all. Woala, just use PlaySoundPacket and you have it!

    Here is the code:
    PHP:
    $pk = new PlaySoundPacket;
                 
    $pk->soundName "yoursoundname";
                 
    $pk->= (int)$this->player->x;
                 
    $pk->= (int)$this->player->y;
                 
    $pk->= (int)$this->player->z;
                 
    $pk->volume 1;
                 
    $pk->pitch 1;
                 
    $this->player->dataPacket($pk);
    sound_definitions.json:
    Code:
    "yoursoundname": {
        "category": "music",
        "sounds": [{ "name": "sounds/location/soundname", "stream": true }]
      }
    I hope this will help :)
     
    RicardoMilos384 and ethaniccc like this.
  4. Superomarking

    Superomarking Spider Jockey

    Messages:
    34
    GitHub:
    Superomarking
    why do you need to use a resource pack to put sounds why dont you just code your own sounds
     
  5. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    If the client dosen't recognize it, nothing would happen (plus, how would you code a sound).
     
  6. Superomarking

    Superomarking Spider Jockey

    Messages:
    34
    GitHub:
    Superomarking
    combine two sounds into one i guess
     
  7. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    how do you expect the client to play a sound if it doesn't exist? it needs to have a resource pack downloaded with the sound inside it, otherwise it won't work.
    also what the hell does coding a sound mean?
     
    Ayush likes this.
  8. Superomarking

    Superomarking Spider Jockey

    Messages:
    34
    GitHub:
    Superomarking
    uh just stop ok
     
    Ayush likes this.
  9. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    ...
     
    Ayush likes this.
  10. Ayush

    Ayush Witch

    Messages:
    62
    Can I get his full plugin I like that plugin please
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.