Files
horizon-airdef/tools/test_mipmap_parity.py
T
Ludovic Marie ce87bfb8c7 Tools read the pinned Minecraft version from research-lock.json
lab.VERSION, lab.GAME (.local/minecraft/<version>) and lab.RESOURCES
(.local/horizon-client/<version>) come from the lock, and lab.version_info()
reads the pinned client jar's version.json. Every harness, generator and
tool that named 26.3 (resource folders, jar and source paths, result
records, the vanilla client's --version and asset index, the bare login
client's protocol, the benchmark's options.txt data version, the packet id
table's header) uses them, so a candidate worktree pinned to another version
runs them unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 12:22:20 +02:00

55 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""Sprite mip levels against the pinned client's MipmapGenerator.
Every static square block texture and a sample of item textures, with their
.mcmeta `texture` settings (mipmap_strategy, alpha_cutoff_bias):
VanillaMipmapOracle runs MipmapGenerator.generateMipLevels (solidify or the
dark fill, meanLinear or darkenedAlphaBlend, scaleAlphaToCoverage for cutout
sprites) and the `mipmap_probe` example loads the same sprites through
`sprites::Sprites` and runs `mipmap::generate`; every level's pixels must be
identical."""
import json
import struct
try:
from . import oracle_harness as oh
except ImportError:
import oracle_harness as oh
NAME = 'mipmap-parity'
def size(png):
with open(png, 'rb') as f:
head = f.read(24)
return struct.unpack('>II', head[16:24])
def make_input(build):
root = oh.lab.RESOURCES
textures = root / 'assets/minecraft/textures'
names = []
for folder, every in (('block', 1), ('item', 7)):
for i, png in enumerate(sorted((textures / folder).glob('*.png'))):
if i % every:
continue
meta = png.with_name(png.name + '.mcmeta')
if meta.is_file() and 'animation' in json.loads(meta.read_text(encoding='utf-8')):
continue
w, h = size(png)
if w != h or w & (w - 1) or w != 16:
continue
names.append(f'minecraft:{folder}/{png.stem}')
path = build / 'sprites.txt'
path.write_text('\n'.join([str(root)] + names) + '\n', encoding='utf-8')
return path, len(names)
if __name__ == '__main__':
oh.differential(NAME, 'VanillaMipmapOracle', 'mipmap_probe', make_input,
'MipmapGenerator.generateMipLevels (solidify, fillEmptyAreasWithDarkColor, meanLinear, '
'darkenedAlphaBlend, alphaTestCoverage, scaleAlphaToCoverage) on static 16x16 block and item sprites '
'with their .mcmeta texture settings',
sources=[oh.lab.ROOT / 'crates/horizon-client/src/mipmap.rs',
oh.lab.ROOT / 'crates/horizon-client/src/sprites.rs'])