Setup
Basics
- Conventions and Terminology
- Registries
- Development Tools
There are two main ways to make a new mod for Minecraft based on Fabric. You can either manually download fabric-example-mod and setup by yourself, or use automatic tools for you.
LICENSE
and README.md
files - as those apply to the template itself, not necessarily to your mod.gradle.properties
:archives_base_name
and maven_group
to your preferred values.build.gradle
.
You can generate the Minecraft sources for reference (since IDEA already has a decompiler this is only useful for searching through the code) :
Run the genSources
Gradle task. If your IDE doesn't have Gradle integration, then run the following command in the terminal: gradlew genSources
(or ./gradlew genSources
on Linux/MacOS).
If you are using IntelliJ IDEA by JetBrains, please follow these steps:
Optional, but recommended: By default, IntelliJ delegates to Gradle to build the project. This is unnecessary for Fabric and causes longer build times and hotswapping related weirdness, among other problems. To make it use the builtin compiler:
$PROJECT_DIR$/out
.Unfortunately, it is currently impossible to set an IDE-wide default for the 'Build and run using' and 'Run tests using' options, so these steps have to be repeated for every new project.
NOTE: Don't run ./gradlew idea
as it messes up with gradle and breaks develop environment.
If you are using Eclipse and you would like to have the IDE run configs you can run gradlew eclipse
.
If you are using VSCode by Microsoft, please follow these instructions
If you are using IntelliJ IDEA you can use the MinecraftDev plugin. This plugin adds support for automatically generating Fabric projects as well as some mixin related features like inspections, generating accessors/shadow fields, and copying Mixin Target References (JVM Descriptors). The plugin can be found in the IntelliJ plugin repository, so you can install it using IntelliJ's internal plugin browser by navigating to File → Settings → Plugins, then clicking the Marketplace tab and searching for Minecraft.
If you are unable to use the MinecraftDev plugin or the fabric-example-mod repo, you may also use GeneratorFabricMod by ExtraCrafTX, a convenient tool to automatically generate new fabric mods from template. Follow these steps:
path/to/GeneratorFabricMod/bin/GeneratorFabricMod
.Try adding an item or a block. It's also a good idea to visit Applying changes without restarting Minecraft.
gradlew cleanloom
. Running gradlew --stop
can also help with a few rare issues.
Sometimes, when importing the Gradle project into an IDE, the assets might not download correctly. In this case, run the downloadAssets
task manually - either using IDE's built-in menu or by simply running gradlew downloadAssets
.