Posted June 7, 201312 yr 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 http://i.imgur.com/RvFDhZj.gif[/img]
June 8, 201312 yr Author I used the same code to play vanilla registered music and it works but when I try to play my own music it doesn't give an error message but no sound http://i.imgur.com/RvFDhZj.gif[/img]
June 8, 201312 yr Author 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 http://i.imgur.com/RvFDhZj.gif[/img]
June 8, 201312 yr Author Ok, I solved it. It wasn't that easy though... This helped a lot: http://www.minecraftforge.net/forum/index.php?topic=3038.0 http://i.imgur.com/RvFDhZj.gif[/img]
June 8, 201312 yr QUADRA-POST! Sorry about the lack of help; I don't know anything about sounds. BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
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.