本文整理了Java中net.minecraft.util.SoundEvent
类的一些代码示例,展示了SoundEvent
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SoundEvent
类的具体详情如下:
包路径:net.minecraft.util.SoundEvent
类名称:SoundEvent
暂无
代码示例来源:origin: Vazkii/Botania
private static SoundEvent makeSoundEvent(String name) {
ResourceLocation loc = new ResourceLocation(LibMisc.MOD_ID, name);
return new SoundEvent(loc).setRegistryName(loc);
}
代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation
@Override
public ResourceLocation getSound() {
return EsteemedInnovation.SOUND_WHISTLE.getSoundName();
}
代码示例来源: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: PenguinSquad/Harvest-Festival
public static void registerSounds(String... sounds) {
for (String sound : sounds) {
ResourceLocation resource = new ResourceLocation(MODID, sound);
GameRegistry.register(new SoundEvent(resource), resource);
}
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
public static void registerSound(SoundEvent sound, String name)
{
sound.setRegistryName(name);
sounds.add(sound);
}
代码示例来源:origin: vadis365/TheErebus
public static SoundEvent registerSoundResource(String name) {
return new SoundEvent(new ResourceLocation(Reference.MOD_ID, name));
}
代码示例来源:origin: vadis365/TheErebus
public static void registerSoundName(String name, SoundEvent sound) {
SOUNDS.add(sound);
sound.setRegistryName(Reference.MOD_ID, name);
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
private static SoundEvent sound(String name) {
ResourceLocation location = Util.getResource(name);
SoundEvent event = new SoundEvent(location);
event.setRegistryName(location);
sounds.add(event);
return event;
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
public static SoundEvent[] createArray(String... soundNames) {
SoundEvent[] sounds = new SoundEvent[soundNames.length];
for(int i = 0; i < soundNames.length; i++) {
SoundEvent sound = new SoundEvent(new ResourceLocation(JurassiCraft.MODID, soundNames[i]));
RegistryHandler.registerSound(sound, soundNames[i]);
sounds[i] = sound;
}
return sounds;
}
代码示例来源:origin: CoFH/CoFHCore
public SoundBase(SoundEvent sound, SoundCategory category, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) {
this(sound.getSoundName(), category, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR);
}
代码示例来源: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: lorddusk/HQM
private static SoundEvent registerSound(ResourceLocation sound) {
SoundEvent event = new SoundEvent(sound).setRegistryName(sound);
registeredSounds.add(event);
return event;
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
public static SoundEvent create(String soundName) {
SoundEvent sound = new SoundEvent(new ResourceLocation(JurassiCraft.MODID, soundName));
RegistryHandler.registerSound(sound, soundName);
return sound;
}
代码示例来源:origin: CoFH/CoFHCore
public SoundBase(SoundEvent sound, SoundCategory category, float volume, float pitch, boolean repeat, int repeatDelay) {
this(sound.getSoundName(), category, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE);
}
代码示例来源: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: Alex-the-666/Ice_and_Fire
private static SoundEvent createSoundEvent(final String soundName) {
final ResourceLocation soundID = new ResourceLocation(MODID, soundName);
return new SoundEvent(soundID).setRegistryName(soundID);
}
}
代码示例来源:origin: CyclopsMC/EvilCraft
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
if(!world.isRemote) {
if (!player.capabilities.isCreativeMode) {
itemStack.shrink(1);
}
world.playSound(player, player.posX, player.posY, player.posZ, new SoundEvent(new ResourceLocation("random.bow")), SoundCategory.MASTER, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
EntityThrowable entity = getThrowableEntity(itemStack, world, player);
entity.shoot(player, player.rotationPitch, player.rotationYaw, -20.0F, 0.5F, 1.0F);
world.spawnEntity(entity);
}
return MinecraftHelpers.successAction(itemStack);
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@SideOnly(Side.CLIENT)
public String name() {
return sound != null ? sound.getSoundName().toString() : "";
}
代码示例来源: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: Silentine/GrimoireOfGaia
private static SoundEvent createSoundEvent(final String soundName) {
ResourceLocation soundID = new ResourceLocation(GaiaReference.MOD_ID, soundName);
return new SoundEvent(soundID).setRegistryName(soundID);
}
}
内容来源于网络,如有侵权,请联系作者删除!