{{DISPLAYTITLE:Tutorials/See ''Minecraft'''s code}}
{{disclaimer}}
{{exclusive|java}}
Since snapshot [[19w36a]], Mojang releases [[obfuscation map]]s for every version available in the [[launcher]]. Those maps can be used to deobfuscate a version's [[Jar|JAR file]], that is to say, replace obfuscated class names and class member names with their original (deobfuscated) names. Using a {{wikipedia|decompiler}}, it is possible to reconstruct human-readable {{wikipedia|Java (programming language)|Java}} code.
== Disclaimer ==
According to the [[Obfuscation map#License|license]], decompiling ''Minecraft'' is allowed, but it is recommended not to release decompiled code. Furthermore, a [[dinnerbonetweet:1293597329854009344|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 [https://files.minecraftforge.net/net/minecraftforge/forge/ Forge], [https://fabricmc.net/ Fabric], [https://quiltmc.org/ Quilt] and other modloaders) or for usage in server software with plugins (such as [https://www.spigotmc.org/ Spigot], [https://bukkit.org/ Bukkit], [https://papermc.io/ Paper], and others) is okay, and 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 cannot do under any circumstances are releasing the code or releasing something that contains an exact copy of the code.
== Decompiling JAR ==
{{disclaimer|section=1}}
There are numerous ways of decompiling the Minecraft source, see below.
----
=== Using third-party software ===
The easiest way to view the source is probably by using [https://github.com/MaxPixelStudios/MinecraftDecompiler/releases/latest MinecraftDecompiler] by MaxPixelStudios.
Upon downloading and unzipping MinecraftDecompiler.zip, it should give a jar file, which can be run via Terminal/PowerShell. Basic usage is as follows:
java -jar MinecraftDecompiler.jar --version {{v|java|nolink=yes}} --side SERVER --output dir ./output.zip
'''Additional Options:'''
* You can replace SERVER
with CLIENT
, although they must be in capitals
* You can also replace MinecraftDecompiler.jar
with the path to the application if it is in a different directory
{{msgbox
| title = File location
| text = Note: the option -jar MinecraftDecompiler.jar
assumes that the jar file exists in the current directory with that name. On most operating systems, it is necessary to enter cd path/to/downloads_folder/
before running the command mentioned above.
| type = notice
}}
=== Using built-in IDE functions ===
{{msgbox
| title = Warning:
| text = The following method is not intented for users with little to no experience with java and/or bash, and they might find the method described above less complex.
| type = content
}}
If you prefer to download as little additional software as possible, you can also view the Minecraft source using built in IDE functions in programs such as [https://www.jetbrains.com/idea/| IntelliJ IDEA], [https://eclipseide.org| Eclipse], or [https://code.visualstudio.com| VS Code].
Since you are not using additional software, you will have to generate the source yourself. Start by downloading the [https://github.com/FabricMC/fabric-example-mod 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. {{v|java}}, you may skip this step, as the example mod will almost always be up-to-date. Otherwise, navigate [https://fabricmc.net/develop/#Latest%20Versions| 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 Terminal/PowerShell window. If this window is in-IDE, run gradlew gensources
, and add a ./
before it if you are on Linux or Mac. However, if this window is seperate 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:
* VS 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 ==
{{Navbox tutorials|technical}}