Jump to content

[Solved] Sound won't work, I've used multiple methods shown elsewhere


xFyreStorm

Recommended Posts

EDIT: SOLVED! Using worldObj.playSound clientside no longer seems to play sounds, and must be used serverside. Before hand I only played sounds clientside, which is why it wasn't working even when set up properly.

 

Below is what I'm using in my ClientProxy to register and play sounds, and I register it under my main mod file. I've checked multiple times and all the methods are, in fact, being called, and the correct file names are being printed. I'm getting absolutely no errors and, as far as I can tell, I have everything set up as I'm supposed to. I wasn't going to ask here, but this is literally the last thing I need to fix to update my mod to 1.6.2, I don't really have the time to mess around with it since I'm working on other non-MC projects, and no matter what I try it doesn't work. All of my textures work 100%, but with sounds, nothing.

 

My sounds are under assets/borderlands/sound, and I've also tried with other directories, and between sound and sounds.

 

I just can't see what I'm doing wrong when comparing to other people with the same problem. I've used paulscode's SoundSystem in some games of my own, and am half tempted just to load sounds my own way if this persists much longer.  :-\

 

    public static String[] sounds = {"gunshot", "reload", "bullethit", "shock", "shieldrecharge", "rocket", "cashregister"};

    @ForgeSubscribe
    public void onSound(SoundLoadEvent event) {
        for(String s : sounds) {
        	//I've also tried :sound/ and :sounds/ before the file name, using manager.soundPoolSounds, as well as converting sounds and extensions to .ogg
        	event.manager.addSound("borderlands:" + s + ".wav");
        }
    }

    @Override
    public void register() {
        MinecraftForge.EVENT_BUS.register(this);
    }

    @Override
    public void playSound(Entity par1EntityLiving, int sound) {
        //As far as I can tell, no extensions here, correct? I've also tried the other playSound methods.
    	if(sound < sounds.length && sound >= 0) {par1EntityLiving.worldObj.playSoundAtEntity(par1EntityLiving, "borderlands:" + sounds[sound], 1.0F, 1.0F);}
    }

 

While I'm asking, where are pack.mcmeta's supposed to go? I've placed it in just about every directory, but eclipse just won't detect it. I know they aren't apparently needed, but I'd like to include it if possible.

 

Thanks in advance and please ask if you need anything else provided.

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

 

package medieval.medievalsounds;

import medieval.Medieval;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;

public class Fireshot_Sound 

{

	@ForgeSubscribe
    public void onSound(SoundLoadEvent event)
    {
        try 
        {
        	event.manager.addSound("medieval:fireshot1.wav");
        	event.manager.addSound("medieval:fireshot2.wav");
        	event.manager.addSound("medieval:fireshot3.wav");
        }
        catch (Exception e)
        {
            System.err.println("Fire sounds error");
        }

    }
}

 

use it like i do but this way youd have to make a class for each different item sound register the sound in your proxy and when you want to call it add this

 

par2World.playSoundAtEntity(par3EntityPlayer, "medieval:fireshot", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

the only problem i have is that some sound files will play but other not might you know the reason

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

I saw your solution earlier in another thread as well, but still nothing. I can only guess it has something to do with how I'm referencing the files, but like I said, I've tried with :sound/, :sounds/, changing borderlands to minecraft, etc. I wish it'd at least give some sort of error telling me what I'm doing wrong. They worked totally fine in 1.5, so I don't think it has anything to do with the files themselves. :-\

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

ok im going to help you as much as i can cause i took 2 weeks to finally get to the solution and i want to be nice :)

 

First my sound class is registered in proxyclient this way

 

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

 

i make a class for each different sound so it wont be messy i dont know if you have like reload sounds, shoot sounds, etc on the same class so if you do make a class for each one

 

secondly when adding the sound its like this

package medieval.medievalsounds;

import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;

public class Fireshot_Sound 

{

	@ForgeSubscribe
    public void onSound(SoundLoadEvent event)
    {
        try 
        {
        	event.manager.addSound("medieval:fireshot1.wav");
        	event.manager.addSound("medieval:fireshot2.wav");
        	event.manager.addSound("medieval:fireshot3.wav");
        }
        
        catch (Exception e)
        {
            System.err.println("Fire sounds error");
        }

    }
}

medieval is my modid and fireshot1,fireshot2,fireshot3 my soundfiles

so they must be in

\forge\mcp\src\minecraft\assets\medieval\sound

 

