Jump to content

Playing audio on block placement


Recommended Posts

I have an issue with audio playback in my mod.


First I created a SoundEvents Class

public class SoundEvents
public void onSound(SoundLoadEvent e)
	URL u=DirtyMod.class.getResource(CommonProxy.FURNACE_SOUND);
		e.manager.soundPoolSounds.addSound(CommonProxy.FURNACE_SOUNDID, u);
		System.out.println(CommonProxy.FURNACE_SOUND+" registered as "+u.toString());
		System.out.println(CommonProxy.FURNACE_SOUND+" not found");


I then call it in my PreInit function with

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


I then created a packet handler. whenever I place a dirtfurnace the coords are transferred to the player placing the furnace.


The receiver end looks like the folowing:

public class PacketHandler implements IPacketHandler

public void onPacketData(INetworkManager manager,Packet250CustomPayload packet, Player player)
	int x,y,z;
	World w;
	EntityClientPlayerMP p;
	if (packet.channel.equals("DirtyNetwork"))
		DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
			p = (EntityClientPlayerMP) player;
			System.out.println("FURNACE!!! "+x+","+y+","+z);
		catch (IOException e)


the folowing constants are defined in my CommonProxy class:

public static final String FURNACE_SOUND= "/ayra/dirtyMod/furnace.ogg";
public static final String FURNACE_SOUNDID="ayra.dirtyMod.furnace";


My issue is, that the sound is not playing. The initialization function gets called. The output to the console looks like this:

/ayra/dirtyMod/furnace.ogg registered as file:/D:/Programme/Games/minecraft/develop/1.4.7/forge/mcp/eclipse/Minecraft/bin/ayra/dirtyMod/furnace.ogg

The ogg file exists at the specified location.

The placement function also gets called because the receiver function outputs to the console:

FURNACE!!! -43,74,308

There is no error printed to the console.

Does somebody know how to correctly do this? I also tried using a .wav file.

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.

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.


  • Create New...

Important Information

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