Tutorial (1.13 to 1.16.5) - ThisTestUser/MCPFixer GitHub Wiki

Note: VERSION refers to the version you want to decompile, like 1.13.

Starting Up

This guide is for versions 1.13-1.16.5.

The first thing you want to do is to download mcp940.zip (https://minecraft.wiki/w/Tutorials/Programs_and_editors/Mod_Coder_Pack#Downloads). Extract the zip file to a folder and open up mcp940/conf/version.cfg. Replace 9.40 with something else (e.g. 9.41) and set the client and server version to the version you want to decompile. This will serve as a starting point for our custom fixes.

Then, clone MCPConfig (https://github.com/MinecraftForge/MCPConfig/tree/0cdc6055297f0b30cf3e27e59317f229a30863a6) (you MUST use this version, not the newest) and run gradlew :VERSION:makeSRG to get the joined.srg file. For access.txt and exceptions.txt, run gradlew :VERSION:fixAccessLevels and gradlew :VERSION:makeExceptions respectively, although access.txt is only non-empty from 1.13-1.13.2 and exceptions.txt is always empty for versions relevant to this guide.

Runtime JARs

For the 3 required runtime JARs (ForgeFlower, MCInjector, and SpecialSource), you will need to find config.json at MCPConfig/versions/release/VERSION. This will give you the versions of the 3 libraries you need to download.

The first two libraries can be found on the Forge maven website. Example links for MCInjector and ForgeFlower are below (swap out the version number for your version):

https://maven.minecraftforge.net/net/minecraftforge/forgeflower/1.5.478.16/forgeflower-1.5.478.16.jar

https://maven.minecraftforge.net/de/oceanlabs/mcp/mcinjector/3.8.0/mcinjector-3.8.0-fatjar.jar

For the SpecialSource library, use the link below (again, swap out the version number):

https://repo1.maven.org/maven2/net/md-5/SpecialSource/1.8.3/SpecialSource-1.8.3-shaded.jar

Note that you MUST have the correct versions for all 3 libraries as specified in config.json.

Rename the 3 files you downloaded to exactly the name shown below.

  • ForgeFlower - Rename to fernflower.jar
  • MCInjector - Rename to mcinjector.jar
  • SpecialSource - Rename to specialsource.jar

Then, move all 3 files into mcp940/runtime/bin. The new files should replace the 3 JAR files that are already in there.

For 1.16 and up, find the resources folder of this repository and download MCInjectorImpl.class. Go to de/oceanlabs/mcp/mcinjector inside mcinjector.jar and replace the MCInjectorImpl.class that exists inside. This will prevent MCInjector from processing a library class file that causes it to crash.

Downloading Libraries

To download libraries, run this command with my fixer tool: java -jar fixer.jar -v "MINECRAFT_VERSION" -w "YOUR_PATH/mcp940" -mode download. This will eliminate the need for MCP to copy libraries. Note that the server JAR will also be downloaded to mcp940/jars and be decompiled by MCP. If you don't want that, rename or delete the server JAR.

Configs

First, head to this link and find the right mapping for your Minecraft version: https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_snapshot/maven-metadata.xml

You should get the latest mapping release for a specific Minecraft version. For 1.15.2, there isn't a mapping release, so simply use the 1.15.1 mappings. Now replace the link below with your mapping version and download it.

https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_snapshot/20210309-1.16.5/mcp_snapshot-20210309-1.16.5.zip

Once you've downloaded the mappings file, extract the 3 CSVs to the mcp940/conf folder. This should replace the 3 CSVs that already exist in the folder.

Now, from the mcp940/conf folder, delete patches (the entire folder), exceptor.json, joined.exc, joined.srg, and STATIC_METHODS.txt.

From MCPConfig/build/versions/VERSION/data, add access.txt and exceptions.txt.

From MCPConfig/build/versions/VERSION/data, add joined.srg. Be sure to add back the following to the file:

PK: . net/minecraft/src
PK: net net
PK: net/minecraft net/minecraft
PK: net/minecraft/client net/minecraft/client
PK: net/minecraft/client/main net/minecraft/client/main
PK: net/minecraft/realms net/minecraft/realms
PK: net/minecraft/server net/minecraft/server

Additionally, if you are doing 1.14+, you should add these too:

PK: com com
PK: com/mojang com/mojang
PK: com/mojang/blaze3d com/mojang/blaze3d
PK: com/mojang/blaze3d/platform com/mojang/blaze3d/platform

From MCPConfig/versions/release/VERSION, add constructors.txt.

For the patches, you will need my fixer tool to reformat them to the MCP format. Run java -jar fixer.jar -i "YOUR_PATH/MCPConfig/versions/release/VERSION" -o "YOUR_PATH/mcp940/conf" -mode patch.

Then, go to mcp.cfg.

Delete the line starting with "UpdateUrl", as MCP won't be receiving updates anymore.

Check for this part:

XClientJson     = %(DirConf)s/exceptor.json
XServerJson     = %(DirConf)s/exceptor.json
XClientCfg      = %(DirConf)s/joined.exc
XServerCfg      = %(DirConf)s/joined.exc

and replace with this:

XClientAccess   = %(DirConf)s/access.txt
XServerAccess   = %(DirConf)s/access.txt
XClientExe      = %(DirConf)s/exceptions.txt
XServerExe      = %(DirConf)s/exceptions.txt
XClientCfg      = %(DirConf)s/constructors.txt
XServerCfg      = %(DirConf)s/constructors.txt

Now, find this:

CmdExceptor   = %s -jar %s --jarIn {input} --jarOut {output} --mapIn {conf} --log {log} --generateParams --lvt=LVT
CmdExceptorDry = %s -jar %s --jarIn {input} --mapIn {conf} --log {log} --lvt=LVT

and replace with:

CmdExceptor   = %s -jar %s --in {input} --out {output} --ctr {conf} --acc {acc} --exc {exc} --log {log} --lvt=LVT
CmdExceptorDry = %s -jar %s --in {input} --ctr {conf} --acc {acc} --exc {exc} --log {log} --lvt=LVT

Find the line that starts with IgnorePkg. Add ,joptsimple to the end of that line. This is only to deal with an extra library in the server JAR.

For 1.15.2 and up, add "-isl=0" after "-jvn=1" at the line beginning with "CmdFernflower".

commands.py

It is highly recommended to use Notepad++ to do the following edits.

Head over to mcp940/runtime, and open up commands.py.

Find the line jarslwjgl.append(os.path.join(self.dirjars,self.mcLibraries['lwjgl_util']['filename'])) and delete it.

Find

self.xclientjson = os.path.normpath(config.get('EXCEPTOR', 'XClientJson'))
self.xserverjson = os.path.normpath(config.get('EXCEPTOR', 'XServerJson'))

and replace with

self.xclientaccess = os.path.normpath(config.get('EXCEPTOR', 'XClientAccess'))
self.xserveraccess = os.path.normpath(config.get('EXCEPTOR', 'XServerAccess'))
self.xclientexe = os.path.normpath(config.get('EXCEPTOR', 'XClientExe'))
self.xserverexe = os.path.normpath(config.get('EXCEPTOR', 'XServerExe'))

Find

json = {CLIENT: self.xclientjson, SERVER: self.xserverjson}

and replace with

access = {CLIENT: self.xclientaccess, SERVER: self.xserveraccess}
exe = {CLIENT: self.xclientexe, SERVER: self.xserverexe}

Find (warning: actual code is split into two lines)

forkcmd = self.cmdexceptor.format(input=excinput[side], output=excoutput[side], conf=excconf[side],
 log=exclog[side], json=json[side])

and replace with

forkcmd = self.cmdexceptor.format(input=excinput[side], output=excoutput[side], conf=excconf[side], acc=access[side], 
exc=exe[side], log=exclog[side])

Find

forkcmd = self.cmdexceptordry.format(input=excinputdry[side], conf=excconf[side], log=exclogdry[side], json=json[side])

and replace with

forkcmd = self.cmdexceptordry.format(input=excinputdry[side], conf=excconf[side], acc=access[side], exc=exe[side], log=exclogdry[side])

Find

if i.filename.startswith(p):

and replace with

if i.filename.startswith(p) and side == SERVER:

The above fix prevents IgnorePkg from triggering in the client JAR and incorrectly excluding source files.

Find (2 matches, replace both)

ignore_dirs = [os.path.normpath(p) for p in self.ignorepkg]

and replace with

ignore_dirs = []

The above fix prevents IgnorePkg from applying to the client JAR when copying files. This is essential as 1.14 and above includes source files that start with com.

In total, you should have replaced code 7 times and deleted one line. Keep in mind your indents, as your decompile.bat will fail quickly with a compile error if you don't. To be safe, use Notepad++.

Conclusion

At this point, you should run decompile.bat and everything should work properly. If it didn't, that means that you probably messed up somewhere.

Remember that the decompiled Minecraft code may not be distributed. If you wish to make mods for Minecraft that require being able to edit the base code whenever you want, I highly recommend you use Fabric. It is much less burdensome and you can easily update to a newer version when needed.