refactor: update decompilation process and documentation to use version naming convention with '-Vanilla' for consistency

This commit is contained in:
BruceChen 2026-04-12 21:01:24 +00:00
parent 31c968ffa6
commit d2b279974c
4 changed files with 46 additions and 30 deletions

View file

@ -12,11 +12,11 @@ Systematic workflow for updating Minecraft Console Client to support a new Minec
- Decompiled server source for both the old and new MC versions in `$MCC_REPO/MinecraftOfficial/<version>-decompiled/`
- If missing, decompile and download server.jar:
```bash
$MCC_REPO/tools/decompile.sh --version <ver>
$MCC_REPO/tools/decompile.sh --version <ver>-Vanilla
```
This auto-downloads `MinecraftDecompiler.jar` if needed, produces the decompiled source, and downloads `server.jar` into `$MCC_SERVERS/<ver>/`.
- `tools/decompile.sh` depends on official mappings. For older versions where it refuses to decompile, fall back to a raw Java decompiler such as `cfr-decompiler` against `$MCC_SERVERS/<ver>/server.jar`. That fallback is good enough for packet inspection and registration order checks even when the output is obfuscated.
- A test server of the target version in `$MCC_SERVERS/<version>/` (see `mcc-dev-workflow` skill)
This auto-downloads `MinecraftDecompiler.jar` if needed, produces the decompiled source under `$MCC_REPO/MinecraftOfficial/<mc-version>-decompiled/`, and downloads `server.jar` into `$MCC_SERVERS/<ver>-Vanilla/`.
- `tools/decompile.sh` depends on official mappings. For older versions where it refuses to decompile, fall back to a raw Java decompiler such as `cfr-decompiler` against `$MCC_SERVERS/<ver>-Vanilla/server.jar`. That fallback is good enough for packet inspection and registration order checks even when the output is obfuscated.
- A test server of the target version in `$MCC_SERVERS/<version>-Vanilla/` (see `mcc-dev-workflow` skill)
## Step 0: Generate Server Reports (CRITICAL since 1.21.9)

View file

