Jump to content

Recommended Posts

Posted

Hello guys,

 

How can you add custom sounds with 1.7.10?

 

I have no problem playing a vanilla sound (for my mod : when an item is used) but adding sound seems a different story.

Code like :

 

@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSoundLoad(SoundLoadEvent event) {
Minecraft mc = Minecraft.getMinecraft();
event.manager.soundPoolSounds.addSound("lnl/mod/tutorial/metalhit.ogg",
new File(mc.mcDataDir, "resources/mod/tutorial/metal_hit.ogg"));

is deprecated and even when adapting (@ForgeSubscribe -> @SubscribeEvent, and so on), addSound seems to have dissappeared

 

Going through javadoc and forgeSrc-1.7.10-10.13.0.1180-sources.jar does not help me to understand.

 

BTW, I'm quite new to forge, what is the equivalent of RTFM? :)

I find many answers through forums, but the wiki tutorials are (it seems) quite basic and sometimes out of date.

 

Thanks,

JL

Posted

Found how to do it....

 

For the record, I used :

http://www.minecraftforge.net/wiki/MrGReapers_tutorials/1.7.2_sound_tutorial

 

As the url lacks working examples, here is one :

The mod is "jlmod"

 

- You must create a sound folder \resources\assets\jlmod\sounds

- Inside, ogg files.

-> In this example, "sonar.ogg"

 

You must create an sounds.json file in \resources\assets\jlmod

Content :

{
"custom_sound": {"category": "ambient","sounds": [{"name": "sonar","stream": false}]}
}

 

You can then play the sound with something like :

world.playSound(posX, posY, posZ, "jlmod:mineral_detector_sound", 1.0F, 0.6F, false);

  • Like 2
  • 2 years later...
  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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