Changes

27 bytes removed ,  08:33, 17 June 2022
Line 1: Line 1: −
=== Jar-In-Jar ===
   
Jar-in-Jar is a way to handle the dependencies of your mod.
 
Jar-in-Jar is a way to handle the dependencies of your mod.
 
Sometimes these are libraries pulled from a central maven repository, sometimes these are libraries specially designed for Minecraft and sometimes these are completely other mods.
 
Sometimes these are libraries pulled from a central maven repository, sometimes these are libraries specially designed for Minecraft and sometimes these are completely other mods.
Line 6: Line 5:  
Although there are several options available to achieve this, including for example the Shading plugin, this does not work all the time and can even cause problems along the way when for example two mods need the same dependency.
 
Although there are several options available to achieve this, including for example the Shading plugin, this does not work all the time and can even cause problems along the way when for example two mods need the same dependency.
 
Introducing the all-new, all-shiny: Jar-In-Jar.
 
Introducing the all-new, all-shiny: Jar-In-Jar.
 
+
====Central function====
==== Central function ====
   
Jar-In-Jar is first and foremost a way to load dependencies for mods, from the jars of the mods.
 
Jar-In-Jar is first and foremost a way to load dependencies for mods, from the jars of the mods.
 
To achieve this it looks for a file called: ''META-INF/jarjar/metadata.json''. If you are interested in the format of this file, see the following section of the JarJar library which we expose: [https://github.com/MinecraftForge/JarJar/tree/main/src/main/java/net/minecraftforge/jarjar/metadata JarJar Library - Metadata Source]  
 
To achieve this it looks for a file called: ''META-INF/jarjar/metadata.json''. If you are interested in the format of this file, see the following section of the JarJar library which we expose: [https://github.com/MinecraftForge/JarJar/tree/main/src/main/java/net/minecraftforge/jarjar/metadata JarJar Library - Metadata Source]  
Line 14: Line 12:     
During the startup of the game, FML will first collect all mods and then collect all their dependencies to load. Jar-In-Jar hooks into this second phase and reads all the dependency files (recursively) and then determines what versions of the dependencies to load.  
 
During the startup of the game, FML will first collect all mods and then collect all their dependencies to load. Jar-In-Jar hooks into this second phase and reads all the dependency files (recursively) and then determines what versions of the dependencies to load.  
 
+
====Dependency negotiation====
==== Dependency negotiation ====
   
Because different mods might need different versions of the same dependency (and have those included) Jar-In-Jar is first and foremost a negotiation system (hence you having to supply a version range your mod supports). From all dependencies that need to be loaded their supported version range is narrowed down to the agreeable range that all mods support. Then there are in principle three outcomes that can occur:
 
Because different mods might need different versions of the same dependency (and have those included) Jar-In-Jar is first and foremost a negotiation system (hence you having to supply a version range your mod supports). From all dependencies that need to be loaded their supported version range is narrowed down to the agreeable range that all mods support. Then there are in principle three outcomes that can occur:
 
# No agreeable version range is found: Loading can not continue and the user will see an error message that mods require different dependency versions which are not compatible.
 
# No agreeable version range is found: Loading can not continue and the user will see an error message that mods require different dependency versions which are not compatible.
Line 21: Line 18:  
# An agreeable version range is found, and a matching jar could be located: That dependency will be loaded.
 
# An agreeable version range is found, and a matching jar could be located: That dependency will be loaded.
   −
==== Dependency loading ====
+
====Dependency loading====
 
Once negotiation ends, the selected jars are loaded into the game.
 
Once negotiation ends, the selected jars are loaded into the game.
 
The class loading layer is determined in two ways:
 
The class loading layer is determined in two ways: