Files
PixelPics/tools/build-vanilla-pack.sh
T

31 lines
1.4 KiB
Bash
Executable File

#!/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 a zip by its
# vanilla blockstate files).
#
# Needs: curl, jq, unzip, zip.
#
# Usage: tools/build-vanilla-pack.sh 26.3 # -> ./vanilla-26.3.zip
# tools/build-vanilla-pack.sh 26.3 <output-dir> # -> <output-dir>/vanilla-26.3.zip
set -euo pipefail
VER="${1:?usage: $0 <minecraft-version> [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)"