Posted March 20, 20214 yr I'm once again asking about mod compatibility :v This time, it's more of a curiosity than a necessity, as I've already come up with a solution to my problem, but I was wondering: How do you run some code in 1.16 only if a mod is present? I know there is ModList.get().isLoaded(<modid>) but if I import a class that isn't loaded it will still break.
March 20, 20214 yr Author 12 minutes ago, diesieben07 said: Imports are a compiler fiction, once your code is compiled there are no imports (only fully qualified class names). Huh, I didn't know that! So an import is just a thing to help code readability? 12 minutes ago, diesieben07 said: However yes, you are right, you can't just reference a class which might potentially be absent. A good choice for this is to have an interface (this can't reference any of the other mod's classes) and two implementations - one for when the mod is loaded and one for when it isn't. Oh, I saw a post of yours from a few years ago describing this process, but I wasn't sure if it still applied today. I'll do that then, thanks! Edited March 20, 20214 yr by A Soulspark
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.