当前位置: 首页>>代码示例>>Java>>正文


Java PlaySoundEvent.getResultSound方法代码示例

本文整理汇总了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
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:26,代码来源:BlockSoundSuppress.java

示例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()));
				}
			}
		}
	}
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:17,代码来源:SoundEventsManager.java

示例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();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:7,代码来源:ForgeHooksClient.java


注:本文中的net.minecraftforge.client.event.sound.PlaySoundEvent.getResultSound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。