#!/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. # # Needs the version installed in the launcher (~/.minecraft/versions//.json + jar + libraries). # # Usage: tools/update-vanilla-models.sh 26.3 # -> src/main/resources/cem/ (bundled; rebuild jar) # tools/update-vanilla-models.sh 26.4 # -> /vanilla_entity_models.json # # (overrides the bundled copy, no rebuild) set -euo pipefail VER="${1:?usage: $0 [output-dir]}" ROOT="$(cd "$(dirname "$0")/.." && pwd)" 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; } # Classpath: client jar + all libraries listed in the version json. CP="$(python3 - "$JSON" "$MC" "$JAR" <<'EOF' import json, os, sys j = json.load(open(sys.argv[1])); mc = sys.argv[2]; cp = [] for lib in j.get("libraries", []): a = lib.get("downloads", {}).get("artifact") if a: p = os.path.join(mc, "libraries", a["path"]) if os.path.exists(p): cp.append(p) cp.append(sys.argv[3]) 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. 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')) assert len(d['models']) > 100, 'dump looks incomplete' print('version', d.get('version'), '-', len(d['models']), 'models,', len(d['entities']), 'entity types')" 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 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)."