#!/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. The plugin does the same on its own (resource-pack.auto-download/auto-update in # config.yml); use this script for servers without internet access, then drop the zip into # plugins/PixelPics/resourcepack/. No pack.mcmeta needed (the client jar has none; the loader detects # a zip by its vanilla blockstate files). The zip carries a pixelpics-pack.json with the version, so # the plugin's auto-update recognises and replaces it after a Minecraft update. # # Needs: curl, jq, unzip, zip, sha1sum. # # 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/version.json" "$META" SHA1="$(jq -r .downloads.client.sha1 "$WORK/version.json")" curl -fsS -o "$WORK/client.jar" "$(jq -r .downloads.client.url "$WORK/version.json")" echo "$SHA1 $WORK/client.jar" | sha1sum -c --quiet - || { echo "sha1 mismatch for the client jar"; exit 1; } unzip -q "$WORK/client.jar" 'assets/minecraft/'{blockstates,models,textures,items,atlases,font}'/*' -d "$WORK/pack" jq -n --arg v "$VER" --arg s "$SHA1" --arg t "$(date -u +%FT%TZ)" \ '{version: $v, client_sha1: $s, created: $t, source: "tools/build-vanilla-pack.sh"}' > "$WORK/pack/pixelpics-pack.json" rm -f "$OUT" (cd "$WORK/pack" && zip -qr "$OUT" .) echo "Wrote $OUT ($(unzip -Z1 "$OUT" | grep -vc '/$') files)"