/* * Decompiled with CFR 0.152. */ package com.vinlanx.explosionoverhaul.client; import com.vinlanx.explosionoverhaul.ModSounds; import com.vinlanx.explosionoverhaul.client.Blur; import com.vinlanx.explosionoverhaul.client.DeafnessConcussionEffect; import com.vinlanx.explosionoverhaul.client.FadingMusicInstance; import com.vinlanx.explosionoverhaul.client.LowPassConcussionEffect; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @OnlyIn(value=Dist.CLIENT) @Mod.EventBusSubscriber(modid="explosionoverhaul", value={Dist.CLIENT}) public class ConcussionSoundManager { private static FadingMusicInstance currentLowSound = null; @SubscribeEvent public static void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.END) { return; } Minecraft mc = Minecraft.m_91087_(); if (mc.f_91073_ == null || mc.f_91074_ == null) { if (currentLowSound != null) { mc.m_91106_().m_120399_((SoundInstance)currentLowSound); currentLowSound = null; } return; } if (mc.m_91104_()) { return; } boolean deafness = DeafnessConcussionEffect.isActive(); boolean lowpass = LowPassConcussionEffect.isActive(); boolean blur = Blur.isActive(); float targetVolume = 0.0f; if (blur) { if (deafness) { targetVolume = 1.0f; } else if (lowpass) { targetVolume = 0.4f; } } if (targetVolume > 0.0f) { if (currentLowSound == null || !mc.m_91106_().m_120403_((SoundInstance)currentLowSound)) { currentLowSound = new FadingMusicInstance((SoundEvent)ModSounds.LOW_SOUND.get(), 0.01f, SoundSource.MASTER); currentLowSound.fadeTo(targetVolume, 1.0f); mc.m_91106_().m_120367_((SoundInstance)currentLowSound); } else if (Math.abs(currentLowSound.getCurrentVolume() - targetVolume) > 0.01f && !currentLowSound.hasFinishedFading()) { currentLowSound.fadeTo(targetVolume, 0.5f); } } else if (currentLowSound != null && mc.m_91106_().m_120403_((SoundInstance)currentLowSound) && !currentLowSound.hasFinishedFading()) { currentLowSound.fadeOutAndStop(1.0f); } } }