now when you want it to make the sound, in the item class entity whatever you have to call it like this

par2World.playSoundAtEntity(par3EntityPlayer, "medieval:fireshot", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

 

now i dont know if you know but when calling it you can see i have "medieval:fireshot" so like i said medieval is my modid and when you want your sound to play it must be fireshot, not fireshot2, fireshot1,etc because this loads randomly the sounds and takes the numbers out not sure you understood that part lol dont really know how to explain it.

 

 

if this worked for you please tell me :)

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

Just tried it, and still nothing, no error, no sound. I'll probably just take some time and make my own sound loader, it'll give me more flexibility anyhow. But if anyone has any other suggestions on things to try, feel free to tell me. Like I said, I've tried most of the suggestions in other threads already. :-\

 

Sound location:

\forge\mcp\src\minecraft\assets\borderlands\sound

 

How I'm registering it (successfully prints to console if I add checks to the loading code):

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

 

Sound class:

package assets.borderlands;

import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;

public class Gunshot_Sound {
@ForgeSubscribe
public void onSound(SoundLoadEvent event)
{
	try 
	{
		event.manager.addSound("borderlands:gunshot1.wav"); //renamed file to gunshot1 just to make sure it didn't have anything to do with random sounds screwing up or something
	}

	catch (Exception e)
	{
		System.err.println("Gunshot sounds error");
	}

}
}

 

Code to play sound:

player.worldObj.playSoundAtEntity(player, "borderlands:gunshot", 1.0F, 1.0F);

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

add a prinln after  event.manager.addSound("medieval:fireshot3.wav");

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

Prints fine, just as I've said it has. I'm either playing the sound under the wrong conditions, or it's just plain not playing. Will ANY worldObj work for playing the new sound system? Like I said, in 1.5, all these sounds worked perfectly fine in the situations I tried to use them in. There are literally no pointers to what could be going wrong.

 

Class with check:

package assets.borderlands;

import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;

public class Gunshot_Sound {
@ForgeSubscribe
public void onSound(SoundLoadEvent event)
{
	try 
	{
		event.manager.addSound("borderlands:gunshot1.wav");
		System.out.println("Check.");
	}

	catch (Exception e)
	{
		System.err.println("Gunshot sounds error");
	}

}
}

 

Console:

