Jump to content

new way to add sounds?


etopsirhc

Recommended Posts

so u mean like

SoundLoadEvent s = new SoundLoadEvent(new SoundHandler());

 

SoundHandler.java

package etopsirhc.mods.tremmorCraft;

import java.io.File;

import net.minecraft.src.SoundManager;

public class SoundHandler extends SoundManager {

public SoundHandler(){
	super.soundPoolSounds.addSound("gun.click",new File("/etopsirhc/mods/tremmorCraft/gun/click.ogg"));
}
}

 

i seriously have no clue as how to load my own sounds , i've tried everything i could think of including using this in the client proxy

FMLClientHandler.instance().getClient().sndManager.addSound("gun.click", new File("/path/file.ogg"))

 

Link to comment
Share on other sites

hey , cut me a little slack , i'm relatively new to modding and b4 forge 4 came out i'd never used it XP

but that said i think i got  most of it right now , i just cant get it working right.

 

in my preinit method i register the event handler class and have a soundLoadEvent handler setup , but even after setting it all up i get nothing.

i've tried both ogg and wav formats . and while the playSoundAtEntity event is called for the right sound name , the sound fails to play.

 

 

Link to comment
Share on other sites

I'll show you how I did it.

 

In your common and client proxy (I'm assuing you have these. If you don't, read this tutorial) add a method for registering sounds, I called mine registerSounds. Inside registerSounds in your client proxy, put this:

MinecraftForge.EVENT_BUS.register(new ClientEvents());

replace ClientEvents with the class you're about to set up with your sound register stuff.

 

Make your new ClientEvents class inside the client. Put this in it:

package etopsirhc.mods.tremmorCraft;

import net.minecraftforge.client.event.sound.*;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraft.src.*;

public class ClientEvents
{

    @ForgeSubscribe
public void onSoundsLoaded(SoundLoadEvent event)
{
    	SoundManager manager = event.manager;
        String [] soundFiles = {
                "gun/click.ogg"}
        	for (int i = 0; i < soundFiles.length; i++){
        		manager.soundPoolSounds.addSound(soundFiles[i], this.getClass().getResource("/etopsirhc/mods/tremmorCraft/" + soundFiles[i]));
        	}
}
}

 

finally, add

proxy.registerSounds();

to your pre initialization method in your mod class, and that should be it. I only just found out how to do this, so I thought I'd share it with you. If you ever want to add more sounds, just add them to the list.

 

 

I'm probably doing this in a really inefficient way, but I'm a noob, so cut me some slack :P

Link to comment
Share on other sites

YES!!!! TY !! =D

 

after i got it working i changed it slightly from what you did

i registered the event listner class in the preinit and set the @client side only on the sound load event so that i can register any event in there but only use the sounds on the client side

pretty much same as what you have , but i can skip adding a second event listner for the server side by doing so

Link to comment
Share on other sites

Thats because we have a audiomod compatibility layer, and if you put your things inside the resources folder, you're doing it wrong and creating nothing but useless hassle for your end user.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Thats because we have a audiomod compatibility layer, and if you put your things inside the resources folder, you're doing it wrong and creating nothing but useless hassle for your end user.

 

So when I'm using the soundmanager, I can just put my soundfiles into my mod.zip?

 

Awesome :)

Link to comment
Share on other sites

Yes, thats one of the main points, EVERY mod should be a SINGLE jar and the end user should ONLY have to put it in the mods folder.

If you have install instructions that are more complicated then that, you're doing it wrong.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Yes, thats one of the main points, EVERY mod should be a SINGLE jar and the end user should ONLY have to put it in the mods folder.

If you have install instructions that are more complicated then that, you're doing it wrong.

Unless your mod is like NEI.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

Yes, thats one of the main points, EVERY mod should be a SINGLE jar and the end user should ONLY have to put it in the mods folder.

If you have install instructions that are more complicated then that, you're doing it wrong.

Unless your mod is like NEI.

Nope, even then, NEI technically doesn't need to be in the jar, It can use any of the methods that FML/Forge provides to do what it wants.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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.

Announcements



×
×
  • Create New...

Important Information

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