Jump to content

Adding sound not working


Dawars
 Share

Recommended Posts

Hi,

I followed this tutorial but I can't hear any sound :(

http://www.minecraftforge.net/wiki/Sounds_For_Forge_1.3.2

 

Please help me find out what's wrong!

 

My code:

Item:

package dimension;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class ItemPortalPlacer extends Item {
public ItemPortalPlacer(int par1) {
	super(par1);
	setCreativeTab(CreativeTabs.tabTools);
}

public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
	world.playSoundEffect((double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, "sound.FluteTrack", 1.0F, world.rand.nextFloat() * 0.1F + 0.9F);
	return true;

}
}

 

Sound handler:

package dimension;

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

public class YourMod_EventSounds {
    @ForgeSubscribe
    public void onSound(SoundLoadEvent event)
    {
        try 
        {
            event.manager.soundPoolSounds.addSound("/sound/FluteTrack.ogg", Main.class.getResource("/sound/FluteTrack.ogg"));            
            System.out.println("Managed to register one or more sounds.");

        } 
        catch (Exception e)
        {
            System.err.println("Failed to register one or more sounds.");
        }
    }
}

 

Main mod file:

	@PreInit
public void preInit(FMLPreInitializationEvent event){
	MinecraftForge.EVENT_BUS.register(new YourMod_EventSounds());
}

 

The sound file is located inside mcp in jars\bin\sound

Here is the sound file:

http://www.mediafire.com/listen/fp2q40tewvrbpre/FluteTrack.ogg

Link to comment
Share on other sites

I changed my code a little bit and now it gives this error:

Error in class 'LibraryLWJGLOpenAL'
2013-06-08 11:22:28 [iNFO] [sTDOUT]     Unable to open file 'flute/track.ogg' in method 'loadSound'
2013-06-08 11:22:28 [iNFO] [sTDOUT] Error in class 'LibraryLWJGLOpenAL'
2013-06-08 11:22:28 [iNFO] [sTDOUT]     Source 'sound_2' was not created because an error occurred while loading flute/track.ogg
2013-06-08 11:22:28 [iNFO] [sTDOUT] Error in class 'LibraryLWJGLOpenAL'
2013-06-08 11:22:28 [iNFO] [sTDOUT]     Source 'sound_2' not found in method 'play'

 

I relocated the file to jars/bin/item/flute/track.ogg

 

The modified code:

Item:

world.playSoundEffect((double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, "flute.track", 1.0F, world.rand.nextFloat() * 0.1F + 0.9F);

 

SoundHandler:

event.manager.soundPoolSounds.addSound("flute/track.ogg", Main.class.getResource("/item/flute/track.ogg"));

 

I hope this message helps

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
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.

 Share



×
×
  • Create New...

Important Information

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