package com.yolp900.itsjustacharm.common.sounds;
import com.yolp900.itsjustacharm.reference.LibSounds;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
public class SoundHandler {
private static int size = 0;
public static void registerSounds() {
size = SoundEvent.REGISTRY.getKeys().size();
for (ModSounds event : ModSounds.values()) {
event.setSoundEvent(registerSound(event.getSound()));
}
}
private static SoundEvent registerSound(LibSounds sound) {
ResourceLocation loc = sound.getName();
SoundEvent e = new SoundEvent(loc);
SoundEvent.REGISTRY.register(size, loc, e);
size++;
return e;
}
public static ModSounds getSoundEvent(LibSounds sound) {
for (ModSounds event : ModSounds.values()) {
if (event.getSound() == sound) {
return event;
}
}
return null;
}
}