Jump to content

Capability usage across mods


TheGreyGhost

Recommended Posts

Howdy folks

I'm currently investigating Forge Capabilities and there's one aspect that I haven't figured out yet.

If I want to access a Capability introduced by another mod, how am I supposed to do that?

 

For inbuilt Capability (such as CapabilityItemHandler) it's no problem, but for anything defined by another mod I can't see an obvious way to access the Capability and its interface (unless of course I include the mod source as a library / dependency).

 

How is that intended to work?  

 

-TGG

 

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

You use @CapabilityInject to inject the other mod's capability. You can put this annotation on a method too (see the javadocs) and that method will then only be called if the other mod is present.

In that method you can then enable your mod's compatibility features. If you put this method in a separate class that class will never load unless the other mod is present.

OK.  So I still need to include that mod's source (or just the jar?) as a library, but if the other mod isn't present then my code will still run (even though the capability interface isn't present).

 

Could you point me in the direction of a working example?

 

TGG

 

 

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.