Tutorial: See Minecraft's code

The contents of this page are not supported by Mojang Studios or the Minecraft Wiki.
 
This tutorial is exclusive to Java Edition.
 
According to the license, decompiling Minecraft is allowed, but it is recommended not to release decompiled code. Furthermore, a tweet from Dinnerbone suggests usage of the mappings inside of projects by the community, such as modding (using them to decompile Minecraft for usage with Forge, Fabric, Quilt and other modloaders) or for usage in server software with plugins (such as Spigot, Bukkit, Paper, and others) is okay, and is an intended use. It should be noted however that this tweet is not legally withstanding, so while it is probably fine to use these mappings for such purposes, you do so at your own risk. This can be extended to decompiling and accessing Minecraft's code as a whole; the only things you should not do under any circumstances are releasing the code or releasing something that contains an exact copy of the code.

Since snapshot 19w36a, Mojang releases obfuscation maps for every version available in the launcher. Those maps can be used to deobfuscate a version's JAR file, that is to say, replace obfuscated class names and class member names with their original (deobfuscated) names. Using a decompiler, it is possible to reconstruct human-readable Java code.

Decompiling JAR

There are numerous ways of decompiling the Minecraft game source, see below.

Using third-party software

There is no official way of decompiling Minecraft's source code. You'd have to use a third-party software designed to process the obfuscation map provided by Mojang and decompile the game into a directory consisting of multiple human readable Java files. One of the third-party software you can use is MaxPixelStudios' MinecraftDecompiler.

The MinecraftDecompiler software is distributed in a JAR file, so you'd need Java to run it (see Tutorial:Update Java § Where to download). You can receive the latest JAR file from their GitHub release page.

Upon downloading, you'd need to open a command-line interface to run the JAR file. On Windows, you can use the Command Prompt, and on macOS or Linux, it may be the terminal. Make sure to open it in the same directory as the JAR file.

On the command-line interface, the JAR file can be run using Java by typing the following command:

java -jar MinecraftDecompiler.jar \
--version 1.21.10 \
--side SERVER \
--decompile \
--output 1.21.10-remapped.jar \
--decompiled-output 1.21.10-decompiled

This will write a mapped version of the server JAR file to 1.21.10-remapped.jar, as well as decompiling the game and writing the generated source files to 1.21.10-decompiled. The following arguments for MinecraftDecompiler software are used:

--version <version>
This specifies which version of the game you want to decompile. MinecraftDecompiler will automatically fetch the game's executable files from the specified version.
--side <environment>
This specifies which environment you want to decompile. There are two environment you can specify: CLIENT and SERVER. The client environment contains the entire game you're playing, while the server only contains the resources necessary to host a multiplayer game. The client includes the entire server code, plus client specific, like rendering, user interface, etc.
--decompile [<decompiler>]
This specifies that you want to decompile the game, usually after deobfuscating the JAR file. Optionally, you can also specify which decompiler you want to use. By default, it uses vineflower, but you can use other decompilers: fernflower, forgeflower, cfr, or user-defined.
--output <mapped-jar-output>
This specifies the output file for the deobfuscated JAR file (or mapped JAR file) from the obfuscation map.
--decompiled-output <decompilation-directory>
This specifies the output directory for the decompilation files.

Additionally, you can run java -jar MinecraftDecompiler.jar --help to see all available options.

Using built-in IDE functions

The following method is intended for users with some experience with Java and command line shell functions.

If you prefer to download as little additional software as possible, you can also view Minecraft's source using built-in IDE functions from IntelliJ IDEA, Eclipse, or Visual Studio Code.

Since you are not using additional software, you will have to generate the source yourself. Start by downloading the Fabric example mod from GitHub, and opening it in your IDE of choice.

Next, you will have to ensure that the version you want to find the source for is selected. If you want to use the latest stable version, i.e. 1.21.10, you may skip this step, as the example mod will almost always be up-to-date. Otherwise, navigate here, select your chosen version in the first dropdown menu, and update your gradle.properties file accordingly.

Once you have completed this step, open a command line window. If this window is in the IDE, run gradlew gensources, or ./gradlew gensources if you are on Linux or Mac. However, if this window is separate from your IDE, remember to run cd path/to/mod_folder/ first.

Now, return to your IDE window and follow the steps below, depending on the IDE you use:

  • Visual Studio Code: Ctrl/⌘ Cmd + P, and begin typing possible class names with the # prefix
  • IntelliJ IDEA: Ctrl + N or ⌘ Cmd + O, and begin typing possible class names
  • Eclipse: Ctrl/⌘ Cmd + ⇧ Shift + T, and begin typing possible class names

Navigation