User Tools

Site Tools


tutorial:reading_mc_code

This is an old revision of the document!


Reading the Minecraft source

Reading the Minecraft source is an important skill in modding. This is mainly because

  • Most of the Minecraft things are not documented
  • Documentations/tutorials get outdated fairly quickly

To read the Minecraft source, you need to generate sources first. See the “Generating Minecraft Sources” section in Setting up a mod development environment.

Searching for a Minecraft class

To search a Minecraft class, follow these steps.

Intellij IDEA

  1. Open the search pane with Ctrl + N
  2. Set the search scope to Project and Libraries or wider
  3. Type the class name in the search box

Visual Studio Code

  1. Open the search pane with Ctrl + P
  2. Type the class name with prefix #

In Visual Studio Code, you can also use Ctrl + T to open the class search directly.

Tips

  • If you don't know what class to read, take a look at open source mods which are similar to what you want to make.
  • When you find a method or class but don't understand what they are doing, check the usages or subclasses of them. You might need to check the usages of the usages and such.
  • You may find an invalid java code such as int i = true;. This is because the decompiler we use is not perfect. Check the corresponding part of bytecodes if needed.
  • Generated sources is located at the user gradle cache (i.e. ~/.gradle/caches/fabric-loom). If you want to use external tools to mess around with Minecraft source, you can use the sources jar.
tutorial/reading_mc_code.1632097065.txt.gz · Last modified: 2021/09/20 00:17 by siglong