Jump to content

Read Capability of another mod


JdiJack

Recommended Posts

Hi all, I made two mods that for simplicity we will call Mod A and Mod B.
Mod A creates and adds a Capability<IMana> to EntityPlayer and works great. My requirement is to be able to read the capabilities of Mod A from mod B

Link to comment
Share on other sites

3 minutes ago, diesieben07 said:

Ehm, what? No, you don't re-create anything.

How do I make mod B obtain the capability? In the Mod A I just do:

IMana mana = player.getCapability(ModCapabilities.MANA, null);
if(mana!=null){
	int value = mana.getMana();
}

 

The problem is that Mod B does not know the "IMana and ModCapabilities.MANA" classes

Link to comment
Share on other sites

You need to create the dependency, and make sure Mod A is present (in deobfuscated form) in the dev environment for Mod B as well the eventual run environment (in obfuscated form) for the user. Basically Mod A becomes a library to Mod B.

 

Here's what I think you need to do (others can correct me):

  • You would specify the dependency in Mod B's @Mod annotation. You would specify that Mod A loads before Mod B generally.
  • Fill in the dependencies block in your build.gradle. (I think there are comments in the template that will guide you.)
  • Add the deobfuscated version of Mod A source code jar to your Mod B project class path. I think that when you build your Mod A jar it also creates a deobfuscated version, but maybe you need to run special build option.
  • Recommended to add a dependencies section in mcmod.info. This is informational.

 

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.
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.