hube12 / DecompilerMC

This repository allows you to decompile any minecraft version that was published after 19w36a without any 3rd party mappings, you just need to execute the script or the executable (see releases)! Thanks mojang to have published proguard mappings
Other
643 stars 54 forks source link

DecompilerMC

This tool automatically decompiles and remaps specific Minecraft versions. (Specifically, it converts Mojang's mappings from their proguard format to the tsrg format. SpecialSource then uses that and remaps the client jar, which is then decompiled either with CFR (code only) or Fernflower (assets and code).)

Your output will be readable/executable code similar to ModCoderPack or other decompilers.

Prerequisites

You will need

You can run this directly with Python 3.7+ with python3 main.py. CFR decompilation takes approximately 60s and fernflower takes roughly 200s. The code will then be inside the folder called ./src/<name_version(option_hash)>/<side>; you can find the jar and the version manifest in the ./versions/ directory.

The ./tmp/ directory can be removed without impact.

There is a common release here: https://github.com/hube12/DecompilerMC/releases/latest for all versions.


Command-line Arguments (Optional)

You can use arguments instead of terminal-based choices. This is not required, but will automatically start if a mcversion is passed.

usage: main.py [-h] [--mcversion MCVERSION] [--side SIDE] [--clean] [--force]
               [--forceno] [--decompiler DECOMPILER] [--nauto]
               [--download_mapping DOWNLOAD_MAPPING]
               [--remap_mapping [REMAP_MAPPING]]
               [--download_jar [DOWNLOAD_JAR]] [--remap_jar [REMAP_JAR]]
               [--delete_dep [DELETE_DEP]] [--decompile [DECOMPILE]] [--quiet]

optional arguments:
  -h, --help            show this help message and exit
  --mcversion MCVERSION, -mcv MCVERSION
                        The version you want to decompile (all versions
                        starting from 19w36a (snapshot) and 1.14.4 (releases))
                        Use 'snap' for latest snapshot (20w48a for example, it will get it automatically) or 'latest'
                        for latest version (1.16.4 for example, it will get it automatically)
  --side SIDE, -s SIDE  The side you want to decompile (either client or
                        server)
  --clean, -c           Clean old runs
  --force, -f           Force resolve conflicts by replacing old files. (Use if a specific path is necessary)
  --forceno, -fn        Force resolve conflicts by creating new directories.
  --decompiler DECOMPILER, -d DECOMPILER
                        Choose between fernflower and cfr.
  --nauto, -na          Choose between auto and manual mode.
  --download_mapping DOWNLOAD_MAPPING, -dm DOWNLOAD_MAPPING
                        Download the mappings (only if auto off)
  --remap_mapping [REMAP_MAPPING], -rmap [REMAP_MAPPING]
                        Remap the mappings to tsrg (only if auto off)
  --download_jar [DOWNLOAD_JAR], -dj [DOWNLOAD_JAR]
                        Download the jar (only if auto off)
  --remap_jar [REMAP_JAR], -rjar [REMAP_JAR]
                        Remap the jar (only if auto off)
  --delete_dep [DELETE_DEP], -dd [DELETE_DEP]
                        Delete the dependencies (only if auto off)
  --decompile [DECOMPILE], -dec [DECOMPILE]
                        Decompile (only if auto off)
  --quiet, -q           Doesn't display messages (recommended)

Examples:


To build as an executable, the commands are

pip install pyinstaller
pyinstaller main.py --distpath build --onefile