Posted August 16, 201411 yr Hi, I created a mod that contains some base and utility classes. I'd like to reuse those in a second mod. Can I simply include the classes in my second mod or am I gonna run into class loading issues? What is the way to go? Do I need to create a separate jar file with those classes (without any @Mod annotated class) and use it as a library for my mods? How to proceed with ForgeGradle? Thanks a lot for your help.
August 16, 201411 yr Well, there are a few ways to go about this, but the most common practice would be to compile one into a jar and use it as a library for the second. Have a look as how you would implement a feature of buildcraft into your own mod for instance. There are tutorials about that and if you do the same thing you should be able to use it as a basic API. As for codewise, basically make your code very trans parant with lots of getters and setters and whatever methods you need to interact with your variables in your base mod. In other words, decent programming behaviour is a must. And you have to create it as if it is a mod if you want to use it in a forge environment. An Api is just another mod that you're using so there is nothing different from the usual ones.
August 16, 201411 yr Well, actually a utility mod is not the same thing as an API library. An API library use usually just a jar of java classes with source in a jar (and any jar of natives if it uses the JNI system). It is normally added to the build path and parts can be included in the final jar. A utility mod is one that is a dependency and is a full mod in its own right with either necessary linkage points or an API-only version. It can be made to be necessary or optional. Inter-mod coms can be useful in this case. There are other permutations and variants as well, but this seems to be the norm. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
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.