#!/usr/bin/env bash # Updates the bundled CEM entity-model set (the only asset PixelPics vendors itself). # # Source: the CEM Template Loader data (Ewan Howell / wynem) — vanilla Java entity models as JSON, # already correctly posed. These ultimately mirror Mojang's hardcoded Java EntityModel classes. # # Most future-proof alternative for a NEW Minecraft version (sourced straight from the game): # 1. Install the JsonEM mod (Fabric), set dump_models=true in .minecraft/config/jsonem.properties # 2. Launch the game once -> models dumped to .minecraft/jsonem_dump # (a small format-adapter would be needed; the CEM source below covers vanilla until then.) # # Usage: tools/update-cem-models.sh # update if newer # tools/update-cem-models.sh --force # always overwrite set -euo pipefail URL="https://wynem.com/assets/json/cem_template_models.json" DEST="$(cd "$(dirname "$0")/.." && pwd)/src/main/resources/cem/cem_template_models.json" TMP="$(mktemp)" trap 'rm -f "$TMP"' EXIT echo "Fetching $URL ..." curl -fsSL "$URL" -o "$TMP" # Validate + read versions/counts. read -r NEW_VER NEW_COUNT < <(python3 -c " import json,sys d=json.load(open('$TMP')) assert 'models' in d and len(d['models'])>50, 'unexpected structure' print(d.get('version','?'), len(d['models'])) ") CUR_VER="(none)" if [ -f "$DEST" ]; then CUR_VER="$(python3 -c "import json;print(json.load(open('$DEST')).get('version','?'))" 2>/dev/null || echo '?')" fi echo "Current: $CUR_VER Remote: $NEW_VER ($NEW_COUNT models)" if [ "${1:-}" != "--force" ] && [ "$CUR_VER" = "$NEW_VER" ]; then echo "Already up to date. (use --force to overwrite)" exit 0 fi mkdir -p "$(dirname "$DEST")" cp "$TMP" "$DEST" echo "Updated -> $DEST (version $NEW_VER, $NEW_COUNT models)" echo "Rebuild/redeploy the plugin to apply."