Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Commit

Permalink
Duplicate registering will be automatically handled, no need to map S…
Browse files Browse the repository at this point in the history
…oundEvent and it's path
  • Loading branch information
ISNing committed Jul 15, 2023
1 parent 0cbdf0b commit 66df05c
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/main/java/weather2/SoundRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegisterEvent;

import java.util.HashMap;

public class SoundRegistry {

private static HashMap<String, SoundEvent> lookupStringToEvent = new HashMap<String, SoundEvent>();

@Mod.EventBusSubscriber(modid = Weather.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents {
@SubscribeEvent
Expand Down Expand Up @@ -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));
}

}

0 comments on commit 66df05c

Please sign in to comment.