This is an old revision of the document!
Table of Contents
Setting up a mod development environment
Prerequisites
- A Java Development Kit (JDK) for Java 8 (recommended) or newer https://adoptopenjdk.net/
- Any Java IDE, for example Intellij IDEA and Eclipse. You may also use any other code editors, such as Visual Studio Code.
Mod Startup
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.
Manual Steps
- Copy the starting files from fabric-example-mod (or from the Kotlin version, if you wish to use Kotlin,) excluding the
LICENSE
andREADME.md
files - as those apply to the template itself, not necessarily to your mod. - Edit
gradle.properties
:- Make sure to set
archives_base_name
andmaven_group
to your preferred values. - Make sure to update the versions of Minecraft, the mappings and the loader - all of which can be queried through this website - to match the versions you wish to target.
- Add any other dependencies you plan to use in
build.gradle
.
- Import the build.gradle file to your IDE. You may refer to the next section for specific IDE's.
- Happy modding!
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).
IntelliJ IDEA
If you are using IntelliJ IDEA by JetBrains, please follow these steps:
- Run
gradlew idea
first, then import the Project to IDEA. - In order to run/debug your project, go to menu
Run → Edit Configurations…
. InRun/Debug Configuration
dialog, findApplication > Minecraft Client
and changeUse classpath of module
form[ProjectName]
to[ProjectName].main
, then change forApplication > Minecraft Server
as well. After pressing OK, you will know see Minecraft Client and Minecraft Server now showing up at Run/Debug Toolbar.
Eclipse
If you are using Eclipse and you would like to have the IDE run configs you can run gradlew eclipse
.
Visual Studio Code
If you are using VSCode by Microsoft, please follow these instructions
Generator
You may also use GeneratorFabricMod by ExtraCrafTX, a convenient tool to automatically generate new fabric mods from template. Follow these steps:
- Download latest release of GeneratorFabricMod here and extract them.
- Make a new directory, then run a command shell there and type
path/to/GeneratorFabricMod/bin/GeneratorFabricMod
. - After letting it get its dependencies, follow the instructions and input required information.
- You're now done, just open the project folder with in your IDE.
MinecraftDev IntelliJ IDEA Plugin
If you are using IntelliJ IDEA you can use Earthcomputer's experimental fork of the MinecraftDev plugin. This fork adds support for automatically generating Fabric projects as well as some mixin related features like inspections and generating accessors. You can follow these instructions to install the plugin.
Getting started
Try adding an item or a block. It's also a good idea to visit Applying changes without restarting Minecraft.
Advice
- While Fabric API is not strictly necessary for developing mods, its primary goal is to provide cross-compatibility and hooks where the game engine does not, and as such it is highly recommended!
- Occasionally, with development of fabric-loom (our Gradle build plugin) issues may crop up which require resetting the cache files. This can be done by running
gradlew cleanloom
. Runninggradlew --stop
can also help with a few rare issues. - Don't hesitate to ask questions! We're here to help you and work with you to make your dream mod a reality.
Troubleshooting
Missing sounds
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
.