From 66df05c57519a9332a3f0751ac3a7ee964c1aba3 Mon Sep 17 00:00:00 2001 From: ISNing <1208733578@qq.com> Date: Sat, 15 Jul 2023 23:57:39 +0800 Subject: [PATCH] Duplicate registering will be automatically handled, no need to map SoundEvent and it's path --- src/main/java/weather2/SoundRegistry.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/weather2/SoundRegistry.java b/src/main/java/weather2/SoundRegistry.java index a3ea4322..9940667f 100644 --- a/src/main/java/weather2/SoundRegistry.java +++ b/src/main/java/weather2/SoundRegistry.java @@ -7,12 +7,7 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegisterEvent; -import java.util.HashMap; - public class SoundRegistry { - - private static HashMap lookupStringToEvent = new HashMap(); - @Mod.EventBusSubscriber(modid = Weather.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent @@ -60,14 +55,10 @@ public static void register(RegisterEvent regEvent, String soundPath) { ResourceLocation resLoc = new ResourceLocation(Weather.MODID, soundPath); SoundEvent event = new SoundEvent(resLoc); regEvent.register(ForgeRegistries.Keys.SOUND_EVENTS, resLoc, () -> event); - if (lookupStringToEvent.containsKey(soundPath)) { - System.out.println("WEATHER SOUNDS WARNING: duplicate sound registration for " + soundPath); - } - lookupStringToEvent.put(soundPath, event); } public static SoundEvent get(String soundPath) { - return lookupStringToEvent.get(soundPath); + return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(Weather.MODID, soundPath)); } }