Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • 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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.