diff --git a/.gitignore b/.gitignore index 9722c8c..e30d1d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # C2ME runtime worldgen class cache (regenerated at runtime; see .packwizignore) cache/ + +# Immersive Paintings player-upload cache (regenerated at runtime; see .packwizignore) +immersive_paintings_cache/ diff --git a/.packwizignore b/.packwizignore index 1a8374c..83d50ea 100644 --- a/.packwizignore +++ b/.packwizignore @@ -40,6 +40,9 @@ tools/ # C2ME runtime worldgen cache (regenerated at runtime) cache/ +# Immersive Paintings player-upload cache (regenerated at runtime) +immersive_paintings_cache/ + # Scratch artifacts from the map-migration tooling - never ship these sp-world/ xaero-migration-kit/ diff --git a/index.toml b/index.toml index 897a583..fcc1258 100644 --- a/index.toml +++ b/index.toml @@ -1087,3 +1087,8 @@ metafile = true file = "shaderpacks/makeup-ultra-fast-shaders.pw.toml" hash = "b65333a4878eecf3d220c101ae02be6e8707380156a7a02100164a865fb3a167" metafile = true + +[[files]] +file = "usernamecache.pw.toml" +hash = "8b15bf90bf87fd17378d8413ff0e2d3f4d0d2ffc5d6b0fa87e654ec99621b2fc" +metafile = true diff --git a/pack.toml b/pack.toml index b881738..6d81c57 100644 --- a/pack.toml +++ b/pack.toml @@ -6,7 +6,7 @@ pack-format = "packwiz:1.1.0" [index] file = "index.toml" hash-format = "sha256" -hash = "f9852076c38404288e9f09588cdae45b6e3a51fb8333099953566abbe06c791a" +hash = "65215ee765ac7e8321c232dd2624f7453aed4900384a18b004410d77158f7b6d" [versions] minecraft = "1.21.1" diff --git a/packfiles/usernamecache-offline.json b/packfiles/usernamecache-offline.json new file mode 100644 index 0000000..02e9c9d --- /dev/null +++ b/packfiles/usernamecache-offline.json @@ -0,0 +1,7 @@ +{ + "032f0cc0-2762-33bc-9731-e6cf550f6527": "Onion4Dinner", + "0d000554-ad3a-3719-83db-3a7fd258cd88": "ItsMeC", + "673b1e52-3895-3d9d-ae01-daca53835e89": "xX_ShyG0D_Xx", + "a03ea28c-ab84-339d-ac8b-dee0a152be15": "Conqueeftador", + "c22c84e2-a8d1-3acb-bb56-32047ed1aa83": "Stirwick" +} diff --git a/tools/sync-usernamecache.py b/tools/sync-usernamecache.py new file mode 100644 index 0000000..7d803e0 --- /dev/null +++ b/tools/sync-usernamecache.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +"""Refresh the pack's client-side usernamecache.json from the live server cache. + +The pack ships /usernamecache.json to clients (via usernamecache.pw.toml) +so Jade can resolve offline-mode owner names client-side (it falls back to +NeoForge's UsernameCache after the Mojang lookup fails). This merges the +server's live cache into packfiles/usernamecache-offline.json and updates the +download hash in usernamecache.pw.toml. + +Run after new players have logged in, then refresh/commit/push: + + python3 tools/sync-usernamecache.py + packwiz refresh + git add packfiles/usernamecache-offline.json usernamecache.pw.toml index.toml pack.toml + git commit -m "chore(pack): refresh client usernamecache" + git push +""" +import hashlib +import json +import pathlib +import re +import sys + +ROOT = pathlib.Path(__file__).resolve().parent.parent +LIVE = ROOT / "usernamecache.json" +SHIPPED = ROOT / "packfiles" / "usernamecache-offline.json" +META = ROOT / "usernamecache.pw.toml" + + +def load(path): + try: + return json.loads(path.read_text(encoding="utf-8")) + except FileNotFoundError: + return {} + + +def main(): + live = load(LIVE) + shipped = load(SHIPPED) + merged = {**shipped, **live} # the live server cache wins + if not merged: + print("no entries found; is the server's usernamecache.json missing?", file=sys.stderr) + return 1 + + text = json.dumps(merged, indent=2, sort_keys=True) + "\n" + changed = not SHIPPED.exists() or SHIPPED.read_text(encoding="utf-8") != text + SHIPPED.parent.mkdir(parents=True, exist_ok=True) + SHIPPED.write_text(text, encoding="utf-8") + + digest = hashlib.sha256(text.encode("utf-8")).hexdigest() + meta = META.read_text(encoding="utf-8") + new_meta = re.sub(r'(?m)^(hash = ")[0-9a-f]+(")$', lambda m: m.group(1) + digest + m.group(2), meta) + if new_meta != meta: + META.write_text(new_meta, encoding="utf-8") + + print(f"{len(merged)} entries ({len(live)} live, {len(shipped)} shipped), " + f"{'updated' if changed else 'unchanged'} -> packfiles/usernamecache-offline.json") + print(f"sha256 {digest}") + print("next: packwiz refresh && git add packfiles/usernamecache-offline.json " + "usernamecache.pw.toml index.toml pack.toml && commit && push") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/usernamecache.pw.toml b/usernamecache.pw.toml new file mode 100644 index 0000000..7f03973 --- /dev/null +++ b/usernamecache.pw.toml @@ -0,0 +1,8 @@ +name = "usernamecache (offline owner names for Jade)" +filename = "usernamecache.json" +side = "client" + +[download] +url = "https://git.ljones.me/logan/onion-mc/raw/branch/main/packfiles/usernamecache-offline.json" +hash-format = "sha256" +hash = "da4e9e31233718bcf421127b5d89517dcb0db7287e21653532edfffcb9b75de2"