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


Java ISound类代码示例

本文整理汇总了Java中net.minecraft.client.audio.ISound的典型用法代码示例。如果您正苦于以下问题:Java ISound类的具体用法?Java ISound怎么用?Java ISound使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ISound类属于net.minecraft.client.audio包,在下文中一共展示了ISound类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: playRecord

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
public void playRecord(String recordName, BlockPos blockPosIn)
{
    ISound isound = (ISound)this.mapSoundPositions.get(blockPosIn);

    if (isound != null)
    {
        this.mc.getSoundHandler().stopSound(isound);
        this.mapSoundPositions.remove(blockPosIn);
    }

    if (recordName != null)
    {
        ItemRecord itemrecord = ItemRecord.getRecord(recordName);

        if (itemrecord != null)
        {
            this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
        }

        PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.create(new ResourceLocation(recordName), (float)blockPosIn.getX(), (float)blockPosIn.getY(), (float)blockPosIn.getZ());
        this.mapSoundPositions.put(blockPosIn, positionedsoundrecord);
        this.mc.getSoundHandler().playSound(positionedsoundrecord);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:RenderGlobal.java

示例2: playRecord

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
public void playRecord(@Nullable SoundEvent soundIn, BlockPos pos)
{
    ISound isound = (ISound)this.mapSoundPositions.get(pos);

    if (isound != null)
    {
        this.mc.getSoundHandler().stopSound(isound);
        this.mapSoundPositions.remove(pos);
    }

    if (soundIn != null)
    {
        ItemRecord itemrecord = ItemRecord.getBySound(soundIn);

        if (itemrecord != null)
        {
            this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
        }

        PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.getRecordSoundRecord(soundIn, (float)pos.getX(), (float)pos.getY(), (float)pos.getZ());
        this.mapSoundPositions.put(pos, positionedsoundrecord);
        this.mc.getSoundHandler().playSound(positionedsoundrecord);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:RenderGlobal.java

示例3: soundPlay

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
public void soundPlay(ISound soundIn, SoundEventAccessor accessor)
{
    if (accessor.getSubtitle() != null)
    {
        String s = accessor.getSubtitle().getFormattedText();

        if (!this.subtitles.isEmpty())
        {
            for (GuiSubtitleOverlay.Subtitle guisubtitleoverlay$subtitle : this.subtitles)
            {
                if (guisubtitleoverlay$subtitle.getString().equals(s))
                {
                    guisubtitleoverlay$subtitle.refresh(new Vec3d((double)soundIn.getXPosF(), (double)soundIn.getYPosF(), (double)soundIn.getZPosF()));
                    return;
                }
            }
        }

        this.subtitles.add(new GuiSubtitleOverlay.Subtitle(s, new Vec3d((double)soundIn.getXPosF(), (double)soundIn.getYPosF(), (double)soundIn.getZPosF())));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:GuiSubtitleOverlay.java

示例4: playSound

import net.minecraft.client.audio.ISound; //导入依赖的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

示例5: onMusicControl

import net.minecraft.client.audio.ISound; //导入依赖的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

示例6: playSound

import net.minecraft.client.audio.ISound; //导入依赖的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

示例7: addSubtitle

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
/** Adds a subtitle to the list in the given colour. */
public void addSubtitle(ISound sound, SoundEventAccessor accessor,
        int colour) {

    if (sound != null && accessor.getSubtitle() != null) {
        
        String s = accessor.getSubtitle().getFormattedText();

        if (!this.subtitles.isEmpty()) {
            
            for (Subtitle subtitle : this.subtitles) {
                
                if (subtitle.getString().equals(s)) {
                    
                    subtitle.refresh(new Vec3d(sound.getXPosF(),
                            sound.getYPosF(), sound.getZPosF()));
                    return;
                }
            }
        }

        this.subtitles.add(new Subtitle(s, new Vec3d(sound.getXPosF(),
                sound.getYPosF(), sound.getZPosF()), colour));
    }
}
 
开发者ID:JayAvery,项目名称:accesstweaks,代码行数:26,代码来源:Sounds.java

示例8: PlayMusic

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
public static ISound PlayMusic (ISound musicIn) {
	Minecraft mc = Minecraft.getMinecraft();
	WorldClient world = mc.world;
	EntityPlayerSP player = mc.player;

	if (rand.nextFloat() > 0.5) {
		return musicIn;
	}
	
	if (world == null) {
		return musicIn;
	} else {
		switch (Biome.getIdForBiome(world.getBiome(player.getPosition()))) {
		case OCEAN:
	        musicIn = PositionedSoundRecord.getMusicRecord(ModSound.OCEAN);
			return musicIn;
		case DEEP_OCEAN:
	        musicIn = PositionedSoundRecord.getMusicRecord(ModSound.OCEAN);
			return musicIn;
		default:
			return musicIn;
		}
	}
}
 
开发者ID:williambl,项目名称:EssentialFeatures,代码行数:25,代码来源:CustomMusic.java

示例9: BasicSound

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
public BasicSound(@Nonnull final ResourceLocation soundResource, @Nonnull final SoundCategory cat) {
	super(soundResource, cat);

	this.volumeScale = DEFAULT_SCALE;

	this.volume = 1F;
	this.pitch = 1F;
	this.setPosition(0, 0, 0);
	this.repeat = false;
	this.repeatDelay = 0;
	this.attenuationType = ISound.AttenuationType.LINEAR;

	// Sounds are not routed by default. Need to be turned on
	// in a derived class or set via setter.
	this.route = false;

	super.sound = SoundHandler.MISSING_SOUND;

}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:20,代码来源:BasicSound.java

示例10: playSound

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
@Override
public void playSound(@Nonnull final ISound sound) {
	if (sound != null) {
		try {
			if (sound instanceof BasicSound<?>)
				this.playSound((BasicSound<?>) sound);
			else if (!ModEnvironment.ActualMusic.isLoaded() || sound.getCategory() != SoundCategory.MUSIC)
				super.playSound(sound);
			
			// Flush - avoid that pesky missing sound issue due to async
			getSoundSystem().CommandQueue(null);
		} catch (final Throwable t) {
			// Stop more weirdness from a crashed sound system
		}
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:17,代码来源:SoundManagerReplacement.java

示例11: diagnostics

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOW)
public void diagnostics(final DiagnosticEvent.Gather event) {
	final TObjectIntHashMap<String> counts = new TObjectIntHashMap<String>();

	final Iterator<Entry<String, ISound>> iterator = this.playingSounds.entrySet().iterator();
	while (iterator.hasNext()) {
		Entry<String, ISound> entry = iterator.next();
		ISound isound = entry.getValue();
		counts.adjustOrPutValue(isound.getSound().getSoundLocation().toString(), 1, 1);
	}

	final ArrayList<String> results = new ArrayList<String>();
	final TObjectIntIterator<String> itr = counts.iterator();
	while (itr.hasNext()) {
		itr.advance();
		results.add(String.format(TextFormatting.GOLD + "%s: %d", itr.key(), itr.value()));
	}
	Collections.sort(results);
	event.output.addAll(results);

}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:22,代码来源:SoundManagerReplacement.java

示例12: musicControl

import net.minecraft.client.audio.ISound; //导入依赖的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

示例13: onPlaySound

import net.minecraft.client.audio.ISound; //导入依赖的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

示例14: playRecord

import net.minecraft.client.audio.ISound; //导入依赖的package包/类
/**
 * Plays the specified record. Arg: recordName, x, y, z
 */
public void playRecord(String par1Str, int par2, int par3, int par4)
{
    ChunkCoordinates var5 = new ChunkCoordinates(par2, par3, par4);
    ISound var6 = (ISound)this.mapSoundPositions.get(var5);

    if (var6 != null)
    {
        this.mc.getSoundHandler().func_147683_b(var6);
        this.mapSoundPositions.remove(var5);
    }

    if (par1Str != null)
    {
        ItemRecord var7 = ItemRecord.func_150926_b(par1Str);

        if (var7 != null)
        {
            this.mc.ingameGUI.setRecordPlayingMessage(var7.func_150927_i());
        }

        PositionedSoundRecord var8 = PositionedSoundRecord.func_147675_a(new ResourceLocation(par1Str), (float)par2, (float)par3, (float)par4);
        this.mapSoundPositions.put(var5, var8);
        this.mc.getSoundHandler().playSound(var8);
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:29,代码来源:RenderGlobal.java

示例15: onSoundEvent

import net.minecraft.client.audio.ISound; //导入依赖的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


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