Files
PixelPics/tools/update-vanilla-models.sh
T
MineTec 32afe08f03 render entities from vanilla client models, add items, displays and leashes
- dump entity models straight from the unobfuscated client jar
  (tools/VanillaModelDump.java, tools/update-vanilla-models.sh): models posed
  by vanilla setupAnim, baby/variant/layer models, renderer transforms,
  default textures, pose variants (sitting, holding items, illager arms)
  and all layer definitions; the old CEM template is only a fallback now
- fix adult zombies captured as babies, zero-thickness planes (wings,
  fins) and back faces in the entity intersector
- held items, head items (pumpkins, skulls), shields, elytra, saddles and
  body equipment for every mount, armor following the pose
- block/item/text display entities, dropped items, falling blocks, primed
  TNT, minecart contents, block entities inside displays, leash ropes
- item models resolved from the 26.x item definitions with display
  transforms; generated items extruded like vanilla
- bundle the vanilla font definitions as fallback so sign/text rendering
  works with packs that lack font/*.json
- one failing entity no longer aborts the whole photo
- edge-case test plugin (tools/edgecase-plugin) and offline harnesses
2026-11-04 13:11:39 +01:00

53 lines
2.5 KiB
Bash
Executable File

#!/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/<ver>/<ver>.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 <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]}"
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)."