To develop mods, a Java Development Kit (JDK) is required. Visit https://adoptium.net/releases.html for installers. If you are professional, you can obtain a JDK from http://jdk.java.net/, which needs to be extracted and have system variables set up manually.
More information about installing Java can be found:
Before writing your code, you install have any Java IDE installed, for example Intellij IDEA and Eclipse. You may also use any other code editors, such as Visual Studio Code.
If you are not familiar with any of these, we recommend to use Intellij IDEA as that is what most people choose for modding.
Detailed tutorial can be found on Fabric Documentation
There are multiple ways to create a project:
After creating a project, please edit some key files as you wish:
gradle.properties
:archives_base_name
and maven_group
to your preferred values.build.gradle
.fabric.mod.json
:As of Minecraft 1.19.2, Fabric API's mod ID has changed fromfabric
tofabric-api
. When backporting from 1.19.2 to earlier versions, you must alter thedepends
section of yourfabric.mod.json
to expectfabric
.
If you are using IntelliJ IDEA by JetBrains, please follow these steps:
ideaSyncTask
gradle task to generate run configurations.
NOTE: Don't run the idea
gradle task. It is known to break development environment.
If you are using IntelliJ IDEA, it is highly recommended to install Minecraft Development plugin, which support automatically generating Fabric projects as well as some mixin related features like inspections, generating accessors/shadow fields, and copying Mixin Target References (JVM Descriptors).
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.
For launching Minecraft and start debugging, see Fabric Documentations.
If you are using Eclipse and you would like to have the IDE run configs you can run gradlew eclipse
. The project can then be imported as a normal (non-gradle) Eclipse project into your workspace using the 'File' - 'Import…' menu, then 'General' → 'Existing Projects into Workspace'.
If you are using VSCode, please follow these instructions.
Reading the Minecraft source is an essential part of modding. Unfortunately, we can't publish the Minecraft source because it violates the Minecraft EULA. You need to generate the Minecraft source yourself.
To generate the Minecraft source. run the genSources
gradle task.
If your IDE doesn't have gradle integration, run the following command in the terminal: gradlew genSources
(or ./gradlew genSources
on Linux/macOS).
It can take a while depending on your computer power.
You may need to refresh gradle after running the task.
See Reading the Minecraft source for how to read the source.
gradlew cleanloom
. Running gradlew --stop
can also help with a few rare issues.build.gradle
) and the Fabric Loader and Fabric API version for your mod (which is defined in build.gradle
or gradle.properties
). Latest version can be found in https://fabricmc.net/develop/. Even the old version Minecraft is supported by latest Loom and latest Fabric Loader.gradle/wrapper/gradle-wrapper.properties
. Old version Minecraft is supported by latest Gradle.gradle.properties
, you may also need to change the Java compatibility version in build.gradle
and the mixin config.
After running the genSources
gradle task in IntelliJ IDEA, check if the sources are attached properly. Open a Minecraft .class file and click on the “Choose Sources…” button on the top right of the screen. Select the jar with “-sources” at the end (e.g. .gradle\loom-cache\1.20.1\net.fabricmc.yarn.1_20_1.1.20.1+build.10-v2\minecraft-project-@-merged-named-sources.jar
)
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
.
Sometimes the run config may be invalid, reporting errors such as:
Could not find or load class net.fabricmc.devlaunchinjector.Main: java.lang.ClassNotFoundException
There are several fixes, among which one may be a potential fix:
.idea
folder entirely and then restart Intellij IDEA. The module will be reconstructed. You may need to specify Java versions again. If after restarting there is no run config, you can run gradle ideaSyncTask
then check it again.build.gradle
of your subproject exists, check whether the gradle plugin maven-publish
is enabled or applied to it. Try adding apply plugin: maven-publush
in the build.gradle
file, if it is not declared at all.-cp
) to other values.Sometimes you may come with some error like:
java.lang.ClassNotFoundException: net.fabricmc.loader.impl.launch.knot.KnotClient
java.lang.TypeNotPresentException: Type net/minecraft/util/Identifier not present
java.lang.RuntimeException: Minecraft game provider couldn't locate the game! The game may be absent from the class path, lacks some expected files, suffers from jar corruption or is of an unsupported variety/version.
This may be because the project path contains non-ASCII characters that may cause incompatibility. Try move the project to paths without non-ASCII characters, or in the run config of “Minecraft Client” and “Minecraft Server”, set “Shorten Command Line” from “@argfile (Java 9+)” to “none”. This also applies to the Data Generation run config.
Another potential fix, is to go to Region Settings in the Settings or Contral Panel of Windows, go to Region Settings, and enable “Beta: Use Unicode UTF-8 for worldwide language support”, and then reboot.
That may be because you're using Intellij IDEA to build and run. If issue happens, try open the 'Gradle Settings' dialog from the Gradle tab, and then change the 'Build and run using' and 'Run tests using' fields from 'IntelliJ IDEA' to 'Gradle (default)'.
Try adding an item or a block. It's also a good idea to visit Applying changes without restarting Minecraft.