The Meaning of Life, the Universe, and Everything.
Join Date:
9/26/2014
Posts:
274
Minecraft:
Arcaratus
Member Details
Hello world! This here is a tutorial on how to write addons for existing mods that offer APIs (Application Programming Interface for all you computer nerds )that allow people to do so. Since there aren't any clear explanations on this topic (even I had LOTS of trouble figuring it all out) and some may be confusing/misleading, I decided to write this tutorial to make it easier for others to write addons.
1. Setup development environment:To start out with your addon, you need to first check if the mod you are writing it off of allows you to do so; some mods may not have APIs or may not allow you to do so, so make sure to check if you can. Once that is done, follow these instructions to install Minecraft Forge on your computer:
0. Get your preferred IDK (Integrated Development Environment) either Eclipse or Intellij.
1. Get the latest Minecraft Forge -->SRC<-- for your Minecraft version (1.7.10) here.
2. Extract the .zip file into your desired modding location.
3. In the place where you extracted all the files, SHIFT-right click and click the option listed as: Open command window here.
4. In the following Command Prompt, type in: gradlew setupDecompWorkspace and run it. It will download Forge, MCP and other things so it might take awhile, be patient.
5. After it is done, type in: gradlew and depending on your IDK, either type in: eclipse or idea after and run it. This sets up your IDK and stuffs. After it is done, you can now access the folder named: src with your IDK and start modding!
2. If you are making an addon: Check and see if the mod you are writing an addon for has a separate file labled: deobf or dev. Download it and make a folder named: libs in your modding directory. Place the file in there. Now in your IDK, set that file as a dependency. Congratulations! You can now make addons using the parent mod!
--Tips on making addons:
1. In your mod class, add: dependencies = "required-after:(your parent mod)" to the @Mod annotation. This makes it so that your addon requires the parent mod making it generally better for the mod.
2. On methods that you only want to fire when certain mods are installed, you can add the annotation: @Optional.Method(modid = "(mod ID of that mod)"). You can also use: @Optional.Interface for interfaces.
To finish and compile your mod, SHIFT-right click inside the modding directory again and select: Open command window here again. Type in: gradlew build and (if your mod has no errors or problems) it will then compile it! Once it is done, the finished .jar file will be located in the build folder, and inside of that, the libs folder.
--If you have any comments or suggestions, please feel free to post them! This is my first tutorial, and I would definitely appreciate feedback! Also, check out my addon, Blood Arsenal for Blood Magic here!
How does relate to the actual API? Taking Blood Magic as an example, you can download the deobf version, or an actual "API" download. Is there a difference?
The Meaning of Life, the Universe, and Everything.
Join Date:
9/26/2014
Posts:
274
Minecraft:
Arcaratus
Member Details
You would usually just download the deobf version. The API download just contains the API for packaging with other mods, the deobf version contains everything.
So, am I right in saying that were you to install an addon, you could also install the API to make the mod work without actually having any of the original mod's features?
The Meaning of Life, the Universe, and Everything.
Join Date:
9/26/2014
Posts:
274
Minecraft:
Arcaratus
Member Details
Outside of the src folder
Technically you can put it wherever you want since you specify the IDE on where to find libraries but anything that doesn't belong in the src folder should not be in the src folder!
Thanks for the answer - okay, after removing the the second "required" Minecraft loads up without immersive engineering. I guess this is good. But now I have to figure out how to link the dependency. Can you tell me how this is done or give me a link, please? (I hope this question doesn't seam too stupid, I am just doing this for fun. I am not a professional programmer, so...)
I'm not sure exactly what you mean, but if you want Forge to tell the user that your mod requires Immersive Engineering you can list its mod id in the mcmod.info file (see here). The mcmod.info file supports both hard and soft dependencies and is arguably easier to use than the tags in the @Mod annotation.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
The Meaning of Life, the Universe, and Everything.
Join Date:
9/26/2014
Posts:
274
Minecraft:
Arcaratus
Member Details
You can either link it through build.gradle (don't ask me how, I don't remember) or in your IDE, you should be able to do something along the lines of "Project Structure -> Modules" and add a Dependency there
Well, no that is not my problem. I would like to create an addon for Immersive Engineering. I figured out that one must create an libs folder putting the jar of the parent mod into. Then as mentioned elsewhere on this forum one should set up the build path in eclipse. But obviously to set up the build path is a wrong approach, because it doesn't work. The dependency must be linked in eclipse somehow...But I don't know how to do this. That was my question. How do I tell eclipse to use the parent mod and load it in so I can refer to its classes?
Using eclipse, I open show the contents of the Referenced Libraries folder. Then I right click on any file there and select Build Path > Configure Build Path. It will bring up a window showing all the referenced libraries with a few other buttons. Click Add External Jar and find the deobfuscated mod you want to reference. It does not strictly have to be in the libs folder but consistency is good.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Using eclipse, I show the contents of the Referenced Libraries folder. Then I right click on any file there and select Build Path > Configure Build Path. It will bring up a window showing all the referenced libraries with a few other buttons. Click Add External Jar and select the deobfuscated mod you want to reference. It does not strictly have to be in the libs folder but consistency is good.
Do exactly this with the deobfuscatedor dev version of the mod's jar file to reference it with Eclipse. You can technically use the obfuscated version, but it will not be able to run in the deobfuscated development environment.
You will then be able to see and reference its classes the same way you see and reference the ForgeSrc jar.
Here's an example image (from 1.7.2 that I found randomly on the Internet) of the Referenced Libraries folder. You can right-click on ForgeSrc (called ForgeBin in this image) or the Referenced Libraries folder to find the Configure Build Path option.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Hello world! This here is a tutorial on how to write addons for existing mods that offer APIs (Application Programming Interface for all you computer nerds )that allow people to do so. Since there aren't any clear explanations on this topic (even I had LOTS of trouble figuring it all out) and some may be confusing/misleading, I decided to write this tutorial to make it easier for others to write addons.
1. Setup development environment: To start out with your addon, you need to first check if the mod you are writing it off of allows you to do so; some mods may not have APIs or may not allow you to do so, so make sure to check if you can. Once that is done, follow these instructions to install Minecraft Forge on your computer:
0. Get your preferred IDK (Integrated Development Environment) either Eclipse or Intellij.
1. Get the latest Minecraft Forge -->SRC<-- for your Minecraft version (1.7.10) here.
2. Extract the .zip file into your desired modding location.
3. In the place where you extracted all the files, SHIFT-right click and click the option listed as: Open command window here.
4. In the following Command Prompt, type in: gradlew setupDecompWorkspace and run it. It will download Forge, MCP and other things so it might take awhile, be patient.
5. After it is done, type in: gradlew and depending on your IDK, either type in: eclipse or idea after and run it. This sets up your IDK and stuffs. After it is done, you can now access the folder named: src with your IDK and start modding!
2. If you are making an addon: Check and see if the mod you are writing an addon for has a separate file labled: deobf or dev. Download it and make a folder named: libs in your modding directory. Place the file in there. Now in your IDK, set that file as a dependency. Congratulations! You can now make addons using the parent mod!
--Tips on making addons:
1. In your mod class, add: dependencies = "required-after:(your parent mod)" to the @Mod annotation. This makes it so that your addon requires the parent mod making it generally better for the mod.
2. On methods that you only want to fire when certain mods are installed, you can add the annotation: @Optional.Method(modid = "(mod ID of that mod)"). You can also use: @Optional.Interface for interfaces.
To finish and compile your mod, SHIFT-right click inside the modding directory again and select: Open command window here again. Type in: gradlew build and (if your mod has no errors or problems) it will then compile it! Once it is done, the finished .jar file will be located in the build folder, and inside of that, the libs folder.
--If you have any comments or suggestions, please feel free to post them! This is my first tutorial, and I would definitely appreciate feedback! Also, check out my addon, Blood Arsenal for Blood Magic here!
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
How does relate to the actual API? Taking Blood Magic as an example, you can download the deobf version, or an actual "API" download. Is there a difference?
You would usually just download the deobf version. The API download just contains the API for packaging with other mods, the deobf version contains everything.
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
So, am I right in saying that were you to install an addon, you could also install the API to make the mod work without actually having any of the original mod's features?
Technically yes, but the deobf version allows you access the entire mod.
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
OK, thanks. I think I get it now. Actually trying it will have to wait until I have the time, but at least your explanation has made it clearer.
Thanks for the tutorial!
Diamonds for you
Oh and in the required-after() Do we put the mod id or the mod's file name?
I am taking mod requests. If the mod can be done in an hour, or I like the idea, I will do it.
The Mod ID
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
Outside of the src folder
Technically you can put it wherever you want since you specify the IDE on where to find libraries but anything that doesn't belong in the src folder should not be in the src folder!
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
Tinker's is tricky. I would just highly recommend using Maven in your build.gradle file to grab it as a dependency.
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
isnt eclipse and intelij and IDE and not a IDK
is the dev version a folder or a jar?
Usually a jar
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
I'm trying to make my mod addon-compatible. Exactly how do I export a de-obfuscated version?
Edit: after a bit of searching I found this thread. After editing your gradle.build file you will run gradlew deobfJar
You have to link it as a dependency through your IDE, not Java Build Path
EDIT: Sidenote, when adding more than one 'required-after:...", it should be like this:
"required-after:(parent mod ID);after:(next mod ID)" etc. Just repeat the "after:", not the "required-after:"
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
I'm not sure exactly what you mean, but if you want Forge to tell the user that your mod requires Immersive Engineering you can list its mod id in the mcmod.info file (see here). The mcmod.info file supports both hard and soft dependencies and is arguably easier to use than the tags in the @Mod annotation.
You can either link it through build.gradle (don't ask me how, I don't remember) or in your IDE, you should be able to do something along the lines of "Project Structure -> Modules" and add a Dependency there
Creator of Blood Arsenal and Sleep! Contributor to Blood Magic!
Using eclipse, I open show the contents of the Referenced Libraries folder. Then I right click on any file there and select Build Path > Configure Build Path. It will bring up a window showing all the referenced libraries with a few other buttons. Click Add External Jar and find the deobfuscated mod you want to reference. It does not strictly have to be in the libs folder but consistency is good.
Do exactly this with the deobfuscated or dev version of the mod's jar file to reference it with Eclipse. You can technically use the obfuscated version, but it will not be able to run in the deobfuscated development environment.
You will then be able to see and reference its classes the same way you see and reference the ForgeSrc jar.
Here's an example image (from 1.7.2 that I found randomly on the Internet) of the Referenced Libraries folder. You can right-click on ForgeSrc (called ForgeBin in this image) or the Referenced Libraries folder to find the Configure Build Path option.
How do I set it to require a specific version of my mod?