Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Sound Registry object returning as null


skip999
 Share

Recommended Posts

Hello,

I have been attempting to make a custom armor equip sound for a set of custom armor that I have made. I have registered the sound properly, but I have run into a problem: even though the sound is registered before the armor items are, the sound is returning as null for some reason. I know the sound works and is set up properly, so it must be something with registration. I have attached the crash report as well as linked the relevant classes from my github:

Armor Type: https://github.com/skiprocks999/Electrodynamics-Fork/blob/01b65b032b3cce7c5b5e71485af1c2f24e7874a3/src/main/java/electrodynamics/common/item/gear/armor/types/composite/CompositeArmor.java#L10

Sound Registry: https://github.com/skiprocks999/Electrodynamics-Fork/blob/01b65b032b3cce7c5b5e71485af1c2f24e7874a3/src/main/java/electrodynamics/SoundRegister.java#L13

Item Registration: https://github.com/skiprocks999/Electrodynamics-Fork/blob/01b65b032b3cce7c5b5e71485af1c2f24e7874a3/src/main/java/electrodynamics/DeferredRegisters.java#L300

Registry Registration in Mod Class: https://github.com/skiprocks999/Electrodynamics-Fork/blob/01b65b032b3cce7c5b5e71485af1c2f24e7874a3/src/main/java/electrodynamics/Electrodynamics.java#L59

 

I imagine I'll kick myself when the problem is found. Any help would be appreciated!

crash-2021-08-01_09.58.28-fml.txt

Link to comment
Share on other sites

3 minutes ago, skip999 said:

Here you are trying to access the sound event from the class initialization. But that sound event is only available after the sound registry event has fired. From a static initializer you cannot guarantee this is the case. Your CompositeArmor should store the RegistryObject, not the SoundEvent. Then just call get in getSoundEvent.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.