gcewing Posted December 1, 2016 Posted December 1, 2016 Is there a way for a mod to register its own sounds in 1.10.2? The only machinery I can find for doing that is all private. Quote
Choonster Posted December 1, 2016 Posted December 1, 2016 Create a SoundEvent with the ResourceLocation of your sound (i.e. your mod ID as the domain and the event name from sounds.json as the path), subscribe to RegistryEvent.Register<SoundEvent> and then use RegistryEvent.Register#getRegistry to get the registry and IForgeRegistry#register or IForgeRegistry#registerAll to register your SoundEvent . RegistryEvent.Register is fired before preInit, so you need to subscribe to it with a static method annotated with @SubscribeEvent in a class annotated with @Mod.EventBusSubscriber . You can see how I do this here. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
gcewing Posted December 1, 2016 Author Posted December 1, 2016 Thanks. I couldn't see how to make sure my sounds got assigned unique ID numbers, but digging deeper I can see that Forge has its own way of allocating them. All is working now. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.