Jump to content

Correctly access nested sounds in sounds.json


Raycoms

Recommended Posts

I have various sounds in my sounds.json and accessing them works usually well, but some of the objects in the json file have various sounds like:

 

  "mob.barbarian.hurt": {
    "category": "hostile",
    "sounds": [
      {
        "name": "minecolonies:mob/barbarian/hurt1",
        "stream": false
      },
      {
        "name": "minecolonies:mob/barbarian/hurt2",
        "stream": false
      },
      {
        "name": "minecolonies:mob/barbarian/hurt3",
        "stream": false
      },
      {
        "name": "minecolonies:mob/barbarian/hurt4",
        "stream": false
      }
    ]
  },

 

How may I register these?

sound1 = registerSound("mob.barbarian.hurt.1");
sound1 = registerSound("mob.barbarian.hurt[1]");

 

I tried various of these but they didn't work.

 

How do access these nested ones?

Link to comment
Share on other sites

I haven't dealt with sounds in a LONG time, so don't qoute me on this.

 

Right now you have 1 sound "object" in which you specify multiple sound files. This makes it, that whenever you play the sound, Minecraft selects a random sound specified in your sound "object". If you want to play these sounds yourself you have to make a new sound "object".

 

EDIT: Apparently I was right :/

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Hmmm.  Lets see...

 

"name": "minecolonies:mob/barbarian/hurt1"

 

I wonder if this name means anything...

 

registerSound("minecolonies:mob/barbarian/hurt1");

 

Ooooh...it does!

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

larsgerrits was correct:

mob.barbarian.hurt

is the name of your sound event, so use this in the

ResourceLocation

you pass to the

SoundEvent

constructor.

 

minecolonies:mob/barbarian/hurt1

is the path to a sound file, which doesn't need to be registered.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

and then it will choose a random one from them?

 

That's even better.

 

Yes, that's the whole point of having a sound event contain multiple sound files.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.