User Tools

Site Tools


mod_development:decompiling

Preface

Minecraft uses a programming language called Java. The advantages of this are that it works on many kinds of systems and that it is fairly easy to decompile and modify. All(?) the Minecraft code is stored inside a JAR file (Java ARchive) which contains class files (compiled JAVA files). These class files are obfuscated which means that the purpose of the code within has been concealed. This code must be decompiled and deobfuscated in order to be modified. 1)

Requirements

  • JDK (Java Development Kit). Version 8 is recommended.

One of:

  • RetroMCP-Java (MCP remade in Java with many more versions). Recommended.
  • LTS (MCP with Long Term Service).
  • MCP (Minecraft Coder Pack) Use this if LTS doesn't support the version you are using or doesn't work for some other reason.

Instructions

After installing JDK, follow the instructions below depending on your choice of coder pack.

RetroMCP-Java

  1. Download the latest release from Github Releases.
  2. To launch with the GUI, simply click on the JAR file twice.
  3. To launch with the CLI, use:
    java -jar "RetroMCP-Java-all.jar"
  4. To launch the GUI from a CLI, type the following to launch the GUI:
    java -cp "RetroMCP-Java-all.jar" org.mcphackers.mcp.main.MainGUI
  5. After opening RetroMCP-Java, use the version dropdown to select a version or use the command:
    setup [version]
  6. (Optional) Apply extra mods and APIs to jars/minecraft.jar
  7. Press the decompile button or type:
    decompile

LTS

  1. Download LTS by following the link above and clicking the green button named 'Clone or download', then 'Download ZIP'.
  2. Export your LTS-master.zip to somewhere sensible (this will contain all your development files).
  3. In the newly exported folder, run setup.bat or setup.sh depending on your OS (Use .bat on Windows).
  4. Enter 'y' in the newly opened console to confirm the action.
  5. Choose the version you wish to compile by entering it's name.
  6. After it is finished you may need to refresh the folder to see the new files.
  7. (Optional) If decompiling a mod, apply it to the relevant jar in the jars folder.
  8. Run the decompile.bat/sh file that has generated.

MCP

  1. Download the appropriate version of MCP for your Minecraft version via the link above.
  2. Export the zip to somewhere sensible (this will contain all your development files).
  3. In the newly exported folder, insert minecraft_server.jar and the bin folder from your .minecraft into the folder named '/jars'. You'll need to provide your own bin folder with the jinput, lwjgl, lwjgl_util, and natives folder in it, as we cannot redistribute these. These files can be obtained by running the legacy Minecraft launcher with a jar for the correct version. If you only wish to decompile the client, the server jar is not required. Alternatively you can use setup.bat/sh in LTS to obtain these files and copy them over to your MCP folder.
  4. Open /runtime/decompile.py with a text editor of your choice and remove line 15: commands.checkupdates()
  5. (Optional) If decompiling a mod, apply it to the relevant jar in the /jars folder.
  6. Run the decompile.bat/sh file that has generated.
1)
You can edit class files directly with bytecode editing but this is a difficult alternative only useful in certain circumstances.
mod_development/decompiling.txt · Last modified: 2023/03/22 19:13 by zero

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki