plugins/tools/plugin_dunechest_pack.py
unimatrixgit b47b0ece3a
All checks were successful
Planet DuneChest Build / dunechest (push) Successful in 1m7s
DuneRealms Plugin CI / plugins (push) Successful in 2m30s
Integrate patch 7 chest models and fix storage setup controls
2026-11-30 19:20:43 +01:00

35 lines
1.8 KiB
Python

"""Verify the commissioned DuneChest overlay against the accepted Navigator pack."""
import hashlib
from pathlib import Path
import sys
from plugin_resource_pack import read_zip
PACK_BASELINE_SHA256 = '446c0b60fa6e6752ff5260bb22c9a76280b7b10ffa03c3cca4b08f4d9320105b'
MODELS = ['ender_chest', *(f'speed_hopper_{tier}{facing}' for tier in range(1,4) for facing in ('','_side'))]
ASSETS = {
'assets/dunerealms/items/ender_chest_barrel_display.json',
'assets/dunerealms/models/block/ender_chest_barrel_display.json',
*(f'assets/dunerealms/{category}/{model}.json' for category in ('items','models/item','models/block') for model in MODELS),
*(f'assets/dunerealms/textures/block/speed_hopper_{tier}.png' for tier in range(1,4)),
*(f'assets/dunerealms/textures/block/ender_chest_{face}.png' for face in ('bottom','front','side','top')),
'assets/dunerealms/items/wrench.json',
'assets/dunerealms/models/item/wrench.json',
'assets/dunerealms/textures/item/wrench.png',
}
def verify(baseline, candidate):
if hashlib.sha256(baseline.read_bytes()).hexdigest()!=PACK_BASELINE_SHA256:
raise ValueError('Unexpected Navigator resource-pack baseline')
old, new = read_zip(baseline), read_zip(candidate)
if set(new)-set(old)!=ASSETS or set(old)-set(new) or any(new[k]!=v for k,v in old.items()):
raise ValueError('DuneChest pack must add exactly the supplied assets and retain all existing entries')
overlay = Path('network/resource-pack/central/overlay')
if any(new[name]!=(overlay/name).read_bytes() for name in ASSETS):
raise ValueError('A DuneChest pack asset differs from its committed input')
return len(ASSETS)
if __name__ == '__main__':
print(f'Verified {verify(Path(sys.argv[1]), Path(sys.argv[2]))} exact DuneChest pack additions.')