41 lines
1.5 KiB
Bash
Executable File
41 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Updates the vendored CEM template model set (Ewan Howell / wynem: vanilla Java entity models as JSON). It is
|
|
# only the rest-pose FALLBACK for entity types missing from the vanilla client dump (+ the elytra fallback);
|
|
# mob and block-entity models come from tools/update-vanilla-models.sh.
|
|
#
|
|
# 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"
|
|
|
|
# Validates the download, prints "<new version> <model count> <current version>".
|
|
read -r NEW_VER NEW_COUNT CUR_VER < <(python3 - "$TMP" "$DEST" <<'PY'
|
|
import json, os, sys
|
|
d = json.load(open(sys.argv[1]))
|
|
assert 'models' in d and len(d['models']) > 50, 'unexpected structure'
|
|
cur = '(none)'
|
|
if os.path.exists(sys.argv[2]):
|
|
try: cur = json.load(open(sys.argv[2])).get('version', '?')
|
|
except Exception: cur = '?'
|
|
print(d.get('version', '?'), len(d['models']), cur)
|
|
PY
|
|
)
|
|
|
|
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."
|