[PR #1463] [MERGED] Totems save a server's players (guests and server-thread single player) #3541

Closed
opened 2026-11-03 04:10:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/st-totem


📝 Commits (1)

  • b8e729b Totems save a server's players: the guest's turn uses it up, and entity event 35 reaches every client

📊 Changes

6 files changed (+157 additions, -22 deletions)

View changed files

📝 crates/horizon-client/src/audio.rs (+7 -0)
📝 crates/horizon-client/src/game.rs (+2 -2)
📝 crates/horizon-client/src/game/lan_actions.rs (+13 -0)
📝 crates/horizon-client/src/game/remote.rs (+3 -0)
📝 crates/horizon-client/src/game/totem.rs (+79 -20)
📝 tools/lan_e2e.py (+53 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes #1292.

What

A totem of undying now saves a server's players: LAN guests, and the window's own player when single player runs on the server thread. Before this, they died holding it.

Why

LivingEntity.checkTotemDeathProtection ran only for the window's in-frame player. During a guest's turn, the hurt code marked the totem as used (totem_used), but nothing on the server side read that flag. Nothing set totem_ready for a guest either, and entity event 35 never reached any client.

How

game/totem.rs is split into two halves, as vanilla does it:

  • Server half (apply_totem), as in vanilla:
    • shrinks the stack, main hand first, then the off hand;
    • sets health to 1;
    • counts the used stat and the used_totem advancement trigger;
    • posts item_interact_finish;
    • clears effects, then adds regeneration II for 900 ticks, absorption II for 100 and fire resistance for 800.
  • Guest turns: enter_guest sets totem_ready from the guest's hands, and leave_guest runs the server half for the guest. hub.entity_event(id, 35, at) then goes to every client near, the guest itself included.
  • Client half (ClientPacketListener.handleEntityEvent 35): the 30-tick totem particle emitter, item.totem.use played locally (play_unshared, so the host's audio capture doesn't forward it a second time), and the rumble for one's own player. It runs for the window's own player, for an in-frame host's guests, and for a remote client receiving the event.

Not in this PR, and missing in both modes before and after: GameRenderer.displayItemActivation, the totem that flies across the screen.

Evidence

lan_e2e --check totem puts a totem in each hand in turn. The player is set to 1 HP, wears no armour and is killed with /damage 50. The check reads the screen, health on client and server, the effects, the totems left, and how many times each window played item.totem.use.

in-frame, before in-frame, after --server-thread, before --server-thread, after
host, off hand lives lives dead, 0 HP lives, 2.83 HP
host, main hand lives lives dead, totem kept lives, 2.5 HP
guest, off hand dead, heard 0/0 lives, heard 1/1 dead lives
guest, main hand dead, totem kept lives dead lives

After the fix, every case shows effects [absorption, fire_resistance, regeneration] and 0 totems left, and both the host and the guest hear the sound once.

How tested

Self-check on the top of the stack (fix/st-books, which contains this PR), Mac mini M4 Pro:

  • cargo fmt --all --check: OK
  • cargo clippy --workspace --all-targets -- -D warnings: OK
  • cargo test -p horizon-protocol: 71 passed. cargo test -p horizon-client --lib: 1061 passed (26 ignored). --bins: 98 + 18 passed.
  • python3 tools/parity.py --changed origin/main: 106 harnesses, 106 passed, 0 failed (23 min).
  • tools/lan_e2e.py, the new checks in both modes (in-frame, then --server-thread), host and guest; the existing sign and lectern checks still pass. Before = origin/main b65e082fd built with the same profile, after = this stack.

Stack

Four small PRs, one fix each, each on top of the previous one (the new lan_e2e checks share one block at the end of the file). Merge in order: #1463 (totem) → #1464 (keep_inventory) → #1465 (signs) → #1466 (books). The change for each PR is its top commit. #1475 (Elytra) and #1476 (shields, tridents, crossbows, spyglasses) continue the stack after #1466.

They leave alone the lines that #1419, #1420 and #1423–#1427 change in tools/lan_e2e.py. The new checks go in a block before if __name__ (CHECKS += [...], CHECK_FNS.update(...)). git merge-tree is clean against each of #1423–#1427. #1419 and #1420 already conflict with main on their own.

Needs Ludovic

A review and a merge, in stack order. Nothing else.

🤖 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/1463 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/st-totem` --- ### 📝 Commits (1) - [`b8e729b`](https://github.com/horizon-rust/horizon/commit/b8e729b950284890ec79d11e4bb448e3a3e4782c) Totems save a server's players: the guest's turn uses it up, and entity event 35 reaches every client ### 📊 Changes **6 files changed** (+157 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/audio.rs` (+7 -0) 📝 `crates/horizon-client/src/game.rs` (+2 -2) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+13 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+3 -0) 📝 `crates/horizon-client/src/game/totem.rs` (+79 -20) 📝 `tools/lan_e2e.py` (+53 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #1292. ## What A totem of undying now saves a server's players: LAN guests, and the window's own player when single player runs on the server thread. Before this, they died holding it. ## Why `LivingEntity.checkTotemDeathProtection` ran only for the window's in-frame player. During a guest's turn, the hurt code marked the totem as used (`totem_used`), but nothing on the server side read that flag. Nothing set `totem_ready` for a guest either, and entity event 35 never reached any client. ## How `game/totem.rs` is split into two halves, as vanilla does it: - **Server half** (`apply_totem`), as in vanilla: - shrinks the stack, main hand first, then the off hand; - sets health to 1; - counts the `used` stat and the `used_totem` advancement trigger; - posts `item_interact_finish`; - clears effects, then adds regeneration II for 900 ticks, absorption II for 100 and fire resistance for 800. - **Guest turns:** `enter_guest` sets `totem_ready` from the guest's hands, and `leave_guest` runs the server half for the guest. `hub.entity_event(id, 35, at)` then goes to every client near, the guest itself included. - **Client half** (`ClientPacketListener.handleEntityEvent` 35): the 30-tick totem particle emitter, `item.totem.use` played locally (`play_unshared`, so the host's audio capture doesn't forward it a second time), and the rumble for one's own player. It runs for the window's own player, for an in-frame host's guests, and for a remote client receiving the event. Not in this PR, and missing in both modes before and after: `GameRenderer.displayItemActivation`, the totem that flies across the screen. ## Evidence `lan_e2e --check totem` puts a totem in each hand in turn. The player is set to 1 HP, wears no armour and is killed with `/damage 50`. The check reads the screen, health on client and server, the effects, the totems left, and how many times each window played `item.totem.use`. | | in-frame, before | in-frame, after | `--server-thread`, before | `--server-thread`, after | |---|---|---|---|---| | host, off hand | lives | lives | **dead**, 0 HP | lives, 2.83 HP | | host, main hand | lives | lives | **dead**, totem kept | lives, 2.5 HP | | guest, off hand | **dead**, heard 0/0 | lives, heard 1/1 | **dead** | lives | | guest, main hand | **dead**, totem kept | lives | **dead** | lives | After the fix, every case shows effects `[absorption, fire_resistance, regeneration]` and 0 totems left, and both the host and the guest hear the sound once. ## How tested Self-check on the top of the stack (fix/st-books, which contains this PR), Mac mini M4 Pro: - `cargo fmt --all --check`: OK - `cargo clippy --workspace --all-targets -- -D warnings`: OK - `cargo test -p horizon-protocol`: 71 passed. `cargo test -p horizon-client --lib`: 1061 passed (26 ignored). `--bins`: 98 + 18 passed. - `python3 tools/parity.py --changed origin/main`: 106 harnesses, 106 passed, 0 failed (23 min). - `tools/lan_e2e.py`, the new checks in both modes (in-frame, then `--server-thread`), host and guest; the existing `sign` and `lectern` checks still pass. Before = origin/main b65e082fd built with the same profile, after = this stack. ## Stack Four small PRs, one fix each, each on top of the previous one (the new lan_e2e checks share one block at the end of the file). Merge in order: #1463 (totem) → #1464 (keep_inventory) → #1465 (signs) → #1466 (books). The change for each PR is its top commit. #1475 (Elytra) and #1476 (shields, tridents, crossbows, spyglasses) continue the stack after #1466. They leave alone the lines that #1419, #1420 and #1423–#1427 change in `tools/lan_e2e.py`. The new checks go in a block before `if __name__` (`CHECKS += [...]`, `CHECK_FNS.update(...)`). `git merge-tree` is clean against each of #1423–#1427. #1419 and #1420 already conflict with main on their own. ## Needs Ludovic A review and a merge, in stack order. Nothing else. 🤖 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 04:10:17 +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#3541
No description provided.