Skip to content

Instantly share code, notes, and snippets.

@TheNathanSpace
Created November 10, 2020 14:43
Show Gist options
  • Save TheNathanSpace/8eb86a41c1097810b86e4a0ad0d42237 to your computer and use it in GitHub Desktop.
Save TheNathanSpace/8eb86a41c1097810b86e4a0ad0d42237 to your computer and use it in GitHub Desktop.
Register sounds using DeferredRegister
@Mod.EventBusSubscriber (modid = MODID)
public class ModSounds
{
public static void registerSounds()
{
SOUNDS.register(FMLJavaModLoadingContext.get().getModEventBus());
}
private static final DeferredRegister<SoundEvent> SOUNDS = new DeferredRegister<>(ForgeRegistries.SOUND_EVENTS, MODID);
public static final RegistryObject<SoundEvent> SOUND_123 = SOUNDS.register("123", () -> new SoundEvent(new ResourceLocation(MODID, "123")));
}
@Mod ("mymod")
public class MYMOD
{
public static final String MODID = "mymod";
public MYMOD()
{
ModSounds.registerSounds();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment