Add sounds to a resource pack, not replace them
I already know that you can have custom sounds in Minecraft by replacing the original sound effects using a resource pack, but that's not exactly what I want. I tried that already and it worked, but I want to see if I can add more sounds instead of replacing pre-existing ones since I'm not sure which sounds I can replace now that won't become a problem for me later on.
I know that it is apparently possible to do this, and I've heard that all you have to do is stick in the sound file wherever and go by the filepath relative to your sounds folder; here's an example in my case. I have a sound called nomoretears.ogg located at sounds/block/custom/nomoretears.ogg, and I tried to play it in-game with the following command:
/playsound block.custom.nomoretears ambient @p
However, it did not work. It isn't the command being typed wrong because this command did work:
/playsound block.barrel.close ambient @p
And all I did was play a pre-existing sound.
So, what am I doing wrong?
P.S. I have tried refreshing/resetting my resource pack by going into the resource packs menu and taking it off and putting it back on. I also tried restarting Minecraft. Neither did anything.
P.P.S I got this specific sound to work when I was replacing the barrel close sound, but not when I tried to add it to the custom folder.
Oh, and one more thing -- I noticed in the Sound Options that I had some of the sliders down, but I already had ambient at 100%. After I turned all of them back up still nothing happened.
Solution 1:
Custom sounds need to be registered into a file called sounds.json so the game knows which sound file to play when the command is called. sounds.json is located in your_res_pack/assets/minecraft/sounds.json
.
An example of sounds.json:
{
"keyboard": {
"sounds":[
{
"name": "custom/keyboard_sound",
"weight": 1
}
]
}
}
- keyboard can be any name you want (example: "entity.sheep.ambient"), this is what you type in the /playsound command to play the custom sound.
- sounds is an array of sound. Each sound in this array has a name property which defines the filename and location of the sound file. In this case, the file "keyboard_sound.ogg" is in the "custom" folder. If there are multiple sounds defined in the sounds array, the system will pick a random sound to play each time the sound event is called.
- weight is the chance of this sound being picked to play when the sound event is called via /plasound. This is used when you have multiple sounds in the array and you want to increase the chance of this sound being played.
There is more to sounds.json but this is the basic idea. More info on this file can be found on the wiki: https://minecraft.gamepedia.com/Sounds.json