2013-07-26 19:52:36 [iNFO] [sTDOUT] Starting up SoundSystem...
2013-07-26 19:52:36 [iNFO] [sTDOUT] Check.
2013-07-26 19:52:36 [iNFO] [sTDOUT] Initializing LWJGL OpenAL
2013-07-26 19:52:36 [iNFO] [sTDOUT]     (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
2013-07-26 19:52:36 [iNFO] [sTDOUT] OpenAL initialized.

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

i dont know if this will help you find something you are missing or something i forgot to tell you lol but look how i call it here when onitemrightclick event

 

public ItemStack onItemRightClick(ItemStack ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  {
      if (!par3EntityPlayer.capabilities.isCreativeMode)
      {
          --ItemStack.stackSize;
      }

      par2World.playSoundAtEntity(par3EntityPlayer, "medieval:fireshot", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

      if (!par2World.isRemote)
      {
          par2World.spawnEntityInWorld(new Rubybolt_Entity(par2World, par3EntityPlayer));
      }
   
      return ItemStack;
  }

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

Wow, I did not expect that to work! Meaning: it worked! I guess it DOES matter what situation you use it in the new system.

 

This

par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer, "borderlands:gunshot", 1.0F, 1.0F);

And this

par2World.playSoundAtEntity(par3EntityPlayer, "borderlands:gunshot", 1.0F, 1.0F);

 

Worked completely fine under onItemRightClick, with my old loading method and your version, which means I'm probably going to have to go through all the places I use sound and try and find a worldObj and/or entity that will correctly play the sound. I at least know the sounds WILL play in 1.6.2 now, I just need to figure out under what conditions, since the ones I used to use them in aren't working any longer.

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

hey can i get my turn to ask a question :P

 

Edit: Also im happy to know that it worked :D

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

hey can i get my turn to ask a question :P

 

Edit: Also im happy to know that it worked :D

 

Go right ahead.  :)

 

And although I know sounds will play, I've still got my work cut out for me making it actually work in the situations I want it to. Because a lot of sounds don't play under an item. I'll be sure to leave anything I find out here though, for anyone else with the same problem.

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

well i get a problem on some sounfiles that some play some dont and i dont know if it is bit rate or anything like tha i have a sounfile original, that works fine when i load it in minecraft but its to slow and long so what i did was edit the sound to make it faster and shorter but i just get an error on loading when i call the sound in game like the example i gave to you of my wand when i shoot it no sound comes oout and get this error

 

2013-07-26 18:38:17 [iNFO] [sTDOUT] Error in class 'CodecWav'
2013-07-26 18:38:17 [iNFO] [sTDOUT]     Unsupported audio format in method 'initialize'
2013-07-26 18:38:17 [iNFO] [sTDOUT]     ERROR MESSAGE:
2013-07-26 18:38:17 [iNFO] [sTDOUT]         could not get audio input stream from input stream
2013-07-26 18:38:17 [iNFO] [sTDOUT]     STACK TRACE:
2013-07-26 18:38:17 [iNFO] [sTDOUT]         javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
2013-07-26 18:38:17 [iNFO] [sTDOUT]         paulscode.sound.codecs.CodecWav.initialize(CodecWav.java:128)
2013-07-26 18:38:17 [iNFO] [sTDOUT]         paulscode.sound.libraries.LibraryLWJGLOpenAL.loadSound(LibraryLWJGLOpenAL.java:392)
2013-07-26 18:38:17 [iNFO] [sTDOUT]         paulscode.sound.libraries.LibraryLWJGLOpenAL.newSource(LibraryLWJGLOpenAL.java:640)
2013-07-26 18:38:17 [iNFO] [sTDOUT]         paulscode.sound.SoundSystem.CommandNewSource(SoundSystem.java:1800)
2013-07-26 18:38:17 [iNFO] [sTDOUT]         paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2415)
2013-07-26 18:38:17 [iNFO] [sTDOUT]         paulscode.sound.CommandThread.run(CommandThread.java:121)
2013-07-26 18:38:17 [iNFO] [sTDOUT] Error in class 'CodecWav'
2013-07-26 18:38:17 [iNFO] [sTDOUT]     Audio input stream null in method 'readAll'
2013-07-26 18:38:17 [iNFO] [sTDOUT] Error in class 'LibraryLWJGLOpenAL'
2013-07-26 18:38:17 [iNFO] [sTDOUT]     Sound buffer null in method 'loadSound'
2013-07-26 18:38:17 [iNFO] [sTDOUT] Error in class 'LibraryLWJGLOpenAL'
2013-07-26 18:38:17 [iNFO] [sTDOUT]     Source 'sound_55' was not created because an error occurred while loading medieval:fireshot2.wav
2013-07-26 18:38:17 [iNFO] [sTDOUT] Error in class 'LibraryLWJGLOpenAL'
2013-07-26 18:38:17 [iNFO] [sTDOUT]     Source 'sound_55' not found in method 'play'

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

How exactly are you editing the file? My guess is when you save it as the shorter and faster file, you're changing the codec, which is why you get the "Unsupported audio format in method 'initialize'". It's trying to load it up as a .wav, when in reality the file isn't a .wav, or at least the kind of .wav it's looking for. The error itself is specifically a paulscode Sound System error, and I've definitely ran in to it before when trying to set up the Sound System for one of my own games.

 

And I've come to the conclusion that worldObj.playSound doesn't work clientside any longer. If you want to play sounds, it must be done from serverside. At least when using playSound from worldObjs.

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

well i use audacity and just change speed and save it , it all sounds ok when i open the edited file on any app that reproduces it but im not sure what im doing wrong :/

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

What are you using to change the speed? Are you just using Effect -> Change Speed/Tempo? Because if you're doing that, and saving it as just a plain .wav, it should be working just fine. You could also try saving it as a .ogg and seeing if that'll work. I'm not really an expert in this stuff by the way, so your guess might be as good as mine.  :P

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

lol no i mean i use a program called audacity to change the speed of the track and then export it lol

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

Link to comment
Share on other sites

I know, I meant, in Audacity, is all your doing to change the speed 'Effect -> Change Speed/Tempo', at the top. Because that's probably the best way to change it. My guess is you probably are, in which case, it should be working. :P

Developer of:

Ice Cream Sandwich Creeper Mod - http://www.minecraftforum.net/topic/1545610-

Borderlands Weapon Mod (WIP) - http://www.minecraftforum.net/topic/1661741-

The "You Will Die" Mod - http://www.minecraftforum.net/topic/1926696-

Link to comment
Share on other sites

i hate it when im supposed to be in the right track but still getting nowhere :(

I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me :)

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.