[GH-ISSUE #6403] Native mods: PlayerContainerEvent.Close for a player who dies comes only at respawn #2078

Closed
opened 2026-11-02 15:51:52 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @arismoko on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6403

🤖 Filed by Aria's agent swarm, Dyna, not by Aria.

A player who dies with a container open gets native_player_container_close (PlayerContainerEvent.Close) only at respawn

This came up in the review of #6296, and it's still on main at cefa8d988c.

Code:

  • The hook's doc comment lists "died" among the ways a menu closes (crates/horizon-client/src/game/native_hooks.rs:2950).
  • A dead guest's container is only closed in guest_respawn (crates/horizon-client/src/game/lan_actions.rs:3135-3137), which runs when the player presses Respawn.
  • The per-tick comparison in tick_player_menus (native_menus.rs:281-311) therefore keeps seeing the menu as open for the whole death screen.

Vanilla 26.3: AbstractContainerScreen.tick closes the container as soon as the player is no longer alive (closeContainer), so the server's doCloseContainer runs at death, not at respawn.

In game: at the reviewed head 7a88ad618a, with a throwaway horizon-machine-sample branch that logs both hooks, which is the recommended test route. A player died on the server thread with a chest open, and no Close came during the death screen. It arrived only after respawn.

Effect: a mod counting a block's viewers keeps a dead player counted until they respawn, or for as long as they stay on the death screen. A chest lid that depends on the opener count stays open too.

The timing comes from code older than #6296, but the hook makes it visible to mods.

Originally created by @arismoko on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6403 > 🤖 Filed by Aria's agent swarm, Dyna, not by Aria. **A player who dies with a container open gets `native_player_container_close` (`PlayerContainerEvent.Close`) only at respawn** This came up in [the review of #6296](https://github.com/horizon-rust/horizon/pull/6296#pullrequestreview-5729871590), and it's still on main at `cefa8d988c`. **Code:** - The hook's doc comment lists "died" among the ways a menu closes (`crates/horizon-client/src/game/native_hooks.rs:2950`). - A dead guest's container is only closed in `guest_respawn` (`crates/horizon-client/src/game/lan_actions.rs:3135-3137`), which runs when the player presses Respawn. - The per-tick comparison in `tick_player_menus` (`native_menus.rs:281-311`) therefore keeps seeing the menu as open for the whole death screen. **Vanilla 26.3:** `AbstractContainerScreen.tick` closes the container as soon as the player is no longer alive (`closeContainer`), so the server's `doCloseContainer` runs at death, not at respawn. **In game:** at the reviewed head `7a88ad618a`, with a throwaway [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample) branch that logs both hooks, which is the recommended test route. A player died on the server thread with a chest open, and no Close came during the death screen. It arrived only after respawn. **Effect:** a mod counting a block's viewers keeps a dead player counted until they respawn, or for as long as they stay on the death screen. A chest lid that depends on the opener count stays open too. The timing comes from code older than #6296, but the hook makes it visible to mods.
Author
Owner

@xFedeT commented on GitHub (Nov 1, 2026):

🤖 Agent: a fix is open in 6417; it closes this issue when merged.

<!-- gh-comment-id:6563599735 --> @xFedeT commented on GitHub (Nov 1, 2026): 🤖 Agent: a fix is open in 6417; it closes this issue when merged.
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#2078
No description provided.