Move subtitles into the HUD overlays and save scoreboards end to end
The subtitle overlay now lays out GuiDraw calls in hud_overlays and the game paints them like the other overlays. Hover events that show an entity save its UUID as an int array, as UUIDUtil.CODEC does. The save round trip builds a vanilla scoreboard with every saved field (objectives, number formats, display slots, locked and displayed scores, teams with every option) and requires Horizon to save scoreboard.dat as vanilla did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -176,6 +176,59 @@ def block_position(i):
|
||||
return 2 + 3 * (i % 10), -60, 2 + 3 * (i // 10)
|
||||
|
||||
|
||||
SCOREBOARD = [
|
||||
'scoreboard objectives add kills totalKillCount {"text":"Kills","color":"red"}',
|
||||
'scoreboard objectives add d dummy',
|
||||
'scoreboard objectives add hearts dummy "Hearts"',
|
||||
'scoreboard objectives modify hearts rendertype hearts',
|
||||
'scoreboard objectives add t trigger',
|
||||
'scoreboard objectives add mined minecraft.mined:minecraft.stone',
|
||||
'scoreboard objectives modify d displayautoupdate true',
|
||||
'scoreboard objectives modify d numberformat styled {"color":"gold","bold":true}',
|
||||
'scoreboard objectives modify kills numberformat blank',
|
||||
'scoreboard objectives setdisplay sidebar d',
|
||||
'scoreboard objectives setdisplay below_name hearts',
|
||||
'scoreboard objectives setdisplay sidebar.team.red kills',
|
||||
'scoreboard players set #fake d 5',
|
||||
'scoreboard players set Alex d -3',
|
||||
'scoreboard players set Alex kills 7',
|
||||
'scoreboard players set Alex hearts 0',
|
||||
'scoreboard players set Steve hearts 12',
|
||||
'scoreboard players add {uuid0} d 2',
|
||||
'scoreboard players display name Alex d {"text":"Alexandra","italic":true}',
|
||||
'scoreboard players display numberformat Alex hearts fixed "lots"',
|
||||
'scoreboard players enable Alex t',
|
||||
'scoreboard players set Steve t 3',
|
||||
'team add red {"text":"Red Team"}',
|
||||
'team modify red color red',
|
||||
'team modify red prefix "[R] "',
|
||||
'team modify red suffix {"text":" *","color":"gold"}',
|
||||
'team modify red friendlyFire false',
|
||||
'team modify red seeFriendlyInvisibles false',
|
||||
'team modify red nametagVisibility hideForOtherTeams',
|
||||
'team modify red deathMessageVisibility never',
|
||||
'team modify red collisionRule pushOwnTeam',
|
||||
'team join red Alex',
|
||||
'team join red #fake',
|
||||
'team add blue',
|
||||
'team join blue {uuid0}',
|
||||
'team join blue Steve',
|
||||
]
|
||||
|
||||
|
||||
def normalize_scoreboard(data):
|
||||
"""Each holder's scores sit in an identity-hash map in vanilla: compare them as a set."""
|
||||
scores = data.get('data', {}).get('PlayerScores') if isinstance(data, dict) else None
|
||||
if isinstance(scores, list):
|
||||
order = []
|
||||
for row in scores:
|
||||
if row.get('Name') not in order:
|
||||
order.append(row.get('Name'))
|
||||
data['data']['PlayerScores'] = sorted(
|
||||
scores, key=lambda r: (order.index(r.get('Name')), json.dumps(r, sort_keys=True, default=str)))
|
||||
return data
|
||||
|
||||
|
||||
def build_world(directory):
|
||||
"""Fill a fresh vanilla world; returns the failed scene commands."""
|
||||
server = Vanilla(directory)
|
||||
@@ -199,6 +252,12 @@ def build_world(directory):
|
||||
out = server.run(command)
|
||||
if command_failed(out):
|
||||
failed.append((command, out))
|
||||
# A scoreboard with every kind of saved field (scoreboard.dat). No criteria that
|
||||
# Horizon's own player (not the bot) would update while it runs.
|
||||
for command in SCOREBOARD:
|
||||
out = server.run(command.replace('{uuid0}', entity_uuid_text(0)))
|
||||
if command_failed(out):
|
||||
failed.append((command, out))
|
||||
server.run('time set 6000')
|
||||
server.run('gamerule advance_time false')
|
||||
server.run('gamerule advance_weather false')
|
||||
@@ -472,7 +531,10 @@ def compare_worlds(vanilla, horizon):
|
||||
if not b.exists():
|
||||
report.append((rel, 'present', 'missing from Horizon'))
|
||||
elif a.exists():
|
||||
compare_dat(rel, anvil_dump.read_dat(str(a)), anvil_dump.read_dat(str(b)), report)
|
||||
va, hb = anvil_dump.read_dat(str(a)), anvil_dump.read_dat(str(b))
|
||||
if rel.endswith('scoreboard.dat'):
|
||||
va, hb = normalize_scoreboard(va), normalize_scoreboard(hb)
|
||||
compare_dat(rel, va, hb, report)
|
||||
return report
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ def components(rng, name=None):
|
||||
lambda: {'type': 'text', 'text': 'typed'},
|
||||
lambda: {'keybind': 'key.jump'},
|
||||
lambda: {'text': 'strike', 'strikethrough': True, 'obfuscated': False},
|
||||
lambda: {'text': name or 'E', 'hover_event': {'action': 'show_entity', 'id': 'minecraft:pig',
|
||||
'uuid': [rng.randint(-9, 9) for _ in range(4)]}},
|
||||
lambda: {'text': 'tip', 'hover_event': {'action': 'show_text', 'value': {'text': 'hi', 'color': 'red'}}},
|
||||
]
|
||||
return rng.choice(choices)()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user