Server menus keep their styled titles

A server's open_screen title is a text component, and container screens
draw it as AbstractContainerScreen does: in the label grey, under the
component's own colours, bold, italics and fonts, with the § codes a
literal holds. Horizon flattened it to a plain string, so a plugin's
gold and bold "Server Selector" menu showed in plain grey (#1645).
Chests, hoppers, dispensers, droppers, brewing stands and the other
workstations now draw the server's title. Before, the workstations
ignored it and showed their default name.

horizon-ctl's `screen` reports the title span by span (text, colour,
bold, italic). server_e2e's new `titles` check names a chest on the
vanilla server with a styled CustomName, opens it, and checks the title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-25 03:30:04 +01:00
parent a7f8650c6b
commit 1fdb119587
7 changed files with 80 additions and 43 deletions
+24 -1
View File
@@ -14,6 +14,8 @@ Checks:
payload (the server's "Received custom click action" line), `wait_for_response` leaves the
waiting screen, and `/dialog clear` closes a dialog (servers used to see nothing: the game
dropped the packets).
- titles: a chest named with styles (`CustomName`, as a plugin's menu is): its screen's title keeps
the colours and bold (it used to be flattened to plain grey).
The game runs with fresh HORIZON_HOME, launcher and XDG folders and without audio. Screenshots and both
logs go to --out.
@@ -126,7 +128,28 @@ def check_dialog(server, game, out):
return shown
CHECKS = {'dialog': check_dialog}
def check_titles(server, game, out):
# AbstractContainerScreen draws the title the server sent, its styles included (#1645). A named
# chest is what a plugin's menu looks like: its CustomName is the open_screen title.
x, y, z = (int(v // 1) for v in game('state')['player']['position'])
chest = (x + 2, y, z)
name = [{'text': 'Server ', 'color': 'gold', 'bold': True}, {'text': 'Selector', 'color': 'aqua'}]
server.console(f'setblock {chest[0]} {chest[1]} {chest[2]} minecraft:chest{{CustomName:{snbt(name)}}}')
game.wait(10)
game.raw('interact', *chest)
game.raw('wait-for', 'screen', 'container', '--timeout', 30)
game.wait(5)
title = game('screen').get('title')
game.shot(out, 'titles')
game.raw('key', 'esc', 'tap')
# A list is its first component with the rest as its children: they inherit its bold.
want = [{'text': 'Server ', 'color': '#FFAA00', 'bold': True, 'italic': False},
{'text': 'Selector', 'color': '#55FFFF', 'bold': True, 'italic': False}]
assert title == want, title
return {'title': title}
CHECKS = {'dialog': check_dialog, 'titles': check_titles}
def run(bins, out, checks):