Files
Explosion-Overhaul/com/vinlanx/explosionoverhaul/client/AnimationSoundManager.java
2026-05-04 10:03:58 +00:00

103 lines
5.2 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package com.vinlanx.explosionoverhaul.client;
import com.vinlanx.explosionoverhaul.ModSounds;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.RandomSource;
import net.minecraftforge.registries.RegistryObject;
public class AnimationSoundManager {
private static final RandomSource RANDOM = RandomSource.m_216327_();
private static final List<RegistryObject<SoundEvent>> ANIMATION_SOUNDS = new ArrayList<RegistryObject<SoundEvent>>();
private static final List<RegistryObject<SoundEvent>> FAR_POWER_2_SOUNDS = new ArrayList<RegistryObject<SoundEvent>>();
private static final List<RegistryObject<SoundEvent>> FAR_POWER_3_SOUNDS = new ArrayList<RegistryObject<SoundEvent>>();
private static final List<RegistryObject<SoundEvent>> MEDIUM_CAVE_POWER_4_SOUNDS = new ArrayList<RegistryObject<SoundEvent>>();
private static final List<RegistryObject<SoundEvent>> SUPERFAR_POWER_4_SOUNDS = new ArrayList<RegistryObject<SoundEvent>>();
private static int lastAnimationSoundIndex = -1;
private static int lastFarPower2SoundIndex = -1;
private static int lastFarPower3SoundIndex = -1;
private static int lastMediumCavePower4SoundIndex = -1;
private static int lastSuperfar4SoundIndex = -1;
private static int getNextRandomIndex(List<?> list, int lastIndex) {
int nextIndex;
if (list.size() <= 1) {
return 0;
}
while ((nextIndex = RANDOM.m_188503_(list.size())) == lastIndex) {
}
return nextIndex;
}
public static void playRandomAnimationSound() {
if (ANIMATION_SOUNDS.isEmpty()) {
return;
}
lastAnimationSoundIndex = AnimationSoundManager.getNextRandomIndex(ANIMATION_SOUNDS, lastAnimationSoundIndex);
SoundEvent sound = (SoundEvent)ANIMATION_SOUNDS.get(lastAnimationSoundIndex).get();
Minecraft.m_91087_().m_91106_().m_120367_((SoundInstance)SimpleSoundInstance.m_119752_((SoundEvent)sound, (float)1.0f));
}
public static void playRandomFarPower2Sound() {
if (FAR_POWER_2_SOUNDS.isEmpty()) {
return;
}
lastFarPower2SoundIndex = AnimationSoundManager.getNextRandomIndex(FAR_POWER_2_SOUNDS, lastFarPower2SoundIndex);
SoundEvent sound = (SoundEvent)FAR_POWER_2_SOUNDS.get(lastFarPower2SoundIndex).get();
Minecraft.m_91087_().m_91106_().m_120367_((SoundInstance)SimpleSoundInstance.m_119752_((SoundEvent)sound, (float)1.0f));
}
public static void playRandomFarPower3Sound() {
if (FAR_POWER_3_SOUNDS.isEmpty()) {
return;
}
lastFarPower3SoundIndex = AnimationSoundManager.getNextRandomIndex(FAR_POWER_3_SOUNDS, lastFarPower3SoundIndex);
SoundEvent sound = (SoundEvent)FAR_POWER_3_SOUNDS.get(lastFarPower3SoundIndex).get();
Minecraft.m_91087_().m_91106_().m_120367_((SoundInstance)SimpleSoundInstance.m_119752_((SoundEvent)sound, (float)1.0f));
}
public static void playRandomMediumCavePower4Sound() {
if (MEDIUM_CAVE_POWER_4_SOUNDS.isEmpty()) {
return;
}
lastMediumCavePower4SoundIndex = AnimationSoundManager.getNextRandomIndex(MEDIUM_CAVE_POWER_4_SOUNDS, lastMediumCavePower4SoundIndex);
SoundEvent sound = (SoundEvent)MEDIUM_CAVE_POWER_4_SOUNDS.get(lastMediumCavePower4SoundIndex).get();
Minecraft.m_91087_().m_91106_().m_120367_((SoundInstance)SimpleSoundInstance.m_119752_((SoundEvent)sound, (float)1.0f));
}
public static void playRandomSuperfar4Sound() {
if (SUPERFAR_POWER_4_SOUNDS.isEmpty()) {
return;
}
lastSuperfar4SoundIndex = AnimationSoundManager.getNextRandomIndex(SUPERFAR_POWER_4_SOUNDS, lastSuperfar4SoundIndex);
SoundEvent sound = (SoundEvent)SUPERFAR_POWER_4_SOUNDS.get(lastSuperfar4SoundIndex).get();
Minecraft.m_91087_().m_91106_().m_120367_((SoundInstance)SimpleSoundInstance.m_119752_((SoundEvent)sound, (float)1.0f));
}
static {
ANIMATION_SOUNDS.add(ModSounds.EXPLODE_SUPERFAR_POWER_2_1);
ANIMATION_SOUNDS.add(ModSounds.EXPLODE_SUPERFAR_POWER_2_2);
ANIMATION_SOUNDS.add(ModSounds.EXPLODE_SUPERFAR_POWER_3_1);
FAR_POWER_2_SOUNDS.add(ModSounds.EXPLODE_FAR_POWER_2_1);
FAR_POWER_2_SOUNDS.add(ModSounds.EXPLODE_FAR_POWER_2_2);
FAR_POWER_2_SOUNDS.add(ModSounds.EXPLODE_FAR_POWER_2_3);
FAR_POWER_3_SOUNDS.add(ModSounds.EXPLODE_FAR_POWER_3_1);
FAR_POWER_3_SOUNDS.add(ModSounds.EXPLODE_FAR_POWER_3_2);
FAR_POWER_3_SOUNDS.add(ModSounds.EXPLODE_FAR_POWER_3_3);
MEDIUM_CAVE_POWER_4_SOUNDS.add(ModSounds.EXPLODE_MEDIUM_CAVE_POWER_4_1);
MEDIUM_CAVE_POWER_4_SOUNDS.add(ModSounds.EXPLODE_MEDIUM_CAVE_POWER_4_2);
MEDIUM_CAVE_POWER_4_SOUNDS.add(ModSounds.EXPLODE_MEDIUM_CAVE_POWER_4_3);
SUPERFAR_POWER_4_SOUNDS.add(ModSounds.EXPLODE_SUPERFAR_POWER_4_1);
SUPERFAR_POWER_4_SOUNDS.add(ModSounds.EXPLODE_SUPERFAR_POWER_4_2);
SUPERFAR_POWER_4_SOUNDS.add(ModSounds.EXPLODE_SUPERFAR_POWER_4_3);
}
}