[PR #3562] [MERGED] Leave the vehicle when a dead player is removed or respawns #5053

Closed
opened 2026-11-03 05:09:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3562
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ludovic111

Base: main ← Head: fix-3474


📝 Commits (1)

  • 2a7ee57 Leave the vehicle when a dead player is removed or respawns

📊 Changes

5 files changed (+47 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+1 -3)
📝 crates/horizon-client/src/game/remote.rs (+6 -0)
📝 crates/horizon-client/src/game/screens.rs (+3 -0)
📝 crates/horizon-client/src/lan/guest.rs (+33 -0)
📝 crates/horizon-client/src/lan/hub.rs (+4 -0)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Fixes #3474

If a player died in a boat (for example, riding it into the void), the respawned player was put straight back into the same boat. In the void, it then died again. The server never cleared the dead player's vehicle. A dead guest skips guest_server_tick (where a dead rider is dropped), so Guest.vehicle lasted through the respawn, and the next tick sat the new player in the boat's seat. The client also kept riding across the Respawn packet.

Vanilla's dead player leaves its vehicle when its body is removed, and in this PR Horizon does the same:

  • Server: Guest::tick_death (moved from guest_tick_death) stops the riding 20 ticks after death, when vanilla removes the body. Hub::respawn also does it, for a respawn before then (immediate_respawn). A dead body still sits in the boat for those 20 ticks, as in vanilla.
  • Client: a Respawn after a death (no KEEP_ENTITY_DATA bit) clears riding, because vanilla's new LocalPlayer (ClientPacketListener.handleRespawn → MultiPlayerGameMode.createPlayer) rides nothing. A dimension change (keep = 3) still keeps riding as before, so vehicle portal trips are unchanged.
  • In-frame: respawn_player clears the window player's riding.

The boat itself still falls forever below the world. Vanilla discards non-living entities there (Entity.onBelowWorld). That is a separate gap and is not touched here.

Vanilla reference

  • LivingEntity.tickDeath: at deathTime >= 20 on the server, broadcastEntityEvent(60) then remove(RemovalReason.KILLED).
  • PlayerList.respawn → ServerLevel.removePlayerImmediately(player, reason) → ServerPlayer.remove. A new ServerPlayer is created, which rides nothing.
  • Entity.setRemoved: when removalReason.shouldDestroy() (true for KILLED), it calls stopRiding().
  • ClientPacketListener.handleRespawn: always builds a new LocalPlayer, which rides nothing until the server pairs a vehicle again.
  • ClientboundRespawnPacket: KEEP_ENTITY_DATA = 2. Death respawns send 0 and dimension changes send 3 (Hub::respawn and the dimension change in hub.rs already send the same).

No parity harness covers riding through a respawn. The ones near it (hardcore_respawn, dedicated_server) run dedicated servers over the network. A unit test on the server-side rule covers it instead.

Self-check

tools/pr_ready.py was not run (Windows). These are the commands I ran:

cargo fmt --all -- --check                                              # ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings   # ok
cargo test -p horizon-client --lib lan::guest::tests::                  # 4 passed

New test: lan::guest::tests::a_dead_player_leaves_its_vehicle_when_its_body_is_removed. A dead guest in a boat stays seated for 19 death ticks and is out of the vehicle on the 20th.

Before (without the stop_riding in tick_death):

test lan::guest::tests::a_dead_player_leaves_its_vehicle_when_its_body_is_removed ... FAILED
assertion `left == right` failed
  left: (Some(7), Some([0.5, -120.0, 0.5]))
 right: (None, None)

After:

test lan::guest::tests::a_dead_player_leaves_its_vehicle_when_its_body_is_removed ... ok
test result: ok. 4 passed; 0 failed

In game

Setup: survival, a void shaft dug through the world, and a boat on a block over it. The player boards the boat and the block is removed. horizon-ctl status was sampled once a second.

Before (v0.2.97, server thread), from horizon-ctl status: after the respawn, the player is back in boat 1053 in the void and dies again:

t=6 screen: dead riding: 1053 y: -324.21 hp: 0.0
respawn:
t=0 screen: playing riding: 1053 pos: 216.5 -331.05 530.5 hp: 12.83
t=1 screen: playing riding: 1053 pos: 216.5 -357.01 530.5 hp: 2.50
t=2 screen: dead riding: 1053 pos: 216.5 -373.21 530.5 hp: 0.0

After (this branch, server thread): the body stays seated while dying, and the respawned player stands at the spawn:

t=7 screen: dead riding: 532 y: -382.41 hp: 0.0
respawn:
t=0..7 screen: playing riding: (none) pos: 211.5 65.0 521.5 hp: 20.0

Also checked:

  • With immediate_respawn true (respawn before the 20 ticks): back at 201.5 65.0 530.5, riding nothing.
  • With --in-frame: back at 214.5 66.0 526.5, riding nothing.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3562 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-3474` --- ### 📝 Commits (1) - [`2a7ee57`](https://github.com/horizon-rust/horizon/commit/2a7ee57bab3ece226e6d46fff0e337c0a9ab4240) Leave the vehicle when a dead player is removed or respawns ### 📊 Changes **5 files changed** (+47 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+1 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+6 -0) 📝 `crates/horizon-client/src/game/screens.rs` (+3 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+33 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+4 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3474 If a player died in a boat (for example, riding it into the void), the respawned player was put straight back into the same boat. In the void, it then died again. The server never cleared the dead player's vehicle. A dead guest skips `guest_server_tick` (where a dead rider is dropped), so `Guest.vehicle` lasted through the respawn, and the next tick sat the new player in the boat's seat. The client also kept `riding` across the `Respawn` packet. Vanilla's dead player leaves its vehicle when its body is removed, and in this PR Horizon does the same: - **Server:** `Guest::tick_death` (moved from `guest_tick_death`) stops the riding 20 ticks after death, when vanilla removes the body. `Hub::respawn` also does it, for a respawn before then (`immediate_respawn`). A dead body still sits in the boat for those 20 ticks, as in vanilla. - **Client:** a `Respawn` after a death (no `KEEP_ENTITY_DATA` bit) clears `riding`, because vanilla's new `LocalPlayer` (`ClientPacketListener.handleRespawn` → `MultiPlayerGameMode.createPlayer`) rides nothing. A dimension change (keep = 3) still keeps `riding` as before, so vehicle portal trips are unchanged. - **In-frame:** `respawn_player` clears the window player's `riding`. The boat itself still falls forever below the world. Vanilla discards non-living entities there (`Entity.onBelowWorld`). That is a separate gap and is not touched here. ## Vanilla reference - `LivingEntity.tickDeath`: at `deathTime >= 20` on the server, `broadcastEntityEvent(60)` then `remove(RemovalReason.KILLED)`. - `PlayerList.respawn` → `ServerLevel.removePlayerImmediately(player, reason)` → `ServerPlayer.remove`. A new `ServerPlayer` is created, which rides nothing. - `Entity.setRemoved`: when `removalReason.shouldDestroy()` (true for KILLED), it calls `stopRiding()`. - `ClientPacketListener.handleRespawn`: always builds a new `LocalPlayer`, which rides nothing until the server pairs a vehicle again. - `ClientboundRespawnPacket`: `KEEP_ENTITY_DATA = 2`. Death respawns send 0 and dimension changes send 3 (`Hub::respawn` and the dimension change in `hub.rs` already send the same). No parity harness covers riding through a respawn. The ones near it (`hardcore_respawn`, `dedicated_server`) run dedicated servers over the network. A unit test on the server-side rule covers it instead. ## Self-check `tools/pr_ready.py` was not run (Windows). These are the commands I ran: ``` cargo fmt --all -- --check # ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings # ok cargo test -p horizon-client --lib lan::guest::tests:: # 4 passed ``` New test: `lan::guest::tests::a_dead_player_leaves_its_vehicle_when_its_body_is_removed`. A dead guest in a boat stays seated for 19 death ticks and is out of the vehicle on the 20th. Before (without the `stop_riding` in `tick_death`): ``` test lan::guest::tests::a_dead_player_leaves_its_vehicle_when_its_body_is_removed ... FAILED assertion `left == right` failed left: (Some(7), Some([0.5, -120.0, 0.5])) right: (None, None) ``` After: ``` test lan::guest::tests::a_dead_player_leaves_its_vehicle_when_its_body_is_removed ... ok test result: ok. 4 passed; 0 failed ``` ## In game Setup: survival, a void shaft dug through the world, and a boat on a block over it. The player boards the boat and the block is removed. `horizon-ctl status` was sampled once a second. Before (v0.2.97, server thread), from `horizon-ctl status`: after the respawn, the player is back in boat 1053 in the void and dies again: ``` t=6 screen: dead riding: 1053 y: -324.21 hp: 0.0 respawn: t=0 screen: playing riding: 1053 pos: 216.5 -331.05 530.5 hp: 12.83 t=1 screen: playing riding: 1053 pos: 216.5 -357.01 530.5 hp: 2.50 t=2 screen: dead riding: 1053 pos: 216.5 -373.21 530.5 hp: 0.0 ``` After (this branch, server thread): the body stays seated while dying, and the respawned player stands at the spawn: ``` t=7 screen: dead riding: 532 y: -382.41 hp: 0.0 respawn: t=0..7 screen: playing riding: (none) pos: 211.5 65.0 521.5 hp: 20.0 ``` Also checked: - With `immediate_respawn true` (respawn before the 20 ticks): back at `201.5 65.0 530.5`, riding nothing. - With `--in-frame`: back at `214.5 66.0 526.5`, riding nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:09:54 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5053
No description provided.