Jump to content

Recommended Posts

Posted

How do I add music to my mods?

 

Scenario is like this:

 

I'm holding an item.If I right click the item,it will play a custom audio file.

 

How do I do something like this?

 

If you know where to put it,review the code here and reply to me where should I put it and what should I add into the code.

 

Code:

 

  Reveal hidden contents

 

Posted

Adding sounds is easy you simply put your audio files (format is .ogg) in assets/modid/sounds then all you have to do to have them loaded into the game is create a sounds.json file which you put in assets/modid it should look something like this

{
   "charge": {"category": "block","sounds": [{"name": "charge","stream": false}]},
   "discharge": {"category": "block","sounds": [{"name": "discharge","stream": false}]},
   "boom": {"category": "block","sounds": [{"name": "boom","stream": false}]},
   "beam": {"category": "block","sounds": [{"name": "beam","stream": false}]}
}

There are lots of tutorials about that if you look.

 

You can then play the sound like any vanilla sound. (There are plenty of examples in the vanilla code)

 

Edit:

Example. worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "modid:boom", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F);

I am the author of Draconic Evolution

Posted
  On 11/19/2014 at 9:34 AM, brandon3055 said:

Adding sounds is easy you simply put your audio files (format is .ogg) in assets/modid/sounds then all you have to do to have them loaded into the game is create a sounds.json file which you put in assets/modid it should look something like this

{
   "charge": {"category": "block","sounds": [{"name": "charge","stream": false}]},
   "discharge": {"category": "block","sounds": [{"name": "discharge","stream": false}]},
   "boom": {"category": "block","sounds": [{"name": "boom","stream": false}]},
   "beam": {"category": "block","sounds": [{"name": "beam","stream": false}]}
}

There are lots of tutorials about that if you look.

 

You can then play the sound like any vanilla sound. (There are plenty of examples in the vanilla code)

 

Edit:

Example. worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "modid:boom", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F);

So,if I want to add a sound of screams,like the ones ghasts have,I would add a sounds.json file and add this:

{
   "mh": {"category": "items","sounds": [{"name": "mh","stream": false}]},
  
}

 

and now how am I gonna register the file in my modid.java?

 

I'm a complete noob.

Posted
  On 11/21/2014 at 11:33 AM, rHaLeX_12 said:

and now how am I gonna register the file in my modid.java?

 

I'm a complete noob.

 

You don't have to.

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.

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.

Announcements



×
×
  • Create New...

Important Information

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