Jump to content

Recommended Posts

Posted

Hello,

 

I am trying to harvest annotation data from mods to do a similar thing to what @Mod.Instance and @SidedProxy do. I am doing this by subscribing to the FMLConstructionEvent, and using the ASM harvested data to inject the values.

 

This has been working great in the development environment, but when in a release build, it crashes with a NPE. ModContainer#getMod() returns null for other mods, causing the crash. I'm not sure if this is caused by the fact that they are ordered differently in the development environment or if it's something else.

 

You can view the source here: https://github.com/iLexiconn/LLibrary/blob/1.9.4/src/main/java/net/ilexiconn/llibrary/LLibrary.java

It crashes here: https://github.com/iLexiconn/LLibrary/blob/1.9.4/src/main/java/net/ilexiconn/llibrary/server/config/ConfigHandler.java#L54

 

Thanks in advance.

Posted

Hello,

 

I am trying to harvest annotation data from mods to do a similar thing to what @Mod.Instance and @SidedProxy do. I am doing this by subscribing to the FMLConstructionEvent, and using the ASM harvested data to inject the values.

 

This has been working great in the development environment, but when in a release build, it crashes with a NPE. ModContainer#getMod() returns null for other mods, causing the crash. I'm not sure if this is caused by the fact that they are ordered differently in the development environment or if it's something else.

 

You can view the source here: https://github.com/iLexiconn/LLibrary/blob/1.9.4/src/main/java/net/ilexiconn/llibrary/LLibrary.java

It crashes here: https://github.com/iLexiconn/LLibrary/blob/1.9.4/src/main/java/net/ilexiconn/llibrary/server/config/ConfigHandler.java#L54

 

Thanks in advance.

Posted

Don't use the

@Mod

annotation. The

ModContainer

already gives you the ModID.

That way your annotation can be in any class of the mod and it will also work for non-FML mods (e.g. coremods).

Thanks for your help!  :) mod.getMod() is still needed for field.set(), but it can be forced to be static like all other annotations.

Posted

Don't use the

@Mod

annotation. The

ModContainer

already gives you the ModID.

That way your annotation can be in any class of the mod and it will also work for non-FML mods (e.g. coremods).

Thanks for your help!  :) mod.getMod() is still needed for field.set(), but it can be forced to be static like all other annotations.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.