本文整理汇总了Java中net.minecraftforge.client.event.sound.PlaySoundEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlaySoundEvent类的具体用法?Java PlaySoundEvent怎么用?Java PlaySoundEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlaySoundEvent类属于net.minecraftforge.client.event.sound包,在下文中一共展示了PlaySoundEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleHearingSounds
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void handleHearingSounds(PlaySoundEvent event) {
EntityPlayer p = Minecraft.getMinecraft().player;
if (p != null)
{
Tuple<SoundType, Double> result = getTypeFromSound(event.getName(), event.getSound());
if (p.getHeldItemMainhand().getItem() == this)
{
if (addSound(p.getHeldItemMainhand(), result.getFirst(), result.getSecond())){
PacketHandler.INSTANCE.sendToServer(new MessageCompositionUpdate(p.getUniqueID(),p.getHeldItemMainhand().getTagCompound(),true));
}
} else if (p.getHeldItemOffhand().getItem() == this) {
if (addSound(p.getHeldItemOffhand(), result.getFirst(), result.getSecond())){
PacketHandler.INSTANCE.sendToServer(new MessageCompositionUpdate(p.getUniqueID(),p.getHeldItemOffhand().getTagCompound(),false));
}
}
}
}
示例2: playSound
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent
public void playSound(PlaySoundEvent event){
World world = CrystalMod.proxy.getClientWorld();
if(world == null)return;
ISound sound = event.getSound();
//if(sound instanceof ITickableSound)return;
AxisAlignedBB bb = new AxisAlignedBB(sound.getXPosF(), sound.getYPosF(), sound.getZPosF(), sound.getXPosF(), sound.getYPosF(), sound.getZPosF()).expand(16, 16, 16);
List<TileSoundMuffler> mufflers = BlockUtil.searchBoxForTiles(world, bb, TileSoundMuffler.class, null);
for(TileSoundMuffler muffler : mufflers){
if(muffler.isSoundInList(sound.getSoundLocation())){
if(muffler.getVolume() <= 0.0f){
event.setResultSound(null);
} else {
event.setResultSound(new WrappedSound(event.getSound(), muffler.getVolume()));
}
break;
}
}
}
示例3: onMusicControl
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent
public void onMusicControl(PlaySoundEvent event)
{
ISound sound = event.getSound();
SoundCategory category = sound.getCategory();
if (category == SoundCategory.MUSIC)
{
if (this.mc.thePlayer != null && this.mc.thePlayer.dimension == AetherConfig.getAetherDimensionID())
{
if (!sound.getSoundLocation().toString().contains("aether_legacy") && (this.musicTicker.playingMusic() || !this.musicTicker.playingMusic()))
{
event.setResultSound(null);
return;
}
}
}
else if (category == SoundCategory.RECORDS)
{
this.musicTicker.stopMusic();
this.mc.getSoundHandler().stopSounds();
return;
}
}
示例4: playSound
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
/** Play or prevent sound and subtitle according to settings.
* This event catches some entity & all other sounds */
@SubscribeEvent
public static void playSound(PlaySoundEvent event) {
ISound sound = event.getSound();
SoundCategory category = SoundCategory.categorise(sound);
SoundResult result = categoryResults.get(category);
if (!result.playSound()) {
event.setResultSound(null);
}
if (result.showSubtitle()) {
guiSubtitles.addSubtitle(sound, Minecraft.getMinecraft()
.getSoundHandler().getAccessor(event.getSound()
.getSoundLocation()), result.getColour());
}
}
示例5: soundEvent
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void soundEvent(final PlaySoundEvent event) {
if (event.getSound() == null || event.getSound() instanceof ConfigSound)
return;
final String resource = event.getSound().getSoundLocation().toString();
if (this.soundsToBlock.contains(resource)) {
event.setResultSound(null);
return;
}
if (ModOptions.soundCullingThreshold <= 0)
return;
// Get the last time the sound was seen
final int lastOccurance = this.soundCull.get(resource);
if (lastOccurance == 0)
return;
final int currentTick = EnvironState.getTickCounter();
if ((currentTick - lastOccurance) < ModOptions.soundCullingThreshold) {
event.setResultSound(null);
} else {
this.soundCull.put(resource, currentTick);
}
}
示例6: supressExcessiveSound
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOW)
public void supressExcessiveSound(PlaySoundEvent event) {
// Basically, divide the volume by the number of events minus some threshold
Minecraft mc = Minecraft.getMinecraft();
if (mc.theWorld == null) {
present_tick = -100;
return;
}
if (event.result == null) return;
if (event.isCanceled()) return;
long now = mc.theWorld.getTotalWorldTime();
if (now != present_tick) {
present_tick = now;
event_count = 0;
}
if (event_count++ < max_event) return;
final double origVolume = event.result.getVolume();
final float newVolume = (float)(origVolume / Math.log(event_count) * logMax);
event.result = new ProxiedSound(event.result) {
@Override
public float getVolume() {
return newVolume;
}
};
}
示例7: onBGMusic
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBGMusic(PlaySoundEvent event)
{
if(event.getSound() != null && event.getSound().getCategory() != null && event.getSound().getCategory() == SoundCategory.MUSIC)
{
if(event.getManager().isSoundPlaying(iSound))
{
event.setResultSound(null);
}
else
{
iSound = PositionedSoundRecord.getMusicRecord(TFC_Sounds.TFCMUSIC);
event.setResultSound(iSound);
}
}
}
示例8: musicControl
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent
public void musicControl(PlaySoundEvent event) {
ISound sound = event.getSound();
SoundCategory category = sound.getCategory();
if (category == SoundCategory.MUSIC) {
if (!sound.getSoundLocation().toString().contains("kk") && MainConfig.client.sound.EnableCustomMusic) {
event.setResultSound(null);
return;
}
if (!sound.getSoundLocation().toString().contains("kk") && this.musicHandler.isPlaying() && MainConfig.client.sound.EnableCustomMusic) {
event.setResultSound(null);
return;
} else {
if (MainConfig.client.sound.EnableCustomMusic) {
musicHandler.stopSound(sound);
}
}
} else if (category == SoundCategory.RECORDS) {
this.musicHandler.stopMusic();
this.mc.getSoundHandler().stopSounds();
return;
}
}
示例9: 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
}
}
示例10: 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()));
}
}
}
}
}
示例11: playSoundEvent
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent
public void playSoundEvent (PlaySoundEvent event) {
if (event.getSound().getCategory() == SoundCategory.MUSIC && !event.getName().startsWith("music.essential_features")) {
ISound result = CustomMusic.PlayMusic(event.getSound());
event.setResultSound(result);
}
}
示例12: soundPlay
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent
public void soundPlay(@Nonnull final PlaySoundEvent e) {
if (e.getName().equals("entity.lightning.thunder")) {
final ISound sound = e.getSound();
final BlockPos pos = new BlockPos(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());
final ISound newSound = Sounds.THUNDER.createSound(pos).setVolume(ModOptions.thunderVolume);
e.setResultSound(newSound);
}
}
示例13: onEvent
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@Override
public void onEvent(PlaySoundEvent event) {
if (event.getSound().getCategory() == SoundCategory.MUSIC) {
if (this.stopSound)
event.setResultSound(null);
}
}
示例14: playSound
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
@SubscribeEvent
public void playSound(PlaySoundEvent event)
{
if (!(event.name.contains("ark_theme")) && mc.currentScreen instanceof GuiMainMenuOverride)
{
event.result = null;
}
}
示例15: onPlaySoundEvent
import net.minecraftforge.client.event.sound.PlaySoundEvent; //导入依赖的package包/类
/**
* Use the PlaySoundEvent to listen for bobber splashing
*
* @param event
*/
@SubscribeEvent
public void onPlaySoundEvent(PlaySoundEvent event) {
if (ModAutoFish.config_autofish_enable && SoundEvents.ENTITY_BOBBER_SPLASH.getSoundName() == event.getSound().getSoundLocation()) {
_autoFish.onBobberSplashDetected(event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF());
}
}