Respawn on a server in vanilla's order, so vanilla clients leave the loading screen

A vanilla 26.3 client that died on a Horizon server stayed on its loading
screen after pressing Respawn (#566): ClientPacketListener.handleRespawn
starts a LevelLoadTracker that waits for the level info's "level chunks
load start" game event and the chunk under the player, and Horizon's
respawn sent neither the level info nor the chunk cache centre.

The hub's respawn now follows PlayerList.respawn: the entities paired with
the dead player are removed (one packet each), its chunks are dropped
without ForgetLevelChunk (as PlayerChunkSender does for a dead player) and
sent again, the abilities, then Respawn (with the last death location),
the teleport to the spawn facing its direction, the default spawn,
difficulty, experience, post effects, the level info, the permission
level, the chunk cache centre and the inventory. A dying guest also gets
the death animation event and no health update while dead, as vanilla's
ServerPlayer.die does.

Guests' commands also ran at the host's permission level: an operator on
a dedicated server could not run operator commands (and LAN guests ran
the host's level). They now run at the guest's own level, as the command
tree they are sent says.

The dedicated server harness covers it: after trading, the vanilla-codec
client is made an operator by the console, runs /kill, respawns, and the
packets from the death screen to the respawned inventory are compared
with vanilla's, then the level must load where it respawned. The client
also stops sending a movement packet beside each teleport acceptance
during the respawn: the 26.3 client sends the acceptance alone, and
vanilla's server kicks a second position in the same tick.

Fixes #566

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-17 02:12:08 +02:00
parent ad5f05a8c7
commit 66d187ed06
5 changed files with 250 additions and 34 deletions
+36 -4
View File
@@ -10,8 +10,11 @@ read is an error), pings each server, joins it in offline mode through
login, configuration and play, accepts the spawn teleport, receives the
chunks around the spawn (their bytes are compared: the world is loaded from
the same files), chats, runs /list and commands that fail (`/random value
7..7`, `/random value x`, `/trigger nope`) and leaves. The console then
runs `list` and `say` and `stop`. Compared, all of them exactly:
7..7`, `/random value x`, `/trigger nope`), trades, is made an operator by
the console, runs /kill, respawns (as vanilla's LevelLoadTracker waits: until the "level
chunks load start" event and the chunk under the player) and leaves. The
console then runs `list` and `say` and `stop`. Compared, all of them
exactly:
- the status response (MOTD, players, version, favicon) and the ping;
- the legacy (pre-1.7, 0xFE) ping reply;
@@ -22,6 +25,10 @@ runs `list` and `say` and `stop`. Compared, all of them exactly:
advancements, which vanilla keeps in hash maps, sorted); the command tree
node by node; the chunks sent and their bytes; the replies to the chat
message, /list and the failing commands, as text components;
- after /kill, the packets from the death screen to the respawned
inventory (PlayerList.respawn; chat, chunk data, light and keep-alives
left out, runs of a packet counted), then that the level loads where the
player respawned (guests' death messages aren't Horizon's yet: left out);
- the console lines about the player, the chat, `list`, `say` and `stop`;
- the files the servers leave: server.properties (but the date line),
eula.txt, ops.json, whitelist.json, banned-players.json, banned-ips.json.
@@ -197,12 +204,17 @@ CONSOLE_LINE = re.compile(r'^\[\d\d:\d\d:\d\d\] \[([^\]]+)\]: (.*)$')
KEPT = re.compile(r'Tester|\[Server\]|\[Not Secure\]|There are|Stopping|Saving|ThreadedAnvilChunkStorage|All dimensions|Unknown or incomplete')
# Guests' death messages and the op's command feedback broadcast to the console aren't
# Horizon's yet (the client's own transcript leaves the death message out as well).
NOT_YET = re.compile(r'Tester was killed|Killed Tester|^\[Tester: ')
def console_lines(lines):
"""The console lines the comparison covers, timestamps and ports aside."""
out = []
for line in lines:
m = CONSOLE_LINE.match(line)
if not m or not KEPT.search(m.group(2)):
if not m or not KEPT.search(m.group(2)) or NOT_YET.search(m.group(2)):
continue
text = re.sub(r'/127\.0\.0\.1:\d+', '/127.0.0.1:_', m.group(2))
text = re.sub(r'entity id \d+', 'entity id _', text)
@@ -246,7 +258,27 @@ def run_side(label, command, directory, client):
'{profession:"minecraft:librarian",level:2,type:"minecraft:plains"}}')
port = int(PROPERTIES_PORTS[label])
legacy = legacy_ping(port)
client(port, directory.parent / f'{label}-client.txt')
# The client asks to be made an operator once it has traded, runs /kill and respawns.
failure = []
def join():
try:
client(port, directory.parent / f'{label}-client.txt')
except BaseException as error: # noqa: BLE001 - reported on the main thread
failure.append(error)
joined = threading.Thread(target=join)
joined.start()
deadline = time.time() + 300
while joined.is_alive() and not any('<Tester> ready to respawn' in l for l in server.lines):
if time.time() > deadline:
break
time.sleep(0.2)
if joined.is_alive():
server.console(f'op {PLAYER}')
joined.join()
if failure:
raise failure[0]
time.sleep(1)
server.console('list')
server.console('say console says hi')