mod_development:decompiling
Table of Contents
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
- Download the latest release from Github Releases.
- To launch with the GUI, simply click on the JAR file twice.
- To launch with the CLI, use:
java -jar "RetroMCP-Java-all.jar"
- 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
- After opening RetroMCP-Java, use the version dropdown to select a version or use the command:
setup [version]
- (Optional) Apply extra mods and APIs to
jars/minecraft.jar
- Press the decompile button or type:
decompile
LTS
- Download LTS by following the link above and clicking the green button named 'Clone or download', then 'Download ZIP'.
- Export your LTS-master.zip to somewhere sensible (this will contain all your development files).
- In the newly exported folder, run setup.bat or setup.sh depending on your OS (Use .bat on Windows).
- Enter 'y' in the newly opened console to confirm the action.
- Choose the version you wish to compile by entering it's name.
- After it is finished you may need to refresh the folder to see the new files.
- (Optional) If decompiling a mod, apply it to the relevant jar in the jars folder.
- Run the decompile.bat/sh file that has generated.
MCP
- Download the appropriate version of MCP for your Minecraft version via the link above.
- Export the zip to somewhere sensible (this will contain all your development files).
- 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.
- Open /runtime/decompile.py with a text editor of your choice and remove line 15:
commands.checkupdates()
- (Optional) If decompiling a mod, apply it to the relevant jar in the /jars folder.
- 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