本文整理汇总了Java中net.minecraft.client.audio.SoundHandler类的典型用法代码示例。如果您正苦于以下问题:Java SoundHandler类的具体用法?Java SoundHandler怎么用?Java SoundHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoundHandler类属于net.minecraft.client.audio包,在下文中一共展示了SoundHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateScreen
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
MusicTicker musicticker = this.mc.func_181535_r();
SoundHandler soundhandler = this.mc.getSoundHandler();
if (this.field_146581_h == 0)
{
musicticker.func_181557_a();
musicticker.func_181558_a(MusicTicker.MusicType.CREDITS);
soundhandler.resumeSounds();
}
soundhandler.update();
++this.field_146581_h;
float f = (float)(this.field_146579_r + this.height + this.height + 24) / this.field_146578_s;
if ((float)this.field_146581_h > f)
{
this.sendRespawnPacket();
}
}
示例2: createAccessor
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
@Nullable
@Override
public SoundEventAccessor createAccessor(@Nonnull SoundHandler handler) {
SoundEventAccessor soundEventAccessor = handler.getAccessor(this.soundLocation);
if (soundEventAccessor == null)
{
FirstAid.logger.warn("Missing sound for location " + this.soundLocation);
this.sound = SoundHandler.MISSING_SOUND;
}
else
{
this.sound = soundEventAccessor.cloneEntry();
}
return soundEventAccessor;
}
示例3: updateScreen
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
MusicTicker musicticker = this.mc.getMusicTicker();
SoundHandler soundhandler = this.mc.getSoundHandler();
if (this.time == 0)
{
musicticker.stopMusic();
musicticker.playMusic(MusicTicker.MusicType.CREDITS);
soundhandler.resumeSounds();
}
soundhandler.update();
++this.time;
float f = (float)(this.totalScrollLength + this.height + this.height + 24) / 0.5F;
if ((float)this.time > f)
{
this.sendRespawnPacket();
}
}
示例4: getSounds
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
public List<ResourceLocation> getSounds(String filter){
if(soundCache == null){
soundCache = Lists.newArrayList();
SoundRegistry reg = null;
try{
reg = ObfuscationReflectionHelper.getPrivateValue(SoundHandler.class, Minecraft.getMinecraft().getSoundHandler(), 4);
} catch(Exception e){}
if(reg == null)return soundCache;
for(ResourceLocation loc : reg.getKeys()){
if(loc.toString().toLowerCase().contains(filter)){
soundCache.add(loc);
}
}
}
return soundCache;
}
示例5: BasicSound
import net.minecraft.client.audio.SoundHandler; //导入依赖的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;
}
示例6: onConnect
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
@Override
public void onConnect() {
this.soundsToBlock.clear();
this.soundCull.clear();
final SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
for (final Object resource : handler.soundRegistry.getKeys()) {
final String rs = resource.toString();
if (this.registry.isSoundBlockedLogical(rs)) {
DSurround.log().debug("Blocking sound '%s'", rs);
this.soundsToBlock.add(rs);
} else if (this.registry.isSoundCulled(rs)) {
DSurround.log().debug("Culling sound '%s'", rs);
this.soundCull.put(rs, -ModOptions.soundCullingThreshold);
}
}
}
示例7: playSound
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
@Override
public void playSound(int soundId, float pitch, float volume, boolean repeat, boolean stop, float x, float y, float z)
{
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
SoundEvent sound = SoundEvent.REGISTRY.getObjectById(soundId);
if (sound != null)
{
if (stop)
{
soundHandler.stop(sound.getRegistryName().toString(), null);
}
else
{
PositionedSoundRecord positionedSound = new PositionedSoundRecord(sound.getSoundName(),
SoundCategory.RECORDS, volume, pitch, repeat, 0, AttenuationType.LINEAR, x, y, z);
soundHandler.playSound(positionedSound);
}
}
}
示例8: playHurtSound
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
public static void playHurtSound(SoundEvent event, int duration) {
if (!FirstAidConfig.enableSoundSystem)
return;
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
DebuffTimedSound matchingSound = activeSounds.get(event);
if (matchingSound != null) {
if (!matchingSound.isDonePlaying())
soundHandler.stopSound(matchingSound);
activeSounds.remove(event);
}
DebuffTimedSound newSound = new DebuffTimedSound(event, duration);
soundHandler.playSound(newSound);
activeSounds.put(event, newSound);
}
示例9: canAddSound
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
public static boolean canAddSound(final ISound sound) {
if (Sounds.playingSounds == null) {
Sounds.playingSounds = ReflectionHelper.findField((Class)SoundManager.class, new String[] { "playingSounds", "field_148629_h" });
Sounds.soundMgr = ReflectionHelper.findField((Class)SoundHandler.class, new String[] { "sndManager", "field_147694_f" });
}
try {
final SoundManager manager = (SoundManager)Sounds.soundMgr.get(Minecraft.getMinecraft().getSoundHandler());
final Map map = (Map)Sounds.playingSounds.get(manager);
return !map.containsValue(sound);
}
catch (IllegalAccessException e) {
return false;
}
}
示例10: click
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
public void click(SoundHandler handler, boolean flag) {
if (flag) {
SoundCore.play(handler, SoundCore.MENU_POPUP);
} else {
SoundCore.play(handler, SoundCore.DIALOG_CLOSE);
}
}
示例11: generateSoundList
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
protected void generateSoundList(final ConfigCategory cat) {
cat.setRequiresMcRestart(false);
cat.setRequiresWorldRestart(false);
final SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
final List<String> sounds = new ArrayList<String>();
for (final Object resource : handler.soundRegistry.getKeys())
sounds.add(resource.toString());
Collections.sort(sounds);
final SoundRegistry registry = RegistryManager.get(RegistryType.SOUND);
for (final String sound : sounds) {
final Property prop = new Property(sound, "", Property.Type.STRING);
prop.setDefaultValue("");
prop.setRequiresMcRestart(false);
prop.setRequiresWorldRestart(false);
prop.setConfigEntryClass(SoundConfigEntry.class);
final StringBuilder builder = new StringBuilder();
if (registry.isSoundBlocked(sound))
builder.append(GuiConstants.TOKEN_BLOCK).append(' ');
if (registry.isSoundCulled(sound))
builder.append(GuiConstants.TOKEN_CULL).append(' ');
final float v = registry.getVolumeScale(sound);
if (v != 1.0F)
builder.append((int) (v * 100F));
prop.setValue(builder.toString());
cat.put(sound, prop);
}
}
示例12: playPressSound
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
@Override
public void playPressSound(SoundHandler paramSoundHandler)
{
PlayerInfo pi = PlayerManagerTFC.getInstance().getClientPlayer();
if(pi.specialCraftingType.getItem() == TFCItems.LooseRock)
paramSoundHandler.playSound(net.minecraft.client.audio.PositionedSoundRecord.getMasterRecord(TFC_Sounds.KNAPPING, 1.0F));
}
示例13: playSoundAtEntity
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public static void playSoundAtEntity(Entity entity, byte soundCode)
{
SoundHandler snd = FMLClientHandler.instance().getClient().getSoundHandler();
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
switch (soundCode)
{
case EntitySoundPacket.COPTER_SOUND:
if (ConfigHandler.ALLOW_COPTER_SOUND)
{
snd.playSound(new CopterPackSound(player));
}
break;
case EntitySoundPacket.NYAN_SOUND:
snd.playSound(new NyanMovingSound(player));
break;
case EntitySoundPacket.JETPACK_FIZZ:
snd.playSound(new JetpackSoundOn(player));
break;
case EntitySoundPacket.BOILING_BUBBLES:
snd.playSound(new BoilingBoilerSound(player));
break;
case EntitySoundPacket.LEAKING_STEAM:
snd.playSound(new LeakingBoilerSound(player));
break;
}
}
}
示例14: processMessage
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
protected void processMessage(final MessageAddEffects message, EntityPlayer player, World world, SoundHandler soundHandler)
{
if (message.effectType == EFFECT_TELEPORT)
{
if ((message.flags & SOUND) == SOUND)
{
float pitch = 0.9f + world.rand.nextFloat() * 0.125f + world.rand.nextFloat() * 0.125f;
Effects.playSoundClient(world, message.x, message.y, message.z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.HOSTILE, 0.8f, pitch);
}
if ((message.flags & PARTICLES) == PARTICLES)
{
Effects.spawnParticles(world, EnumParticleTypes.PORTAL, message.x, message.y, message.z, message.particleCount, message.offset, message.velocity);
}
}
else if (message.effectType == EFFECT_ENDER_TOOLS)
{
if ((message.flags & SOUND) == SOUND && Configs.useToolSounds)
{
Effects.playSoundClient(world, message.x, message.y, message.z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.HOSTILE, 0.08f, 1.8f);
}
if ((message.flags & PARTICLES) == PARTICLES && Configs.useToolParticles)
{
Effects.spawnParticles(world, EnumParticleTypes.PORTAL, message.x, message.y, message.z, message.particleCount, message.offset, message.velocity);
}
}
else if (message.effectType == EFFECT_PARTICLES)
{
Effects.spawnParticles(world, EnumParticleTypes.getParticleFromId(message.flags), message.x, message.y, message.z, message.particleCount, message.offset, message.velocity);
}
else if (message.effectType == EFFECT_SOUND_EVENT)
{
EnderUtilities.proxy.playSound(message.soundEventId, message.pitch, message.volume,
message.repeat, message.flags != 0, message.x, message.y, message.z);
}
}
示例15: update
import net.minecraft.client.audio.SoundHandler; //导入依赖的package包/类
public void update(SoundHandler handler) {
if (isPlaying) {
isPlaying = handler.isSoundPlaying(sound);
} else {
ticks++;
}
}