Compare the chat with vanilla's ChatComponent

The chat cases add messages (with the system and error tags) at given Hud
ticks and draw ChatComponent in background mode: wrapping, the 200-tick
fade, scale, width, height, spacing and opacity options. Horizon's chat now
wraps like StringSplitter.splitLines and ComponentRenderUtils.wrapComponents
(the indent on wrapped lines, breaks at the last space, a dropped newline
or space), keeps the options as doubles and draws through a layout with
vanilla's fills and text offsets. A component list whose first part has
empty text now still passes its style to the rest. The harness runs 200
cases per kind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-12 13:28:05 +02:00
parent ef0c6604a5
commit 5b201965af
11 changed files with 379 additions and 181 deletions
+33
View File
@@ -196,6 +196,38 @@ def overlays(rng, n):
return case
WORDS = ['hello', 'world', 'a', 'Minecraft', 'supercalifragilisticexpialidocious', 'x' * 70, 'ok!', 'Ünïcödé', '★', '']
def chat_text(rng):
words = [rng.choice(WORDS) for _ in range(rng.choice([1, 2, 5, 12, 30]))]
text = rng.choice([' ', ' ', ' ', ' ', '\n']).join(words)
if rng.random() < 0.1:
text = rng.choice([' ', '\n']) + text + rng.choice(['', ' ', '\n'])
if rng.random() < 0.3:
cut = rng.randint(0, len(text))
return [{'text': text[:cut], 'color': rng.choice(['red', 'gold', 'aqua'])},
{'text': text[cut:], 'bold': rng.random() < 0.5, 'italic': rng.random() < 0.3}]
return {'text': text}
def chat(rng, n):
"""Messages wrapped to the chat width and fading 200 ticks after they arrive."""
count = rng.choice([1, 2, 5, 10, 30, 120])
now = rng.randint(200, 2000)
messages = []
for _ in range(count):
at = rng.choice([now, now - 1, now - 179, now - 180, now - 190, now - 199, now - 200, now - 500, rng.randint(now - 260, now + 5)])
messages.append({'text': chat_text(rng), 'at': at, 'tag': rng.choice([None, None, 'system', 'error'])})
messages.sort(key=lambda m: m['at'])
return {**screen(rng), 'now': now, 'messages': messages,
'chatScale': rng.choice([1.0, 1.0, 0.5, 0.0 + 0.75, 0.25]), 'chatWidth': rng.choice([1.0, 1.0, 0.5, 0.0, 0.3]),
'chatOpacity': rng.choice([1.0, 0.5, 0.0, 0.25]), 'textOpacity': rng.choice([0.5, 0.0, 1.0, 0.25]),
'chatLineSpacing': rng.choice([0.0, 0.0, 0.5, 1.0, 0.25]), 'chatHeightUnfocused': rng.choice([70 / 160, 1.0, 0.0, 0.5]),
'chatHeightFocused': 1.0}
# Generators by kind: (rng, index) -> case. Cases are drawn round-robin.
KINDS = {
'decorations': decorations,
@@ -207,4 +239,5 @@ KINDS = {
'sidebar': sidebar,
'decor': decor,
'overlays': overlays,
'chat': chat,
}
+23 -15
View File
@@ -1,21 +1,29 @@
#!/usr/bin/env python3
"""Compare the in-game HUD with the vanilla 26.3 client's Hud.
The Java oracle (VanillaHudOracle) runs vanilla's own Hud methods
(extractCrosshair, extractItemHotbar, extractPlayerHealth,
extractVehicleHealth, extractEffects, extractCameraOverlays, extractTitle,
extractOverlayMessage, extractSelectedItemName, the scoreboard sidebar and
Hud.tick), BossHealthOverlay, ChatComponent, the contextual bars and
GuiGraphicsExtractor.itemDecorations on a stand-in client whose player
answers from the case, and records every blit (sprite, texture, position,
size, region, colour, pose), fill, text call (string, style runs, position,
colour, shadow, pose) and hotbar item (slot, position, seed, pose).
`examples/hud_fixture` lays out the same state with
`horizon_client::hud_layout`; the ordered call lists must agree.
The Java oracle (VanillaHudOracle) runs vanilla's own code on a stand-in
client whose player answers from the case, and records every
GuiGraphicsExtractor blit (sprite, texture, position, size, region, colour,
pose), fill, text call (string, style runs, position, colour, shadow, pose)
and hotbar item (slot, position, seed, pose). `examples/hud_fixture` lays
out the same state with `horizon_client::hud_layout`, `hud_overlays` and
`chat`; the ordered call lists (and any state read back) must agree.
Each case has a `kind` (decorations, effects, title, selected, boss,
sidebar, jump, decor, overlays, chat); timing kinds replay events tick by
tick (title fades, the action bar, the selected item name, chat fades).
Case kinds (`tools/hud_parity_cases.py`), drawn round-robin:
decorations extractCrosshair, extractItemHotbar, extractPlayerHealth,
extractVehicleHealth, ExperienceBar and the level
effects extractEffects (MobEffectInstance order, blinking icons)
title setTitle/setTimes/setOverlayMessage and Hud.tick, then
extractOverlayMessage and extractTitle (fades, backdrops)
selected Hud.tick's tool highlight, then extractSelectedItemName
boss BossHealthOverlay
jump JumpableVehicleBar
sidebar displayScoreboardSidebar (teams, number formats)
decor GuiGraphicsExtractor.itemDecorations (count, bar, cooldown)
overlays extractCameraOverlays (vignette, spyglass and scopeScale,
pumpkin, powder snow, portal, nausea) and extractSleepOverlay
chat ChatComponent: wrapping (StringSplitter, indents), fades,
tags, scale, width, height and spacing options
test_hud_parity.py [--count N] [--detail N] [--kind K]
"""
@@ -81,7 +89,7 @@ def same(x, y):
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--count', type=int, default=600)
parser.add_argument('--count', type=int, default=2200)
parser.add_argument('--detail', type=int, default=3)
parser.add_argument('--kind', action='append', choices=sorted(KINDS), help='only these kinds (repeatable)')
args = parser.parse_args()