I don't have much experience with Gradle and just found a way to get MCPConfig to decompile and deobfuscate Minecraft jar files. The described steps might be extremely inefficient and even wrong.
Any feedback is therefore welcome!
You can use the project MCPConfig-CSV-mappings afterwards to apply CSV mappings, however in that case you have to adjust the indentation used by fernflower as described in the "Usage with MCPConfig" section before using MCPConfig.
- Download the latest MCPConfig version from: https://github.com/MinecraftForge/MCPConfig
- Look in the
versions
folder and choose the version you want, in the following called<version>
, for example1.13.1
- Run
gradlew <version>:projectClientApplyPatches
- For a complete (but possibly outdated tree of tasks, see this gist); to list all tasks use
gradlew <version>:tasks --all
- You might have to specify the JDK path, which can be done for example by using the argument
-Dorg.gradle.java.home
:gradlew <task> "-Dorg.gradle.java.home=<path_to_jdk>"
- You likely have to increase the heap space fernflower is allowed to use, otherwise it can fail decompiling classes or methods; see the "Problems" section
- This task will likely take some time (can be more than 10 minutes)
- For a complete (but possibly outdated tree of tasks, see this gist); to list all tasks use
- Once the task finished the directory
versions/<version>/projects/client/src/main/java
contains the deobfuscated source files
In your IDE choose the option to import a Gradle project and import the directory versions/<version>/projects
.
If you are using Eclipse a run / debug configuration will be created automatically, if not, try running the Gradle task eclipse
. Afterwards a file called RunClient.launch
should have been created in the versions/<version>/projects/client
directory and you should be able to select it in the list of run / debug configurations.
Fernflower can fail decompiling classes or methods. In case of classes the source file will just be empty, for methods the comment // $FF: Couldn't be decompiled
will be added instead of the method body.
You can do the following things to solve this:
- Open the log file
build/versions/<version>/<version>.client.decomp.log
with a text editor. - Search for the class or method which was not decompiled successfully
If the cause was a java.lang.OutOfMemoryError
, try increasing the maximum amount of heap memory fernflower is allowed to use:
-
Open the config file
versions/<version>/config.json
with a text editor -
Add to the array
fernflower
>jvmargs
the respective-Xmx
, for example:{ "fernflower": { "jvmargs": ["-Xmx2G"] } }
- Decompile Minecraft using a different decompiler
- Open the mapping file
versions/<version>/joined.tsrg
with a text editor - Search for the class names
- Open the new decompiled file and copy its content to the empty source file
- Rename fields and methods according to the mapping file. You can use the regex
^<obfuscated_name>
when searching for the names.
I actually tried replacing the mappings with the mojang mappings converted to tsrg by https://github.com/hube12/DecompilerMC, but I got an error message at the end that was to long to read. I kinda gave up on directly modding clients. I'm trying to use forge now.