An easy-to-use template for creating fabric and neoforge mods using gradle for Minecraft 1.20.1 and 1.21+
- Create your repo
Click the "Use this template" button in the top right to create a repository, then clone & import your new repository into IntelliJ idea (or your preferred IDE)
Tip
Select "Include all branches" when creating the repository if you want both 1.21+ and 1.20.1
- Add mod info
Check the gradle.properties file and set your mod id, package, name and version - IDE integration
First, import your repo into IDEA and import the gradle project if it isn't importing already (this might take a while). Once done, run thegenSourcestask and then use the "download sources" button in your IDE. This ensures you have access to the Minecraft source code in all modules - Rename package
In thecommon,fabricandneoforgemodules, refactor the package name fromnet.yourpackage.yourmodto your actual package name. Also adjust the java file names and themodIDfield - Done
You can now enjoy modding in a multiloader setup! Working run configurations are automatically generated - just select the relevant one in the top right of your IDE window and run the game right from your IDE.
Note
For 1.20.1 Forge run configurations to show up, run the genIntellijRuns task and restart IDEA
A multiloader project consists of a root gradle project and three subprojects: common, fabric and neoforge.
The root project should not contain any code. It's build.gradle.kts file is used for some common configuration for all the subprojects.
The common subproject contains all the common mod code, which will be included in all built jars. It has access to all of Minecraft,
and the ability to add Access wideners and mixins (see the comments in it's build script), but no access to any modloader's API.
It's build.gradle.kts is the place to put most of your required dependencies.
The fabric and neoforge subprojects contain initialisation and loader-specific code, as well as loader-specific resources like fabric.mod.json and neoforge.mods.toml