Server titles: /title reaches the guest, and its HUD shows and clears them

TitleCommand sends the targeted player ClientboundSetTitleText,
SetSubtitleText, SetActionBarText, SetTitlesAnimation and ClearTitles. A
guest's /title (the window's own player on the server thread too) only
changed the server's HUD; it is now sent to the guest. The remote client
showed titles and action bars as a bare line and ignored subtitles, times
and clearing; it now feeds the HUD's titles as ClientPacketListener does
(the action bar of a SystemChat overlay too) and ticks them (Gui.tick).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-17 21:46:30 +02:00
parent d223b383ee
commit c12f5cf41a
5 changed files with 80 additions and 36 deletions
+19 -2
View File
@@ -74,7 +74,7 @@ ROOT = Path(__file__).resolve().parents[1]
GUEST_NAME = 'Guest'
# The host plays single player on its server thread (--server-thread).
SERVER_THREAD = False
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'containers', 'feedback', 'commands', 'recipes', 'trials', 'clicks', 'sleep', 'push', 'eat', 'xp', 'effects', 'portals']
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'containers', 'feedback', 'titles', 'commands', 'recipes', 'trials', 'clicks', 'sleep', 'push', 'eat', 'xp', 'effects', 'portals']
class Game:
@@ -775,6 +775,22 @@ def check_recipes(host, guest, out):
return {'known': known, 'grid': grid}
def check_titles(host, guest, out):
# TitleCommand sends the guest its title packets; its HUD shows and clears them.
for command in ('title @s times 10 400 10', 'title @s subtitle "Under"', 'title @s title "Over"',
'title @s actionbar "Bar"'):
guest('command', command=command)
guest.wait(5)
shown = {k: guest.raw('messages', 1)[k] for k in ('title', 'subtitle', 'actionbar')}
guest.shot(out, 'titles')
guest('command', command='title @s clear')
guest.wait(5)
cleared = {k: guest.raw('messages', 1)[k] for k in ('title', 'subtitle')}
assert shown == {'title': 'Over', 'subtitle': 'Under', 'actionbar': 'Bar'}, f'titles shown: {shown}'
assert cleared == {'title': None, 'subtitle': None}, f'titles cleared: {cleared}'
return {'shown': shown, 'cleared': cleared}
def png_rows(path):
"""The rows of an 8-bit RGB or RGBA PNG, unfiltered, as bytes of 4 (or 3) per pixel."""
data = Path(path).read_bytes()
@@ -1047,7 +1063,8 @@ def check_xp(host, guest, out):
CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour, 'nametags': check_nametags,
'chest': check_chest, 'crafting': check_crafting, 'sign': check_sign, 'damage': check_damage,
'mobs': check_mobs, 'hazards': check_hazards, 'pvp': check_pvp,
'containers': check_containers, 'feedback': check_feedback, 'commands': check_commands,
'containers': check_containers, 'feedback': check_feedback, 'titles': check_titles,
'commands': check_commands,
'recipes': check_recipes, 'trials': check_trials, 'walls': check_walls,
'effects': check_effects, 'portals': check_portals, 'clicks': check_clicks,
'sleep': check_sleep, 'push': check_push, 'eat': check_eat,