This project provides a Gradle project template that can compile mods for multiple modloaders using a common sourceset. This project does not require any third party libraries or dependencies. If you have any questions or want to discuss the project join the Discord.
This template uses the NyfsModdingTools Gradle plugin which provides:
- Version Catalog - Pre-configured dependencies for popular modding libraries
- Auto Package Sync - Automatically refactors package names when you change
groupormod_idingradle.properties - Constants Sync - Updates the
MODIDconstant in yourConstantsclass whenmod_idchanges - Entrypoint Sync - Updates
fabric.mod.jsonentrypoints when your initializer classes change
| Version | Loaders |
|---|---|
| 1.20.1 | Fabric, Forge |
| 1.21.1 | Fabric, NeoForge |
| 1.21.3+ | Fabric, NeoForge |
The following libraries are available through the version catalog with pre-configured versions for each Minecraft version:
| Library | Description | Lib String | Versions |
|---|---|---|---|
| GeckoLib | Animation library for entities and items | nyfs.geckolib.commonnyfs.geckolib.fabricnyfs.geckolib.neoforge |
1.20.1, 1.21.1, 1.21.3+ |
| SmartBrainLib | AI/Brain system utilities | nyfs.sbl.commonnyfs.sbl.fabricnyfs.sbl.neoforge |
1.20.1, 1.21.1, 1.21.3+ |
| CommonNetwork | Cross-loader networking library | nyfs.commonnetwork.commonnyfs.commonnetwork.fabricnyfs.commonnetwork.neoforge |
1.20.1, 1.21.1, 1.21.3+ |
| Forge Config API Port | Config API for Fabric/NeoForge | nyfs.config.api.commonnyfs.config.api.fabric |
1.20.1, 1.21.1, 1.21.3+ |
| MixinExtras | Extended Mixin functionality | nyfs.mixin.extras.commonnyfs.mixin.extras.fabricnyfs.mixin.extras.neoforge |
All versions |
| Fabric API | Fabric modding API | nyfs.fabric.api |
All Fabric versions |
| Cardinal Components | Component/capability system for Fabric | nyfs.cc.basenyfs.cc.entity |
1.20.1 |
| Capability Syncer | Capability sync utilities | nyfs.cap.syncer |
1.20.1 |
In your build.gradle files, reference libraries using the version catalog:
dependencies {
implementation nyfs.geckolib.common
implementation nyfs.sbl.common
implementation nyfs.commonnetwork.common
}For loader-specific modules:
dependencies {
implementation nyfs.geckolib.fabric
implementation nyfs.geckolib.neoforge
}The plugin provides a modDeps extension for managing mod dependencies with automatic metadata file modification. Use this in your loader-specific build.gradle files:
Mods that must be installed for your mod to work:
modDeps.requiredMod(nyfs.geckolib.fabric)
modDeps.requiredMod("geckolib", "4.8.3", nyfs.geckolib.fabric)- Adds to
modImplementation(Fabric) orimplementation(NeoForge) - Adds to
dependsinfabric.mod.json - Adds
type="required"inneoforge.mods.toml
Mods that add extra features but aren't required:
modDeps.optionalMod(nyfs.geckolib.fabric)
modDeps.optionalMod("geckolib", "4.8.3", nyfs.geckolib.fabric)- Adds to
modCompileOnly(Fabric) orcompileOnly(NeoForge) - Adds to
suggestsinfabric.mod.json - Adds
type="optional"inneoforge.mods.toml
Mods that are bundled inside your mod's jar:
modDeps.embeddedMod(nyfs.geckolib.fabric)
modDeps.embeddedMod("geckolib", "4.8.3", nyfs.geckolib.fabric)- Adds to
include+modImplementation(Fabric) orjarJar+implementation(NeoForge) - Adds to
dependsinfabric.mod.json - Adds
type="required"inneoforge.mods.toml
The plugin automatically modifies fabric.mod.json and neoforge.mods.toml in the output jar (not source files).
This guide will show how to import the MultiLoader Template into IntelliJ IDEA. The setup process is roughly equivalent to setting up the modloaders independently and should be very familiar to anyone who has worked with their MDKs.
- Clone or download this repository to your computer.
- Configure the project by editing the
group,mod_name,mod_author, andmod_idproperties in thegradle.propertiesfile. You will also need to change therootProject.nameproperty insettings.gradle, this should match the folder name of your project, or else IDEA may complain. - Open the template's root folder as a new project in IDEA. This is the folder that contains this README file and the gradlew executable.
- If your default JVM/JDK is not Java 21 you will encounter an error when opening the project. This error is fixed by going to
File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVMand changing the value to a valid Java 21 JVM. You will also need to set the Project SDK to Java 21. This can be done by going toFile > Project Structure > Project SDK. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. - Open the Gradle tab in IDEA if it has not already been opened. Navigate to
Your Project > Common > Tasks > vanilla gradle > decompile. Run this task to decompile Minecraft. - Open your Run/Debug Configurations. Under the Application category there should now be options to run NeoForge and Fabric projects. Select one of the client options and try to run it.
- Assuming you were able to run the game in step 7 your workspace should now be set up.
When you change the group or mod_id in gradle.properties, the plugin will automatically:
- Rename all package declarations and imports
- Move source files to the new package directory
- Update mixin configuration files
- Update
fabric.mod.jsonandneoforge.mods.toml - Update the
MODID/MOD_IDconstant in yourConstantsclass - Update entrypoints in
fabric.mod.jsonbased on detected initializer classes
Simply refresh your Gradle project after changing the properties.
When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the NeoForge or Fabric project.
Loader specific projects such as the NeoForge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects.
While the MultiLoader Template includes support for many platforms and loaders you can easily remove support for the ones you don't need. This can be done by deleting the subproject folder and then removing it from the settings.gradle file. For example if you wanted to remove support for Forge you would follow the following steps.
- Delete the subproject folder. For example, delete
MultiLoader-Template/forge. - Remove the project from
settings.gradle. For example, removeinclude("forge").