Posted May 13, 20223 yr Hi. Sorry in advance if this question was asked, but I couldn't find any instance of it on here. My question is, can (and if yes, then how) I use org.reflections on other loaded mods? I tried looking it up online, but I couldn't get it to work. More specifically, I wanted to look for classes extending a certain class in another mod. I know it should look something like this, but I'm not sure what to put into parameters in new Reflection(). (It's worth noting that I already have the ModContainer as well as ModObject of the mod I want to modify in a variable if that helps) Reflections reflections = new Reflections("package.goes.here"); Set<Class<? extends CertainClass>> CertainClassSet = reflections.getSubTypesOf(CertainClass.class); Any help from you all is appreciated, and again, sorry if this question was asked / is basic.
May 13, 20223 yr Author Just now, diesieben07 said: This is a bad idea. Why do you need subtypes of a class? I wanted to get all classes extending Screen for a thing I was doing. Speaking more generally, I am looking for a way to "modify" the other's mod behaviour without getting into bytecode manipulation (Getting all Screen classes was not a part of that, I wanted to test something out). I was looking for something similiar to the Harmony.Lib in C#.
May 13, 20223 yr Author 1 minute ago, diesieben07 said: I don't know C#. Getting all subclasses for a class involves classpath scanning, which is not a trivial task at all. I would recommend the ClassGraph library, which is well maintained and supports the Java module system (which Forge now uses) as well. However I would ask you to please describe what you want to do more clearly. Most likely there are better ways to achieve what yoou want. I'll try to describe what I want to achieve: The mod that I'm trying to modify has some custom GUI's, which I want to open by my mod. My thinking was, if I can get all Screen classes, I can search for the one I need and open it if you know what I mean.
May 13, 20223 yr Author 5 minutes ago, diesieben07 said: Why does this need to be so dynamic? Just reference the screen class you want to open directly. How would one go about opening a GUI from an abstract class?
May 13, 20223 yr Author 1 minute ago, diesieben07 said: You cannot instantiate an abstract class. This has nothing to do with classpath scanning or anything, this is basic Java. My bad, I was looking at the wrong class. : /
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.