本文整理汇总了Java中net.minecraftforge.client.event.sound.PlaySoundEvent.getResultSound方法的典型用法代码示例。如果您正苦于以下问题:Java PlaySoundEvent.getResultSound方法的具体用法?Java PlaySoundEvent.getResultSound怎么用?Java PlaySoundEvent.getResultSound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.client.event.sound.PlaySoundEvent
的用法示例。
在下文中一共展示了PlaySoundEvent.getResultSound方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlaySound
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySound(PlaySoundEvent event) {
if (event.getResultSound() == null || event.getResultSound() instanceof ITickableSound || ModCyclic.proxy.getClientWorld() == null) {
return;
} //long term/repeating/music
ISound sound = event.getResultSound();
List<BlockPos> blocks = UtilWorld.findBlocks(ModCyclic.proxy.getClientWorld(), new BlockPos(sound.getXPosF(), sound.getYPosF(), sound.getZPosF()), this, RADIUS);
if (blocks == null || blocks.size() == 0) {
return;
}
try {//WARNING": DO NOT USE getVolume anywhere here it just crashes
//we do use it inside the sound class, but the engine callss tat later on, and our factor is tacked in
SoundVolumeControlled newSound = new SoundVolumeControlled(sound);
//the number of nearby blocks informs how much we muffle the sound by
float pct = ((float) VOL_REDUCE_PER_BLOCK) / 100F;
newSound.setVolume(pct / blocks.size());
event.setResultSound(newSound);
}
catch (Exception e) {
ModCyclic.logger.error("Error trying to detect volume of sound from 3rd party ");
ModCyclic.logger.error(e.getMessage());
e.printStackTrace();//getVolume() in naive Positioned sound event gives NPE
}
}
示例2: onSoundEvent
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onSoundEvent(PlaySoundEvent evt) {
if (SoundEventsManager.isPlayerWearingGlasses()) {
final ISound sound = evt.getResultSound();
if (sound != null) {
// NOTE do not remove, otherwise sound.getVolume will throw NPE
if (sound.createAccessor(evt.getManager().sndHandler) != null) {
final IDrawableIcon icon = icons.getIcon(sound.getSoundLocation());
synchronized (events) {
events.add(new SoundEvent(sound, icon, Math.log(sound.getVolume() + 1), sound.getPitch()));
}
}
}
}
}
示例3: playSound
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入方法依赖的package包/类
public static ISound playSound(SoundManager manager, ISound sound)
{
PlaySoundEvent e = new PlaySoundEvent(manager, sound);
MinecraftForge.EVENT_BUS.post(e);
return e.getResultSound();
}