Skip to content

Custom Sound Events

MehVahdJukaar edited this page Jan 16, 2024 · 11 revisions

Custom Sound Events

Polytone lets you register custom Sount Events via Resource Pack.

This will be handy if you intend to use them in your SoundTypes via Custom Block Properties.

Sound Types represend a new Sound that the game can play and are associated to one or more .ogg file.

Disclaimer

This feature is **EXPERIMENTAL ** and will remain so until its proven that it does not have side effects.

While I was not able to have any issues with it, the way this on the fly registration works is quite sketchy as they game doesnt usually do that. While its unlikely that these issues could be manifested its still worth using this feature with care.

Moreover if you have access to mods like KubeJs it is recommended to register your Sound Types there instead

Registering Sound Events

To add new sound events its super simple, simply add a list of comma separated sound event names in assets/[your pack name]/polytone/sound_events.csv Here's an example:

sound.lead.place,
sound.lead.break,
sound.zinc.hit

This will register those 3 sound events under YOUR PACK namespace. This means that to reference them you'll need to call them with their fully classified id [your pack name]:[your sound event name]. Say for example that your pack is called _my_pack_, then the events registry names will be something like my_pack:sound.lead.place.

Setting up Sounds.Json

Once you have done this the only remaining thing is to tell the game which Sound Files to use when a Sound Event plays. To do so you'll need to edit the sounds.json file in your resource pack at the location assets/[your pack name]/sounds.json

This is a vanilla concept and as such you can reference the Official Minecraft Wiki for more info about this but here's a quick example:

{
  "sound.zinc.hit": {
    "sounds": [
      {
        "name": "my_pack:zinc/hit_0",
        "stream": true
      }
    ],
    "subtitle": "subtitle.my_pack.zinc.hit"
  }
}

Note that the content of the "sounds" object is a list contaning the path of the actual .ogg files that will be played. Also remember to add a translation string in your lang file.