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

[1.15.2] Reading variables from other mods without creating a dependency


Recommended Posts

Is it possible? I want to get some values from other mods, when certain events happen like for example from the mod Nyx I need to know when the Blood Moon is happening, but I don't want to add this mod as a direct dependency in my mod, I want it to only get this variable from the Nyx if the player have the Nyx mod installed. I need that because in fact I need to integrate my mod with a couple of other mods

Link to comment
Share on other sites

3 hours ago, titaniuns said:

I want it to only get this variable from the Nyx if the player have the Nyx mod installed.

That's still a dependency, but it's a soft dependency. What you're saying is that 'can I read a variable without a hard dependency'. Yes, you still need to compile your mod with the code and support some information on it; however, it is possible. You will need to add the information in the mods.toml and specify that it isn't mandatory. From there, you will need extra care to make sure that the mod is present through the use of the ModList or OptionalMod.

Link to comment
Share on other sites

Going off of what Ash said, a soft dependency is easy to implement. Below is one way. In your build.gradle, if you add the following plugin line at the top:

apply plugin: 'maven-publish'

Then in the dependencies section of the same file you can add a line such as (if we were adding the JEI mod):

implementation fg.deobf("curse.maven:jei:2995910")

Where the string of numbers is part of the web address for the specific version of the mod on curseforge. Then when you refresh your workspace, the mod should download as an external library (if the source is available). The plugin is also used for publishing to a maven repository, but the repository function isn't necessary if you're only using it to add a soft dependency (if you want to use it in that way though, go ahead)

Edited by urbanxx001
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.

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.


  • Create New...

Important Information

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