BiomesOPlenty/common/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
{
static String[] recordSoundFiles = { "biomesoplenty:bopdisc.ogg", "biomesoplenty:bopdiscmud.ogg" };
2013-08-30 11:38:54 +00:00
static String[] soundFiles = { "biomesoplenty:mob/phantom/say.ogg", "biomesoplenty:mob/phantom/hurt.ogg", "biomesoplenty:mob/phantom/death.ogg" };
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
{
2013-09-21 22:51:52 +00:00
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
{
2013-09-21 22:51:52 +00:00
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")
{
FMLClientHandler.instance().getClient().sndManager.playStreaming("biomesoplenty:bopdisc", (float) event.x + 0.5F, (float) event.y + 0.5F, (float) event.z + 0.5F);
}
else if (event.name == "bopdiscmud")
{
FMLClientHandler.instance().getClient().sndManager.playStreaming("biomesoplenty:bopdiscmud", (float) event.x + 0.5F, (float) event.y + 0.5F, (float) event.z + 0.5F);
}
}
2013-06-15 11:08:58 +00:00
}