private static SoundEvent makeSoundEvent(String name) { ResourceLocation loc = new ResourceLocation(LibMisc.MOD_ID, name); return new SoundEvent(loc).setRegistryName(loc); }
@Override public ResourceLocation getSound() { return EsteemedInnovation.SOUND_WHISTLE.getSoundName(); }
@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; }
public static void registerSounds(String... sounds) { for (String sound : sounds) { ResourceLocation resource = new ResourceLocation(MODID, sound); GameRegistry.register(new SoundEvent(resource), resource); } }
public static void registerSound(SoundEvent sound, String name) { sound.setRegistryName(name); sounds.add(sound); }
public static SoundEvent registerSoundResource(String name) { return new SoundEvent(new ResourceLocation(Reference.MOD_ID, name)); }
public static void registerSoundName(String name, SoundEvent sound) { SOUNDS.add(sound); sound.setRegistryName(Reference.MOD_ID, name); }
private static SoundEvent sound(String name) { ResourceLocation location = Util.getResource(name); SoundEvent event = new SoundEvent(location); event.setRegistryName(location); sounds.add(event); return event; }
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; }
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); }
private static SoundEvent getInstrument(String name) { ResourceLocation id = new ResourceLocation(name); for (SoundEvent sound : instruments) { if (sound.getRegistryName().equals(id)) { return sound; } } return null; }
private static SoundEvent registerSound(ResourceLocation sound) { SoundEvent event = new SoundEvent(sound).setRegistryName(sound); registeredSounds.add(event); return event; }
public static SoundEvent create(String soundName) { SoundEvent sound = new SoundEvent(new ResourceLocation(JurassiCraft.MODID, soundName)); RegistryHandler.registerSound(sound, soundName); return sound; }
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); }
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() }
private static SoundEvent createSoundEvent(final String soundName) { final ResourceLocation soundID = new ResourceLocation(MODID, soundName); return new SoundEvent(soundID).setRegistryName(soundID); } }
@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); }
@SideOnly(Side.CLIENT) public String name() { return sound != null ? sound.getSoundName().toString() : ""; }
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; } }
private static SoundEvent createSoundEvent(final String soundName) { ResourceLocation soundID = new ResourceLocation(GaiaReference.MOD_ID, soundName); return new SoundEvent(soundID).setRegistryName(soundID); } }