I'm trying to code a compatibility mod for Minecraft that uses mixins to add compatibility with optional dependencies. The mod is an addon to an existing mod called Pet Cemetery and has a mixin that adds compatibility with others mods that add TameableAnimal's. However it also has several lines of code specifically for if a couple of extra mods are added that need special compatibility. These mods should be optional however it is crashing without them because it is calling their classes at runtime.
I've been tentatively consulting with ChatGPT on how to ensure that the methods and classes are not directly called at runtime but can still be called if the mod's are loaded. ChatGPT has suggested Reflection and I wanted to get you guy's opinions on this. My old Java professor briefly talked to us about Reflection and all I really know is that it's very advanced and can be dangerous if done improperly so I was hoping you guys could shed some light on this and whether chatGPT is giving me bad advice.