BiomesOPlenty/src/minecraft/biomesoplenty/handlers/SoundHandler.java

63 lines
1.9 KiB
Java
Raw Normal View History

2013-06-15 11:08:58 +00:00
package biomesoplenty.handlers;
import java.util.logging.Level;
import net.minecraftforge.client.event.sound.PlayStreamingEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
import cpw.mods.fml.client.FMLClientHandler;
2013-06-15 11:08:58 +00:00
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2013-06-15 11:08:58 +00:00
public class SoundHandler
{
2013-07-02 04:51:39 +00:00
static String[] recordSoundFiles = { "assets/BiomesOPlenty/audio/record/" + "bopdisc.ogg", "assets/BiomesOPlenty/audio/record/" + "bopdiscmud.ogg"};
static String[] soundFiles = { };
2013-06-15 11:08:58 +00:00
@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSoundLoad(SoundLoadEvent event)
2013-06-15 11:08:58 +00:00
{
for (String soundFile : soundFiles)
2013-06-15 11:08:58 +00:00
{
try
{
event.manager.soundPoolSounds.addSound(soundFile);
}
catch (Exception e)
2013-06-15 11:08:58 +00:00
{
FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BiomesOPlenty] Failed loading sound file: " + soundFile);
2013-06-15 11:08:58 +00:00
}
}
for (String recordSoundFile : recordSoundFiles)
{
try
{
event.manager.soundPoolStreaming.addSound(recordSoundFile);
}
catch (Exception e)
{
FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BiomesOPlenty] Failed loading sound file: " + recordSoundFile);
}
}
}
@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onPlayStreaming(PlayStreamingEvent event)
{
if (event.name == "bopdisc")
{
2013-07-02 04:51:39 +00:00
FMLClientHandler.instance().getClient().sndManager.playStreaming("assets.BiomesOPlenty.audio.record.bopdisc", (float) event.x + 0.5F, (float) event.y + 0.5F, (float) event.z + 0.5F);
}
else if (event.name == "bopdiscmud")
{
2013-07-02 04:51:39 +00:00
FMLClientHandler.instance().getClient().sndManager.playStreaming("assets.BiomesOPlenty.audio.record.bopdiscmud", (float) event.x + 0.5F, (float) event.y + 0.5F, (float) event.z + 0.5F);
}
2013-06-15 11:08:58 +00:00
}
}