本文整理汇总了Java中net.minecraftforge.client.event.sound.PlaySoundSourceEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlaySoundSourceEvent类的具体用法?Java PlaySoundSourceEvent怎么用?Java PlaySoundSourceEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlaySoundSourceEvent类属于net.minecraftforge.client.event.sound包,在下文中一共展示了PlaySoundSourceEvent类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSound
import net.minecraftforge.client.event.sound.PlaySoundSourceEvent; //导入依赖的package包/类
@SubscribeEvent
public void onSound(PlaySoundSourceEvent evt) {
if (enabled && soundQueue.size() < MAX_PARTICLES) {
switch (evt.getSound().getCategory()) {
case BLOCKS:
soundQueue.offer(new SoundSource(evt.getSound().getXPosF(), evt.getSound().getYPosF(), evt.getSound().getZPosF(), evt.getSound().getVolume(), false));
break;
case AMBIENT:
case HOSTILE:
case NEUTRAL:
case PLAYERS:
soundQueue.offer(new SoundSource(evt.getSound().getXPosF(), evt.getSound().getYPosF(), evt.getSound().getZPosF(), evt.getSound().getVolume(), true));
break;
default:
break;
}
}
}
示例2: playSound
import net.minecraftforge.client.event.sound.PlaySoundSourceEvent; //导入依赖的package包/类
/**
* Plays a sound. Args: soundName, x, y, z, volume, pitch, fadeOutTime
*/
public static String playSound(String par1Str, float par2, float par3,
float par4, float par5, float par6)
{
SoundPoolEntry soundpoolentry = sndManager.soundPoolSounds
.getRandomSoundFromSoundPool(par1Str);
soundpoolentry = SoundEvent.getResult(new PlaySoundEvent(sndManager,
soundpoolentry, par1Str, par2, par3, par4, par5, par6));
if (soundpoolentry != null && par5 > 0.0F)
{
latestSoundID = 256 + ((latestSoundID + 1) % 256);
String s1 = "sound_" + latestSoundID;
float f5 = 16.0F;
if (par5 > 1.0F)
{
f5 *= par5;
}
sndManager.sndSystem.newSource(par5 > 1.0F, s1,
soundpoolentry.getSoundUrl(),
soundpoolentry.getSoundName(), false, par2, par3, par4, 2,
f5);
if (par5 > 1.0F)
{
par5 = 1.0F;
}
sndManager.sndSystem.setPitch(s1, par6);
sndManager.sndSystem.setVolume(s1, par5
* Minecraft.getMinecraft().gameSettings.soundVolume);
MinecraftForge.EVENT_BUS.post(new PlaySoundSourceEvent(sndManager,
s1, par2, par3, par4));
sndManager.sndSystem.play(s1);
return s1;
}
return null;
}