@ -335,12 +335,12 @@ git submodule update --init --recursive
From the repo root, use the decompiler helper to download the official server jar and create the decompiled source tree:
```bash
tools/decompile.sh --version 1.20.6
tools/decompile.sh --version 1.20.6-Vanilla
```
That creates the paths used by the harness and the version-adaptation workflow:
- `$MCC_SERVERS/1.20.6/server.jar`
- `$MCC_SERVERS/1.20.6-Vanilla/server.jar`
- `MinecraftOfficial/1.20.6-decompiled/`
If you are doing protocol work, this step is not optional.
@ -544,13 +544,13 @@ This is the core loop you should expect an agent to follow.
source tools/mcc-env.sh
SESSION="smoke-a"
USERNAME="$(_mcc_resolve_username "$SESSION")"
mc-start 1.20.6
mc-start 1.20.6-Vanilla
```
Check the recent server output:
```bash
mc-log 1.20.6
mc-log 1.20.6-Vanilla
```
### 2. Build MCC
@ -562,7 +562,7 @@ mcc-build
### 3. Run MCC with file input enabled
```bash
mcc-debug -v 1.20.6 --file-input --session "$SESSION" --no-build
mcc-debug -v 1.20.6-Vanilla --file-input --session "$SESSION" --no-build
```
### 4. Set up server state through RCON
@ -665,7 +665,7 @@ The important rule is simple:
The usual order is:
1. `tools/decompile.sh --version <ver>`
1. `tools/decompile.sh --version <ver>-Vanilla`
2. generate server reports from `server.jar`
3. run `tools/diff_registries.py`
4. regenerate the palettes that actually changed
@ -692,9 +692,9 @@ Typical loop:
source tools/mcc-env.sh
SESSION="smoke-a"
USERNAME="$(_mcc_resolve_username "$SESSION")"
mc-start 1.20.6
mc-start 1.20.6-Vanilla
mcc-build
mcc-debug -v 1.20.6 --file-input --session "$SESSION" --no-build
mcc-debug -v 1.20.6-Vanilla --file-input --session "$SESSION" --no-build
mc-rcon "op $USERNAME"
mcc-cmd --session "$SESSION" "inventory player list"
mcc-cmd --session "$SESSION" "entity"
@ -737,7 +737,7 @@ Use skills:
Typical flow:
```bash
tools/decompile.sh --version 26.1
tools/decompile.sh --version 26.1-Vanilla
```
Generate server reports:

View file

@ -51,13 +51,15 @@ Two types of data can be used as input:
### Decompiling a new MC version
```bash
# Server side (default) — also downloads server.jar into MinecraftOfficial/downloads/<ver>/
tools/decompile.sh --version 1.21.9
# Server side (default) — downloads server.jar into $MCC_SERVERS/<ver>-Vanilla/
tools/decompile.sh --version 1.21.9-Vanilla
# Client side
tools/decompile.sh --version 1.21.9 --side CLIENT
```
For server-side runs, the decompiled source still lands in `MinecraftOfficial/<mc-version>-decompiled/`, while the runnable local server directory becomes `$MCC_SERVERS/<mc-version>-Vanilla/`.
If you keep server assets outside the repo, set `MCC_SERVERS=/path/to/servers` before using `tools/mcc-env.sh` or `tools/start-server.sh`.
The script auto-downloads `MinecraftDecompiler.jar` from GitHub releases if it doesn't exist.

View file

@ -6,13 +6,14 @@
# ./tools/decompile.sh --version <ver> [--side SERVER|CLIENT]
#
# Examples:
# ./tools/decompile.sh --version 1.21.11
# ./tools/decompile.sh --version 1.21.11-Vanilla
# ./tools/decompile.sh --version 1.21.11 --side CLIENT
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
MC_OFFICIAL="$REPO_ROOT/MinecraftOfficial"
SERVERS_ROOT="${MCC_SERVERS:-$MC_OFFICIAL/downloads}"
DECOMPILER_JAR="$MC_OFFICIAL/MinecraftDecompiler.jar"
DECOMPILER_REPO="MaxPixelStudios/MinecraftDecompiler"
@ -27,7 +28,7 @@ while [[ $# -gt 0 ]]; do
echo "Usage: $0 --version <ver> [--side SERVER|CLIENT]"
echo ""
echo "Options:"
echo " --version <ver> Minecraft version (e.g. 1.21.11)"
echo " --version <ver> Minecraft version or local server dir (e.g. 1.21.11 or 1.21.11-Vanilla)"
echo " --side <env> SERVER (default) or CLIENT"
exit 0
;;
@ -46,6 +47,16 @@ if [[ "$SIDE" != "SERVER" && "$SIDE" != "CLIENT" ]]; then
exit 1
fi
MC_VERSION="${VERSION%-Vanilla}"
if [[ -z "$MC_VERSION" ]]; then
MC_VERSION="$VERSION"
fi
SERVER_DIR_NAME="$VERSION"
if [[ "$SIDE" == "SERVER" && "$VERSION" != *-Vanilla ]]; then
SERVER_DIR_NAME="${MC_VERSION}-Vanilla"
fi
# --- Ensure MinecraftDecompiler.jar exists ---
if [[ ! -f "$DECOMPILER_JAR" ]]; then
echo "MinecraftDecompiler.jar not found, downloading latest release..."
@ -71,11 +82,11 @@ fi
SIDE_LOWER="$(echo "$SIDE" | tr '[:upper:]' '[:lower:]')"
if [[ "$SIDE" == "SERVER" ]]; then
REMAPPED_JAR="$MC_OFFICIAL/remapped_jar/${VERSION}-remapped.jar"
DECOMPILED_DIR="$MC_OFFICIAL/${VERSION}-decompiled"
REMAPPED_JAR="$MC_OFFICIAL/remapped_jar/${MC_VERSION}-remapped.jar"
DECOMPILED_DIR="$MC_OFFICIAL/${MC_VERSION}-decompiled"
else
REMAPPED_JAR="$MC_OFFICIAL/remapped_jar/${VERSION}-${SIDE_LOWER}-remapped.jar"
DECOMPILED_DIR="$MC_OFFICIAL/${VERSION}-${SIDE_LOWER}-decompiled"
REMAPPED_JAR="$MC_OFFICIAL/remapped_jar/${MC_VERSION}-${SIDE_LOWER}-remapped.jar"
DECOMPILED_DIR="$MC_OFFICIAL/${MC_VERSION}-${SIDE_LOWER}-decompiled"
fi
if [[ -d "$DECOMPILED_DIR" ]]; then
@ -92,12 +103,12 @@ VERSION_URL=$(curl -sL "$MANIFEST_URL" | python3 -c "
import json, sys
data = json.load(sys.stdin)
for v in data['versions']:
if v['id'] == '$VERSION':
if v['id'] == '$MC_VERSION':
print(v['url'])
break
")
if [[ -z "$VERSION_URL" ]]; then
echo "Error: version $VERSION not found in Mojang launcher manifest."
echo "Error: version $MC_VERSION not found in Mojang launcher manifest."
exit 1
fi
@ -109,9 +120,12 @@ data = json.load(sys.stdin)
print('true' if '$MAPPING_KEY' in data.get('downloads', {}) else 'false')
")
echo "=== Decompiling Minecraft $VERSION ($SIDE) ==="
echo "=== Decompiling Minecraft $MC_VERSION ($SIDE) ==="
echo " Remapped JAR: $REMAPPED_JAR"
echo " Decompiled: $DECOMPILED_DIR"
if [[ "$SIDE" == "SERVER" ]]; then
echo " Server dir: $SERVERS_ROOT/$SERVER_DIR_NAME"
fi
echo " Obfuscated: $HAS_MAPPINGS"
echo ""
@ -120,7 +134,7 @@ cd "$MC_OFFICIAL"
if [[ "$HAS_MAPPINGS" == "true" ]]; then
# Obfuscated version: use --version/--side to auto-download jar + mappings + deobfuscate
java -jar "$DECOMPILER_JAR" \
--version "$VERSION" \
--version "$MC_VERSION" \
--side "$SIDE" \
--decompile \
--output "$REMAPPED_JAR" \
@ -129,14 +143,14 @@ else
# Unobfuscated version (26.1+): download jar, extract inner jar from bundle, decompile directly.
# MinecraftDecompiler requires --mapping-path with --input, but unobfuscated versions
# have no mappings. We use Vineflower directly instead.
echo "No Proguard mappings for $VERSION; decompiling without deobfuscation."
echo "No Proguard mappings for $MC_VERSION; decompiling without deobfuscation."
JAR_URL=$(echo "$VERSION_META" | python3 -c "
import json, sys
data = json.load(sys.stdin)
print(data['downloads']['${SIDE_LOWER}']['url'])
")
ORIGINAL_JAR="$MC_OFFICIAL/remapped_jar/${VERSION}-${SIDE_LOWER}-original.jar"
ORIGINAL_JAR="$MC_OFFICIAL/remapped_jar/${MC_VERSION}-${SIDE_LOWER}-original.jar"
if [[ ! -f "$ORIGINAL_JAR" ]]; then
echo "Downloading ${SIDE_LOWER}.jar ..."
curl -L -o "$ORIGINAL_JAR" "$JAR_URL"
@ -175,13 +189,13 @@ echo ""
echo "=== Done ==="
echo "Decompiled source: $DECOMPILED_DIR"
# --- For SERVER side, also ensure downloads/<ver>/server.jar exists ---
# --- For SERVER side, also ensure downloads/<server-dir>/server.jar exists ---
if [[ "$SIDE" == "SERVER" ]]; then
DOWNLOADS_DIR="$MC_OFFICIAL/downloads/$VERSION"
DOWNLOADS_DIR="$SERVERS_ROOT/$SERVER_DIR_NAME"
if [[ ! -f "$DOWNLOADS_DIR/server.jar" ]]; then
mkdir -p "$DOWNLOADS_DIR"
echo ""
echo "Downloading server.jar for $VERSION into $DOWNLOADS_DIR ..."
echo "Downloading server.jar for $MC_VERSION into $DOWNLOADS_DIR ..."
SERVER_JAR_URL=$(echo "$VERSION_META" | python3 -c "
import json, sys
data = json.load(sys.stdin)