diff --git a/tools/build-vanilla-pack.sh b/tools/build-vanilla-pack.sh new file mode 100755 index 0000000..a1611a8 --- /dev/null +++ b/tools/build-vanilla-pack.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Builds the runtime resource pack PixelPics renders from (blockstates, models, textures, items, +# atlases, font) straight from Mojang's CLIENT jar — no launcher install needed. The plugin ships no +# assets itself; drop the resulting zip into plugins/PixelPics/resourcepack/. Run it once per +# Minecraft update. No pack.mcmeta needed (the client jar has none; the loader detects the pack by +# its assets/minecraft/blockstates folder). +# +# Needs: curl, jq, unzip, zip. +# +# Usage: tools/build-vanilla-pack.sh 26.3 # -> ./vanilla-26.3.zip +# tools/build-vanilla-pack.sh 26.3 # -> /vanilla-26.3.zip +set -euo pipefail + +VER="${1:?usage: $0 [output-dir]}" +OUT_DIR="$(mkdir -p "${2:-.}" && cd "${2:-.}" && pwd)" +OUT="$OUT_DIR/vanilla-$VER.zip" +WORK="$(mktemp -d)" +trap 'rm -rf "$WORK"' EXIT + +META="$(curl -fsS https://piston-meta.mojang.com/mc/game/version_manifest_v2.json \ + | jq -r --arg v "$VER" '.versions[] | select(.id==$v) | .url')" +[[ -n "$META" ]] || { echo "Minecraft version $VER not found in Mojang's version manifest"; exit 1; } + +echo "Downloading client jar for $VER ..." +curl -fsS -o "$WORK/client.jar" "$(curl -fsS "$META" | jq -r .downloads.client.url)" + +unzip -q "$WORK/client.jar" 'assets/minecraft/'{blockstates,models,textures,items,atlases,font}'/*' -d "$WORK/pack" +rm -f "$OUT" +(cd "$WORK/pack" && zip -qr "$OUT" .) +echo "Wrote $OUT ($(unzip -Z1 "$OUT" | grep -vc '/$') files)"