本文整理了Java中net.minecraft.util.SoundEvent.getRegistryName()
方法的一些代码示例,展示了SoundEvent.getRegistryName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SoundEvent.getRegistryName()
方法的具体详情如下:
包路径:net.minecraft.util.SoundEvent
类名称:SoundEvent
方法名:getRegistryName
暂无
代码示例来源:origin: Vazkii/Botania
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) {
if(entity instanceof EntityLiving) {
EntityLiving living = (EntityLiving) entity;
SoundEvent sound = null;
if(living instanceof EntityCreeper)
sound = SoundEvents.ENTITY_CREEPER_PRIMED;
else if(living instanceof EntitySlime)
sound = ((EntitySlime) living).isSmallSlime() ? SoundEvents.ENTITY_SMALL_SLIME_SQUISH : SoundEvents.ENTITY_SLIME_SQUISH;
else {
try {
sound = (SoundEvent) ReflectionHelper.findMethod(EntityLiving.class, LibObfuscation.GET_LIVING_SOUND[0], LibObfuscation.GET_LIVING_SOUND[1]).invoke(living);
} catch (InvocationTargetException | IllegalAccessException ignored) {
Botania.LOGGER.debug("Couldn't get living sound");
}
}
if(sound != null) {
String s = EntityList.getEntityString(entity);
if(s == null)
s = "generic";
ItemNBTHelper.setString(stack, TAG_SOUND, sound.getRegistryName().toString());
ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name");
player.setHeldItem(hand, stack);
if(player.world.isRemote)
player.swingArm(hand);
return true;
}
}
return false;
}
代码示例来源:origin: SquidDev-CC/plethora
private static SoundEvent getInstrument(String name) {
ResourceLocation id = new ResourceLocation(name);
for (SoundEvent sound : instruments) {
if (sound.getRegistryName().equals(id)) {
return sound;
}
}
return null;
}
代码示例来源:origin: PrinceOfAmber/Cyclic
public PacketSound(BlockPos p, SoundEvent t, SoundCategory cat) {
pos = p;
ResourceLocation r = t.getRegistryName();
domain = r.getNamespace();
type = r.getPath();
category = cat.getName(); //SoundCategory.BLOCKS.getName()
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
if (sound != null) {
//noinspection ConstantConditions
tag.setString("name", sound.getRegistryName().toString());
}
tag.setFloat("length", length);
tag.setInteger("volume", volume);
return tag;
}
}
代码示例来源:origin: PrinceOfAmber/Cyclic
public static void playSoundFromServer(SoundEvent soundEvent, SoundCategory cat, BlockPos nextPos, int dim, int range) {
//https://github.com/PrinceOfAmber/Cyclic/issues/506
if (soundEvent != null && soundEvent.getRegistryName() != null) // dont crash trying to play invalid sound
ModCyclic.network.sendToAllAround(new PacketSound(nextPos, soundEvent, cat),
new NetworkRegistry.TargetPoint(dim, nextPos.getX(), nextPos.getY(), nextPos.getZ(), range));
}
}
内容来源于网络,如有侵权,请联系作者删除!