Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ding is unable to access sounds from other mods when those mods register them using RegistryEvent #12

Closed
TheNathanSpace opened this issue Nov 9, 2020 · 1 comment

Comments

@TheNathanSpace
Copy link

TheNathanSpace commented Nov 9, 2020

I've been trying to get Ding to play a sound from a mod I'm making. However, I keep getting the error Could not find sound: mymod:mysound.

I've done some digging around, and I figured out the problem.

Here's how Ding currently gets and plays the sounds:

SoundEvent useRegistered = (SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("mymod:mysound"));
Minecraft.getInstance().getSoundHandler().play(SimpleSound.master(useRegistered, 1));

It's trying to get the registered object. However, this doesn't work for mod sounds—it always throws this error message. (I know you haven't updated GitHub with the latest versions of Ding, but it's still pretty much the same)

I tried having Ding re-create the sound reference whenever it needs to play it, and it seems to do the trick. Here's how it works:

SoundEvent recreate = new SoundEvent(new ResourceLocation("mymod:mysound"));
Minecraft.getInstance().getSoundHandler().play(SimpleSound.master(recreate, 1));

Obviously you'd have to change that up to work with the Ding config file, but from my testing this fixes the problem I outlined above.

Here's a gist of Ding.java for the 1.15.2 with my changes.

Edit after some more testing

Alright, I've done some more digging around. It looks like Ding only has this problem when the sounds are registered using Events, as described here. When using DeferredRegister (seen here), it works fine. I guess the problem was sorta on my end, after all.

For anyone else who has trouble with this, here's an example of how you register using DeferredRegister (at least in 1.15).

I think it would be good for you to add something about this to the mod page on CurseForge so others don't have to figure it out like I did! I love the mod.

@TheNathanSpace TheNathanSpace changed the title Ding is unable to access registered sounds in other mods Ding is unable to access sounds from other mods when those mods register them using RegistryEvent Nov 9, 2020
@iChun
Copy link
Owner

iChun commented Mar 1, 2021

Wait, wasn't this fixed in 1.2.0? It's behind a config that's disabled by default.

@iChun iChun closed this as completed Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants