Search in sources :

Example 1 with CategorizedSoundEvent

use of hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent in project AstralSorcery by HellFirePvP.

the class TileAltar method doCraftSound.

@OnlyIn(Dist.CLIENT)
private void doCraftSound() {
    if (SoundHelper.getSoundVolume(SoundCategory.BLOCKS) > 0) {
        ActiveSimpleAltarRecipe activeRecipe = this.getActiveRecipe();
        AltarType type = this.getAltarType();
        if (clientCraftSound == null || ((PositionedLoopSound) clientCraftSound).hasStoppedPlaying()) {
            CategorizedSoundEvent sound = SoundsAS.ALTAR_CRAFT_LOOP_T1;
            switch(type) {
                case ATTUNEMENT:
                    sound = SoundsAS.ALTAR_CRAFT_LOOP_T2;
                    break;
                case CONSTELLATION:
                    sound = SoundsAS.ALTAR_CRAFT_LOOP_T3;
                    break;
                case RADIANCE:
                    sound = SoundsAS.ALTAR_CRAFT_LOOP_T4;
                    break;
            }
            clientCraftSound = SoundHelper.playSoundLoopFadeInClient(sound, new Vector3(this).add(0.5, 0.5, 0.5), 0.6F, 1F, false, (s) -> isRemoved() || SoundHelper.getSoundVolume(SoundCategory.BLOCKS) <= 0 || this.getActiveRecipe() == null).setFadeInTicks(40).setFadeOutTicks(20);
        }
        if (activeRecipe.getState() == ActiveSimpleAltarRecipe.CraftingState.WAITING && type.isThisGEThan(AltarType.RADIANCE)) {
            if (clientWaitSound == null || ((PositionedLoopSound) clientWaitSound).hasStoppedPlaying()) {
                clientWaitSound = SoundHelper.playSoundLoopFadeInClient(SoundsAS.ALTAR_CRAFT_LOOP_T4_WAITING, new Vector3(this).add(0.5, 0.5, 0.5), 0.7F, 1F, false, (s) -> isRemoved() || SoundHelper.getSoundVolume(SoundCategory.BLOCKS) <= 0 || this.getActiveRecipe() == null || this.getActiveRecipe().getState() != ActiveSimpleAltarRecipe.CraftingState.WAITING).setFadeInTicks(30).setFadeOutTicks(10);
            }
            ((PositionedLoopSound) clientCraftSound).setVolumeMultiplier(0.75F);
        } else {
            ((PositionedLoopSound) clientCraftSound).setVolumeMultiplier(1F);
        }
    } else {
        clientWaitSound = null;
        clientCraftSound = null;
    }
}
Also used : Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) ByteBufUtils(hellfirepvp.astralsorcery.common.util.data.ByteBufUtils) NBTHelper(hellfirepvp.astralsorcery.common.util.nbt.NBTHelper) Constants(net.minecraftforge.common.util.Constants) CompoundNBT(net.minecraft.nbt.CompoundNBT) Direction(net.minecraft.util.Direction) Dist(net.minecraftforge.api.distmarker.Dist) SimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.SimpleAltarRecipe) DayTimeHelper(hellfirepvp.astralsorcery.common.constellation.world.DayTimeHelper) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) TileSpectralRelay(hellfirepvp.astralsorcery.common.tile.TileSpectralRelay) SoundCategory(net.minecraft.util.SoundCategory) ISeedReader(net.minecraft.world.ISeedReader) LogicalSide(net.minecraftforge.fml.LogicalSide) PlayerEntity(net.minecraft.entity.player.PlayerEntity) BlockDiscoverer(hellfirepvp.astralsorcery.common.util.block.BlockDiscoverer) TileInventoryFiltered(hellfirepvp.astralsorcery.common.util.tile.TileInventoryFiltered) PositionedLoopSound(hellfirepvp.astralsorcery.client.util.sound.PositionedLoopSound) SimpleAltarRecipeContext(hellfirepvp.astralsorcery.common.crafting.recipe.SimpleAltarRecipeContext) ItemUtils(hellfirepvp.astralsorcery.common.util.item.ItemUtils) CategorizedSoundEvent(hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent) ForgeHooks(net.minecraftforge.common.ForgeHooks) java.util(java.util) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) IConstellationFocus(hellfirepvp.astralsorcery.common.item.base.IConstellationFocus) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) SkyHandler(hellfirepvp.astralsorcery.common.constellation.SkyHandler) SoundsAS(hellfirepvp.astralsorcery.common.lib.SoundsAS) SkyCollectionHelper(hellfirepvp.astralsorcery.common.util.world.SkyCollectionHelper) TileEntityTypesAS(hellfirepvp.astralsorcery.common.lib.TileEntityTypesAS) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) MiscUtils(hellfirepvp.astralsorcery.common.util.MiscUtils) SoundHelper(hellfirepvp.astralsorcery.common.util.sound.SoundHelper) AltarType(hellfirepvp.astralsorcery.common.block.tile.altar.AltarType) PacketChannel(hellfirepvp.astralsorcery.common.network.PacketChannel) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) EntityFlare(hellfirepvp.astralsorcery.common.entity.EntityFlare) StringNBT(net.minecraft.nbt.StringNBT) TileReceiverBase(hellfirepvp.astralsorcery.common.tile.base.network.TileReceiverBase) IRecipe(net.minecraft.item.crafting.IRecipe) World(net.minecraft.world.World) PktPlayEffect(hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect) BlockPos(net.minecraft.util.math.BlockPos) WandInteractable(hellfirepvp.astralsorcery.common.item.wand.WandInteractable) ActiveSimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe) MathHelper(net.minecraft.util.math.MathHelper) StarlightReceiverAltar(hellfirepvp.astralsorcery.common.tile.network.StarlightReceiverAltar) ResourceLocation(net.minecraft.util.ResourceLocation) RecipeTypesAS(hellfirepvp.astralsorcery.common.lib.RecipeTypesAS) StructureType(hellfirepvp.astralsorcery.common.structure.types.StructureType) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext) ActiveSimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe) AltarType(hellfirepvp.astralsorcery.common.block.tile.altar.AltarType) PositionedLoopSound(hellfirepvp.astralsorcery.client.util.sound.PositionedLoopSound) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) CategorizedSoundEvent(hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 2 with CategorizedSoundEvent

use of hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent in project AstralSorcery by HellFirePvP.

the class TileInfuser method doCraftSound.

@OnlyIn(Dist.CLIENT)
private void doCraftSound() {
    if (SoundHelper.getSoundVolume(SoundCategory.BLOCKS) > 0) {
        if (clientCraftSound == null || ((PositionedLoopSound) clientCraftSound).hasStoppedPlaying()) {
            CategorizedSoundEvent sound = SoundsAS.INFUSER_CRAFT_LOOP;
            clientCraftSound = SoundHelper.playSoundLoopFadeInClient(sound, new Vector3(this).add(0.5, 0.5, 0.5), 1F, 1F, false, (s) -> isRemoved() || SoundHelper.getSoundVolume(SoundCategory.BLOCKS) <= 0 || this.getActiveRecipe() == null).setFadeInTicks(30).setFadeOutTicks(20);
        }
    } else {
        clientCraftSound = null;
    }
}
Also used : Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) ByteBufUtils(hellfirepvp.astralsorcery.common.util.data.ByteBufUtils) NBTHelper(hellfirepvp.astralsorcery.common.util.nbt.NBTHelper) Constants(net.minecraftforge.common.util.Constants) CompoundNBT(net.minecraft.nbt.CompoundNBT) Direction(net.minecraft.util.Direction) RenderingUtils(hellfirepvp.astralsorcery.client.util.RenderingUtils) Dist(net.minecraftforge.api.distmarker.Dist) FluidAttributes(net.minecraftforge.fluids.FluidAttributes) TileInventory(hellfirepvp.astralsorcery.common.util.tile.TileInventory) Map(java.util.Map) SoundCategory(net.minecraft.util.SoundCategory) MapStream(hellfirepvp.astralsorcery.common.util.MapStream) LogicalSide(net.minecraftforge.fml.LogicalSide) ImmutableSet(com.google.common.collect.ImmutableSet) ColorUtils(hellfirepvp.astralsorcery.common.util.ColorUtils) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Set(java.util.Set) Capability(net.minecraftforge.common.capabilities.Capability) StructureTypesAS(hellfirepvp.astralsorcery.common.lib.StructureTypesAS) PositionedLoopSound(hellfirepvp.astralsorcery.client.util.sound.PositionedLoopSound) FluidStack(net.minecraftforge.fluids.FluidStack) TileEntityTick(hellfirepvp.astralsorcery.common.tile.base.TileEntityTick) CategorizedSoundEvent(hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent) ForgeHooks(net.minecraftforge.common.ForgeHooks) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) SoundsAS(hellfirepvp.astralsorcery.common.lib.SoundsAS) TileEntityTypesAS(hellfirepvp.astralsorcery.common.lib.TileEntityTypesAS) LazyOptional(net.minecraftforge.common.util.LazyOptional) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) EffectTemplatesAS(hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS) LiquidInfusionContext(hellfirepvp.astralsorcery.common.crafting.recipe.LiquidInfusionContext) Minecraft(net.minecraft.client.Minecraft) LiquidInfusion(hellfirepvp.astralsorcery.common.crafting.recipe.LiquidInfusion) MiscUtils(hellfirepvp.astralsorcery.common.util.MiscUtils) SoundHelper(hellfirepvp.astralsorcery.common.util.sound.SoundHelper) PacketChannel(hellfirepvp.astralsorcery.common.network.PacketChannel) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) EntityFlare(hellfirepvp.astralsorcery.common.entity.EntityFlare) StringNBT(net.minecraft.nbt.StringNBT) VFXAlphaFunction(hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction) IRecipe(net.minecraft.item.crafting.IRecipe) World(net.minecraft.world.World) PktPlayEffect(hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect) BlockPos(net.minecraft.util.math.BlockPos) WandInteractable(hellfirepvp.astralsorcery.common.item.wand.WandInteractable) EffectHelper(hellfirepvp.astralsorcery.client.effect.handler.EffectHelper) java.awt(java.awt) ResourceLocation(net.minecraft.util.ResourceLocation) ActiveLiquidInfusionRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.infusion.ActiveLiquidInfusionRecipe) RecipeTypesAS(hellfirepvp.astralsorcery.common.lib.RecipeTypesAS) Fluid(net.minecraft.fluid.Fluid) StructureType(hellfirepvp.astralsorcery.common.structure.types.StructureType) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) CategorizedSoundEvent(hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with CategorizedSoundEvent

use of hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent in project AstralSorcery by HellFirePvP.

the class RegistrySounds method registerSound.

private static <T extends SoundEvent> T registerSound(String jsonName, SoundCategory predefinedCategory) {
    ResourceLocation res = AstralSorcery.key(jsonName);
    CategorizedSoundEvent se = new CategorizedSoundEvent(res, predefinedCategory);
    se.setRegistryName(res);
    return registerSound((T) se);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) CategorizedSoundEvent(hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent)

Aggregations

CategorizedSoundEvent (hellfirepvp.astralsorcery.common.util.sound.CategorizedSoundEvent)3 PositionedLoopSound (hellfirepvp.astralsorcery.client.util.sound.PositionedLoopSound)2 EntityFlare (hellfirepvp.astralsorcery.common.entity.EntityFlare)2 WandInteractable (hellfirepvp.astralsorcery.common.item.wand.WandInteractable)2 RecipeTypesAS (hellfirepvp.astralsorcery.common.lib.RecipeTypesAS)2 SoundsAS (hellfirepvp.astralsorcery.common.lib.SoundsAS)2 TileEntityTypesAS (hellfirepvp.astralsorcery.common.lib.TileEntityTypesAS)2 PacketChannel (hellfirepvp.astralsorcery.common.network.PacketChannel)2 PktPlayEffect (hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect)2 StructureType (hellfirepvp.astralsorcery.common.structure.types.StructureType)2 MiscUtils (hellfirepvp.astralsorcery.common.util.MiscUtils)2 ByteBufUtils (hellfirepvp.astralsorcery.common.util.data.ByteBufUtils)2 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)2 NBTHelper (hellfirepvp.astralsorcery.common.util.nbt.NBTHelper)2 SoundHelper (hellfirepvp.astralsorcery.common.util.sound.SoundHelper)2 Nonnull (javax.annotation.Nonnull)2 Nullable (javax.annotation.Nullable)2 Minecraft (net.minecraft.client.Minecraft)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 ItemStack (net.minecraft.item.ItemStack)2