feat(pack): ship offline usernamecache to clients for Jade
Jade resolves tamed-animal owner names client-side; its Mojang profile lookup can't resolve offline-mode UUIDs and it falls back to NeoForge's UsernameCache, which the client loads from <game>/usernamecache.json. Ship that file (side = "client", installed at the game root) so migrated owners stop showing as "???". Maintain the mapping with tools/sync-usernamecache.py after new logins.
This commit is contained in:
1 parent
0adfb6c656
commit
e7d6691466
7 files changed
+92
-1
No files matched your search
@@ -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/
|
||||
@@ -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/
|
||||
|
||||
@@ -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
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Refresh the pack's client-side usernamecache.json from the live server cache.
|
||||
|
||||
The pack ships <game>/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())
|
||||
@@ -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"
|
||||
Reference in new issue
Block a user