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


Java PlaySoundEvent类代码示例

本文整理汇总了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));
			}
		}
	}
}
 
开发者ID:TeamMelodium,项目名称:Melodium,代码行数:20,代码来源:ItemCompositionPaper.java

示例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;
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:20,代码来源:ClientEventHandler.java

示例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;
	}
}
 
开发者ID:Modding-Legacy,项目名称:Aether-Legacy,代码行数:27,代码来源:AetherMusicHandler.java

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

示例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);
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:27,代码来源:SoundCullHandler.java

示例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;
        }
    };
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:26,代码来源:MiscClientProxy.java

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

示例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;
    }
}
 
开发者ID:Wehavecookies56,项目名称:Kingdom-Keys-Re-Coded,代码行数:24,代码来源:ClientEventHandler.java

示例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
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:26,代码来源:BlockSoundSuppress.java

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

示例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);
    }
}
 
开发者ID:williambl,项目名称:EssentialFeatures,代码行数:8,代码来源:ClientEventHandler.java

示例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);
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:10,代码来源:SoundEffectHandler.java

示例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);
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:8,代码来源:CommandMusic.java

示例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;
	}
}
 
开发者ID:Archiving,项目名称:ARKCraft-Code,代码行数:9,代码来源:CoreClientEventHandler.java

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


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