[PR #4341] [MERGED] Make the client-loaded immunity term real #5571

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4341
Author: @MSedgeMC
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/4301-respawn-immunity


📝 Commits (3)

  • 015fbc8 Make the client-loaded immunity term real
  • de6436f Merge remote-tracking branch 'origin/main' into pr-4341
  • 18a3169 Format the respawn immunity test

📊 Changes

6 files changed (+111 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+2 -0)
📝 crates/horizon-client/src/health.rs (+37 -1)
📝 crates/horizon-client/src/hunger.rs (+3 -0)
📝 crates/horizon-client/src/lan/hub.rs (+5 -0)
📝 crates/horizon-client/src/motion.rs (+5 -0)
📝 crates/horizon-client/tests/lan_bot.rs (+59 -0)

📄 Description

Fixes #4301.

ServerPlayer.isInvulnerableTo has three terms. The third is !connection.hasClientLoaded(): from a death until the client reports the world loaded (or vanilla's 60-tick load timer expires), nothing hurts the player. That is what spares a respawned player the void during the tick it is still standing where it died — there is no invulnerableTime/hurtTime window in 26.3; PlayerList.respawn writes neither.

Horizon implemented all three terms in damage_immunity.rs, but the only production implementation of the trait returned Ok(true) for this one (health.rs), so the term was dead code and the void's 4.0 landed on the respawn tick.

A guest now carries the flag: true when admitted, cleared by Hub::respawn, set by ServerboundPlayerLoadedPacket (vanilla's handleAcceptPlayerLoad, sent after Login or Respawn), copied onto the body in enter_guest, and read by the damage Environment — which the starvation path builds too, so starvation now obeys the same immunity. A level change does not clear it: vanilla resets the loaded state on death and respawn only and covers a portal with its separate isChangingDimension term.

What is proven: both tests ran on a build box — cargo test -p horizon-client --lib health::tests::the_void_spares → 1 passed, and cargo test -p horizon-client --test lan_bot a_respawned_guest → 1 passed. The first is the decision: an unloaded client takes no out_of_world damage and keeps 20.0 health; loaded, it takes 4.0 and drops to 16.0. The second drives a real protocol bot through Hub::respawn and the PlayerLoaded packet and asserts the flag at each step.

What is not proven: the literal end-to-end the report describes — guest below MIN_Y - 64, die, respawn, one server tick, health 20 rather than 16 — is not reachable from the integration tests, because the hazard tick lives in the game binary; nobody has watched it. And vanilla bounds this window with a client-load timer that Horizon does not have, so a client that never sends PlayerLoaded after a respawn would stay immune — every protocol-777 client, Horizon's own included, sends it.

Known and untouched: Environment still hardcodes changing_dimension = false, so Horizon has no equivalent of vanilla's dimension-change immunity. That is a separate gap and this PR does not pretend to cover it.


🔄 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/4341 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/4301-respawn-immunity` --- ### 📝 Commits (3) - [`015fbc8`](https://github.com/horizon-rust/horizon/commit/015fbc82c11c8ec6e34eed40ab43b76d2a602aee) Make the client-loaded immunity term real - [`de6436f`](https://github.com/horizon-rust/horizon/commit/de6436fd884c8ddbf560e53fc9b2b50e052784f0) Merge remote-tracking branch 'origin/main' into pr-4341 - [`18a3169`](https://github.com/horizon-rust/horizon/commit/18a3169447474e6f03e6869a937c2a213f6c2a15) Format the respawn immunity test ### 📊 Changes **6 files changed** (+111 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+2 -0) 📝 `crates/horizon-client/src/health.rs` (+37 -1) 📝 `crates/horizon-client/src/hunger.rs` (+3 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+5 -0) 📝 `crates/horizon-client/src/motion.rs` (+5 -0) 📝 `crates/horizon-client/tests/lan_bot.rs` (+59 -0) </details> ### 📄 Description Fixes #4301. `ServerPlayer.isInvulnerableTo` has three terms. The third is `!connection.hasClientLoaded()`: from a death until the client reports the world loaded (or vanilla's 60-tick load timer expires), **nothing** hurts the player. That is what spares a respawned player the void during the tick it is still standing where it died — there is no `invulnerableTime`/`hurtTime` window in 26.3; `PlayerList.respawn` writes neither. Horizon implemented all three terms in `damage_immunity.rs`, but the only production implementation of the trait returned `Ok(true)` for this one (`health.rs`), so the term was dead code and the void's 4.0 landed on the respawn tick. A guest now carries the flag: `true` when admitted, cleared by `Hub::respawn`, set by `ServerboundPlayerLoadedPacket` (vanilla's `handleAcceptPlayerLoad`, sent after Login *or* Respawn), copied onto the body in `enter_guest`, and read by the damage `Environment` — which the starvation path builds too, so starvation now obeys the same immunity. A **level change does not clear it**: vanilla resets the loaded state on death and respawn only and covers a portal with its separate `isChangingDimension` term. **What is proven:** both tests ran on a build box — `cargo test -p horizon-client --lib health::tests::the_void_spares` → 1 passed, and `cargo test -p horizon-client --test lan_bot a_respawned_guest` → 1 passed. The first is the decision: an unloaded client takes no `out_of_world` damage and keeps 20.0 health; loaded, it takes 4.0 and drops to 16.0. The second drives a real protocol bot through `Hub::respawn` and the `PlayerLoaded` packet and asserts the flag at each step. **What is not proven:** the literal end-to-end the report describes — guest below `MIN_Y - 64`, die, respawn, one server tick, health 20 rather than 16 — is not reachable from the integration tests, because the hazard tick lives in the game binary; nobody has watched it. And vanilla bounds this window with a client-load timer that Horizon does not have, so a client that never sends `PlayerLoaded` after a respawn would stay immune — every protocol-777 client, Horizon's own included, sends it. Known and untouched: `Environment` still hardcodes `changing_dimension = false`, so Horizon has no equivalent of vanilla's dimension-change immunity. That is a separate gap and this PR does not pretend to cover it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:29 +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#5571
No description provided.