Forgix is a brand-new tool that allows Minecraft modders to combine numerous mod-loaders into one jar!
What is it?
Forgix is a tool that is used to combine numerous mod-loaders into a single jar.
How does this benefit me as a regular user?
You don’t need to know much about Forgix as this is a tool for developers, but the mods you use may simply have a single file that you need to download, so you don’t have to worry about which mod-loader you’re installing for.
Is it stable enough for production use?
Yes, in its current state, it is quite ready for production usage and has worked on all mods I’ve tested and should work on your mod as well, even if your mod’s code base is very cursed. If anything breaks, simply open an issue on GitHub.
You could wait for update ‘1.3.0,’ which improves stability and adds a few new features though that update would release anytime between now and 4096-01-01T00:00:00Z.
How it all began
Forgix began as an experiment to see if I could merge multiple mod-loaders into one; I know it’s possible (despite the fact that a lot of people said it wasn’t), and after a lot of trial and error I managed to make a working prototype for semi-automatic jar merging, which was actually quite bad and was hard-coded to only work with the mod I was working on.
After realizing that it was doable, I rewrote the entire thing so that it could be used by the public, and so Forigx was born (the name is generated by an AI).
How it works
Forgix makes advantage of a JVM feature that only loads the classes that are called; by altering the packages slightly, we can make it such that each mod-loader calls its own package and does not interfere with other mod-loaders.
So, for example, Quilt goes into quilt.mod.json and calls the entry-point from there, but we’ve updated the packages so that it only calls Quilt entry-points and not other mod-loader entry-points, and JVM will never load other classes since Quilt would never call them.
Usage and Documentation
First apply the plugin in your root build.gradle
Applying the plugin
Groovy
Using the plugins DSL:
Click to view
plugins {
id "io.github.pacifistmc.forgix" version "<version>"
}
Using the legacy plugin application:
Click to view
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.github.pacifistmc.forgix:Forgix:<version>"
}
}
apply plugin: "io.github.pacifistmc.forgix"
Kotlin
Using the plugins DSL:
Click to view
plugins {
id("io.github.pacifistmc.forgix") version "<version>"
}
Using the legacy plugin application:
Click to view
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("io.github.pacifistmc.forgix:Forgix:<version>")
}
}
apply(plugin = "io.github.pacifistmc.forgix")
Remember to change <version>
with the latest version! You can get the latest version from Forgix Version.
Then configure it to work with your mod! This process is going to be automatic in the future but I haven’t gotten time to make that yet.
Configuring the plugin to make it work
This is the normal configuration that by default should work on almost all mods.
forgix {
group = "org.example.mod"
mergedJarName = "example-mod"
}
The group
is the common package name for your mod and the mergedJarName
is going to be the name of the merged jar that it’s going to create, if the mergedJarName
doesn’t have an extension then it’s going to give it the extension jar
but keep in mind that sometimes the version number might be detected as an extension which at that point it won’t give it the extension jar
and you’ll have to manually do that.
Running the task mergeJars
(after running build
) would create the merged jars in the Merged
folder. (In the future this might be in the build/libs/merged
folder)
If you don’t want to run mergeJars
manually then you could add this. (In the future this might be the default behavior)
subprojects {
// ...
build.finalizedBy(mergeJars)
assemble.finalizedBy(mergeJars)
}
Documentation for each Forgix configuration!
Click to view
Root container (“forgix”)
-
group
(String)- This is the common package name for your mod; it is usually the maven group.
- A required value for now.
-
mergedJarName
(String)- This is the output jar’s name. If the name does not contain an extension, the extension
jar
is added; however, it sometimes identifies the version number as an extension and does not add it; in that case, you need to manually add thejar
extension to the name. - A required value for now.
- This is the output jar’s name. If the name does not contain an extension, the extension
-
removeDuplicate
(String)- This removes a duplicate package from the merged jar. For example, if you have a core package that is replicated across all mod-loaders but doesn’t need to be then you might use this to remove the duplication.
- This can be used numerous times to remove multiple duplicates, but if there are a lot of them then it’s best to use ‘removeDuplicates’ which accepts a list.
Forge sub-container (“forge”)
-
projectName
(String)- This is the name of the Forge project. This is set to “forge” by default.
-
jarLocation
(String)- This is the location of the built Forge jar from the project that’s specified in
projectName
. By default, this retrieves the jar with the shortest name, which is quite scuffed but I don’t know how to retrieve the built jar without relying on loom or something similar, hopefully it’ll be better in the future though!
- This is the location of the built Forge jar from the project that’s specified in
-
additionalRelocate
(String, String)- Simply put, this allows you to define more
group
s, which is useful for relocating libraries. - This can be used numerous times to specify multiple relocations.
- Simply put, this allows you to define more
-
mixin
(String)- This exists because Forge can be a nuisance at times, and sometimes Forge does something strange where we can’t actually identify mixins the normal way. However, if we don’t automatically detect the mixins, then this should be used to specify the mixins explicitly.
- This can be used numerous times to specify multiple mixins.
Quilt sub-container (“quilt”)
-
projectName
(String)- This is the name of the Quilt project. This is set to “quilt” by default.
-
jarLocation
(String)- This is the location of the built Quilt jar from the project that’s specified in
projectName
. By default, this retrieves the jar with the shortest name, which is quite scuffed but I don’t know how to retrieve the built jar without relying on loom or something similar, hopefully it’ll be better in the future though!
- This is the location of the built Quilt jar from the project that’s specified in
-
additionalRelocate
(String, String)- Simply put, this allows you to define more
group
s, which is useful for relocating libraries. - This can be used numerous times to specify multiple relocations.
- Simply put, this allows you to define more
Fabric sub-container (“fabric”)
-
projectName
(String)- This is the name of the Fabric project. This is set to “fabric” by default.
-
jarLocation
(String)- This is the location of the built Fabric jar from the project that’s specified in
projectName
. By default, this retrieves the jar with the shortest name, which is quite scuffed but I don’t know how to retrieve the built jar without relying on loom or something similar, hopefully it’ll be better in the future though!
- This is the location of the built Fabric jar from the project that’s specified in
-
additionalRelocate
(String, String)- Simply put, this allows you to define more
group
s, which is useful for relocating libraries. - This can be used numerous times to specify multiple relocations.
- Simply put, this allows you to define more
Custom sub-container (“custom”)
Because I’m not going to develop a new container for each mod-loader, this is the one that handles everything else. Yes, this can handle Fabric and Quilt but not Forge. This configuration can be used numerous times to specify multiple loaders.
-
projectName
(String)- This is the name of the project.
- This is a required value.
-
jarLocation
(String)- This is the location of the built jar from the project that’s specified in
projectName
. By default, this retrieves the jar with the shortest name, which is quite scuffed but I don’t know how to retrieve the built jar without relying on loom or something similar, hopefully it’ll be better in the future though!
- This is the location of the built jar from the project that’s specified in
-
additionalRelocate
(String, String)- Simply put, this allows you to define more
group
s, which is useful for relocating libraries. - This can be used numerous times to specify multiple relocations.
- Simply put, this allows you to define more
An example of a complete Forgix configuration
forgix {
group = "org.example.mod" // (Required Value)
mergedJarName = "example-mod" // (Required Value)
outputDir = "build/libs/merged"
forge {
projectName = "forge"
jarLocation = "build/libs/example-mod.jar"
additionalRelocate "org.my.lib" "forge.org.my.lib"
additionalRelocate "org.my.lib.another" "forge.org.my.lib.another"
mixin "forge.mixins.json"
mixin "forge.mixins.another.json"
}
fabric {
projectName = "fabric"
jarLocation = "build/libs/example-mod.jar"
additionalRelocate "org.my.lib" "fabric.org.my.lib"
additionalRelocate "org.my.lib.another" "fabric.org.my.lib.another"
}
quilt {
projectName = "quilt"
jarLocation = "build/libs/example-mod.jar"
additionalRelocate "org.my.lib" "quilt.org.my.lib"
additionalRelocate "org.my.lib.another" "quilt.org.my.lib.another"
}
custom {
projectName = "sponge" // (Required Value)
jarLocation = "build/libs/example-mod.jar"
additionalRelocate "org.my.lib" "sponge.org.my.lib"
additionalRelocate "org.my.lib.another" "sponge.org.my.lib.another"
}
custom {
projectName = "spigot" // (Required Value)
jarLocation = "build/libs/example-mod.jar"
additionalRelocate "org.my.lib" "spigot.org.my.lib"
additionalRelocate "org.my.lib.another" "spigot.org.my.lib.another"
}
removeDuplicate "org.example.mod.core"
}
This project feels dead
Depending on how far in the future you are, it very well could be. I am not going to update this every day; all future updates will be bug fixes for issues I haven’t found, quality of life improvements, or resolving that one minecraft mod that won’t work due to how cursed its codebase is.
This tool has completed its function it was designed for.