simplify tools: shared harness setup (pipeline, block proxy, render job, framing, record copy, label cells, contact sheets) for the standalone renderers and the benchmark, block-entity scenes as name/yaw records, one dump pipeline for mob and avatar renderers with a shared submit helper, transform record and jem/entry/subset helpers, posed block entities from direct layer constants, pptest scenes registered once with settle-tick and resolution tables and put() for all blocks, jdk detection and full error log in the dump script, pptest jar rebuilt instead of updated, gradle task printing the tool classpath, comments trimmed

This commit is contained in:
MineTec committed 2026-11-05 03:24:30 +01:00
1 parent b242adb6d2
commit 02e052787c
11 files changed
+1449 -1686

No files matched your search

+31 -20
View File
@@ -1,14 +1,13 @@
#!/usr/bin/env bash
# Regenerates the vanilla entity-model dump straight from a Minecraft CLIENT jar (26.x+ ships
# unobfuscated, so no mappings are needed). This is the primary entity-model source of PixelPics:
# every mob is posed by its own renderer's setupAnim, and new entities/layers/baby/variant models of
# the new version are picked up automatically. Run it once per Minecraft update.
# Regenerates the vanilla entity-model dump from a Minecraft CLIENT jar (26.x+ ships unobfuscated, no mappings
# needed). This is PixelPics' primary entity-model source; run it once per Minecraft update.
#
# Needs the version installed in the launcher (~/.minecraft/versions/<ver>/<ver>.json + jar + libraries).
# Needs the version installed in the launcher (~/.minecraft/versions/<ver>/<ver>.json + jar + libraries) and a
# JDK (the dump runs as a source-file program): $JAVA, $JAVA_HOME or the JDK of `javac` on the PATH.
#
# Usage: tools/update-vanilla-models.sh 26.3 # -> src/main/resources/cem/ (bundled; rebuild jar)
# tools/update-vanilla-models.sh 26.4 <plugin-data-dir> # -> <dir>/vanilla_entity_models.json
# # (overrides the bundled copy, no rebuild)
# Usage: tools/update-vanilla-models.sh 26.3 # -> src/main/resources/cem/ (bundled; rebuild jar)
# tools/update-vanilla-models.sh 26.4 <plugin-data-dir> # -> <dir>/vanilla_entity_models.json
# # (overrides the bundled copy, no rebuild)
set -euo pipefail
VER="${1:?usage: $0 <minecraft-version> [output-dir]}"
@@ -17,9 +16,19 @@ OUT_DIR="${2:-$ROOT/src/main/resources/cem}"
MC="${MINECRAFT_DIR:-$HOME/.minecraft}"
JSON="$MC/versions/$VER/$VER.json"
JAR="$MC/versions/$VER/$VER.jar"
JAVA="${JAVA:-$(command -v java)}"
[[ -f "$JSON" && -f "$JAR" ]] || { echo "Version $VER not found under $MC/versions (start it once in the launcher)"; exit 1; }
NEED="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("javaVersion", {}).get("majorVersion", 0))' "$JSON")"
is_jdk() { # a JDK (jdk.compiler) at least as new as the game's Java version
[[ -n "$1" && -x "$1" ]] && "$1" --list-modules 2>/dev/null | grep -q '^jdk.compiler@' &&
(( $("$1" --version 2>/dev/null | head -1 | grep -oE '[0-9]+' | head -1) >= NEED ))
}
JAVAC_JAVA="$(command -v javac >/dev/null && echo "$(dirname "$(readlink -f "$(command -v javac)")")/java" || true)"
for j in "${JAVA:-}" "${JAVA_HOME:+$JAVA_HOME/bin/java}" "$JAVAC_JAVA" "$(command -v java || true)"; do
if is_jdk "$j"; then JDK_JAVA="$j"; break; fi
done
[[ -n "${JDK_JAVA:-}" ]] || { echo "No JDK >= $NEED found (a JRE can't launch source files): set JAVA or JAVA_HOME"; exit 1; }
# Classpath: client jar + all libraries listed in the version json.
CP="$(python3 - "$JSON" "$MC" "$JAR" <<'EOF'
import json, os, sys
@@ -34,19 +43,21 @@ print(":".join(cp))
EOF
)"
TMP="$(mktemp --suffix=.json)"
trap 'rm -f "$TMP"; rm -rf "${WORK:-}"' EXIT
# Run from a scratch dir: the game's logger writes a logs/ folder into the working directory.
# Scratch dir as working directory: the game's logger writes a logs/ folder there.
WORK="$(mktemp -d)"
(cd "$WORK" && "$JAVA" -cp "$CP" "$ROOT/tools/VanillaModelDump.java" "$TMP" 2>&1) | grep -E "STDOUT|Exception" | sed 's/.*STDOUT\]: //'
python3 -c "
import json; d = json.load(open('$TMP'))
trap 'rm -rf "$WORK"' EXIT
OUT="$WORK/vanilla_entity_models.json"
if ! (cd "$WORK" && "$JDK_JAVA" -cp "$CP" "$ROOT/tools/VanillaModelDump.java" "$OUT" > "$WORK/dump.log" 2>&1); then
cat "$WORK/dump.log"; echo "Dump failed"; exit 1
fi
grep -E "STDOUT|Exception" "$WORK/dump.log" | sed 's/.*STDOUT\]: //' || true
python3 - "$OUT" <<'EOF'
import json, sys
d = json.load(open(sys.argv[1]))
assert len(d['models']) > 100, 'dump looks incomplete'
print('version', d.get('version'), '-', len(d['models']), 'models,', len(d['entities']), 'entity types')"
print('version', d.get('version'), '-', len(d['models']), 'models,', len(d['entities']), 'entity types')
EOF
mkdir -p "$OUT_DIR"
mv "$TMP" "$OUT_DIR/vanilla_entity_models.json"
chmod 644 "$OUT_DIR/vanilla_entity_models.json"
rm -rf "$WORK"
trap - EXIT
install -m 644 "$OUT" "$OUT_DIR/vanilla_entity_models.json"
echo "Wrote $OUT_DIR/vanilla_entity_models.json"
echo "Note: the runtime resource pack must come from the same version (incl. assets/minecraft/font for text)."