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


Java ITickableSound类代码示例

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


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

示例1: onPlaySound

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

import net.minecraft.client.audio.ITickableSound; //导入依赖的package包/类
@SubscribeEvent
public void soundMufflerPlay(final PlaySoundEvent17 event) {
    if (Minecraft.getMinecraft().theWorld != null && ExtraUtils.soundMuffler != null && event.result != null) {
        final World world = (World)Minecraft.getMinecraft().theWorld;
        if (event.result instanceof ITickableSound) {
            return;
        }
        final float x = event.result.getXPosF();
        final float y = event.result.getYPosF();
        final float z = event.result.getZPosF();
        for (int dx = (int)Math.floor(x - 8.0f) >> 4; dx <= (int)Math.floor(x + 8.0f) >> 4; ++dx) {
            for (int dz = (int)Math.floor(z - 8.0f) >> 4; dz <= (int)Math.floor(z + 8.0f) >> 4; ++dz) {
                for (final TileEntity var19 : (Collection<TileEntity>) world.getChunkFromChunkCoords(dx, dz).chunkTileEntityMap.values()) {
                    if (var19 instanceof TileEntitySoundMuffler) {
                        if (var19.getBlockMetadata() == 1) {
                            continue;
                        }
                        double d = (var19.xCoord + 0.5 - x) * (var19.xCoord + 0.5 - x) + (var19.yCoord + 0.5 - y) * (var19.yCoord + 0.5 - y) + (var19.zCoord + 0.5 - z) * (var19.zCoord + 0.5 - z);
                        if (d > 64.0) {
                            continue;
                        }
                        if (d <= 0.0) {
                            continue;
                        }
                        event.result = (ISound)new SoundMuffled(event.result);
                        d = Math.sqrt(d);
                        if (d != 0.0) {
                            d = 1.0 / d / 8.0;
                        }
                        world.spawnParticle("smoke", (double)x, (double)y, (double)z, (var19.xCoord + 0.5 - x) * d, (var19.yCoord + 0.5 - y) * d, (var19.zCoord + 0.5 - z) * d);
                    }
                }
            }
        }
    }
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:37,代码来源:EventHandlerClient.java

示例3: updateAllSounds

import net.minecraft.client.audio.ITickableSound; //导入依赖的package包/类
@Override
public void updateAllSounds() {

	final SoundSystem sndSystem = getSoundSystem();

	++this.playTime;

	for (final ITickableSound itickablesound : this.tickableSounds) {
		itickablesound.update();

		if (itickablesound.isDonePlaying()) {
			this.stopSound(itickablesound);
		} else {
			final String s = this.invPlayingSounds.get(itickablesound);
			synchronized (SoundSystemConfig.THREAD_SYNC) {
				sndSystem.setVolume(s, this.getClampedVolume(itickablesound));
				sndSystem.setPitch(s, this.getClampedPitch(itickablesound));
				sndSystem.setPosition(s, itickablesound.getXPosF(), itickablesound.getYPosF(),
						itickablesound.getZPosF());
			}
		}
	}

	final Iterator<Entry<String, ISound>> iterator = this.playingSounds.entrySet().iterator();

	while (iterator.hasNext()) {

		final Entry<String, ISound> entry = iterator.next();
		final String s1 = entry.getKey();

		if (!sndSystem.playing(s1)) {
			final ISound isound = entry.getValue();
			final int j = isound.getRepeatDelay();
			final int minThresholdDelay = isound instanceof BasicSound ? 0 : 1;

			// Repeatable sound could have a delay of 0, meaning
			// don't delay a requeue.
			if (isound.canRepeat() && j >= minThresholdDelay) {
				this.playDelayedSound(isound, j);
			} else {
				this.setState(isound, SoundState.DONE);
			}

			iterator.remove();
			sndSystem.removeSource(s1);
			this.playingSoundsStopTime.remove(s1);

			try {
				this.categorySounds.remove(isound.getCategory(), s1);
			} catch (RuntimeException var8) {
				;
			}

			if (isound instanceof ITickableSound) {
				this.tickableSounds.remove(isound);
			}
		}
	}

	final Iterator<Entry<ISound, Integer>> iterator1 = this.delayedSounds.entrySet().iterator();

	while (iterator1.hasNext()) {
		final Entry<ISound, Integer> entry1 = iterator1.next();

		if (this.playTime >= entry1.getValue().intValue()) {
			final ISound isound1 = entry1.getKey();

			if (isound1 instanceof ITickableSound) {
				((ITickableSound) isound1).update();
			}

			this.playSound(isound1);
			iterator1.remove();
		}
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:77,代码来源:SoundManagerReplacement.java

示例4: canRestartSound

import net.minecraft.client.audio.ITickableSound; //导入依赖的package包/类
public static boolean canRestartSound(ITickableSound sound)
{
	return sound.isDonePlaying() && !getSoundMap().containsKey(sound);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:5,代码来源:SoundHandler.java


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