Jump to content

[Solved] [1.10.2] Using Mod API Without Using Dependencies


WillR27398

Recommended Posts

Your question is a bit two-sided when it comes to what you mean.

How to check if a mod is loaded?

if(Loader.isModLoaded("other_mod's_modid"))
//do stuff with things from this mod.

 

How to get rid of dependency, but still make use of X.

Dependency is the easiest and most stable way of getting cross-mod interactions. That has to be said.

However, for simple things like entities, items, blocks etc, they can all be accessed from strings (Item.getByNameOrId(modid:name), Block.getBlockFromName(modid:name) and EntityList.NAME_TO_CLASS.get(name)) though they should always have null checks, case their name changes or they are, as mentioned, not installed together with your mod.

 

However, for full and complete freedom from dependencies, you want to learn about java reflection, and find classes from strings, instantiate them from scratch, which would be very prone to complete failure should a single thing change in a constructor.

 

It's a long and twisted road to go down if you are not quite adapt with Java. You sure you want to go down it?

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Thanks, that clears everything up that I wanted to know, whether you fully understood what I was trying to say anyway xD For the most part I will just be using other mod's blocks/items so what you said will work fine, but then if there is any other classes I need then I might as well learn reflection at some point, but it most likely won't be necessary for what I want to do.

 

Thanks again :)

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.