[PR #1849] [MERGED] Drop the cursor stack of a dead player #3814

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

📋 Pull Request Information

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

Base: main ← Head: fix/1329-cursor-death


📝 Commits (6)

  • 0481dbd Make hardcore players spectators when they respawn
  • 10efca9 Discard a dead player's ender pearl when the rule says so
  • 5bfc649 Drop the cursor stack of a dead player
  • 50727eb Harnesses: one scaffold for one-player dedicated server scripts
  • 94bc569 Merge #1843 into #1847: share LocatorBarClient's respawn command and the harness scaffold
  • 75951a7 Merge #1847 into #1849: LocatorBarClient's respawn and use commands, the harness scaffold

📊 Changes

12 files changed (+356 additions, -14 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+19 -1)
📝 crates/horizon-client/src/game/agent.rs (+6 -2)
📝 crates/horizon-client/src/game/chat.rs (+2 -0)
📝 crates/horizon-client/src/game/creatures.rs (+19 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+31 -1)
📝 crates/horizon-client/src/game/screens.rs (+22 -5)
📝 crates/horizon-client/src/lan/guest.rs (+3 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/LocatorBarClient.java (+19 -1)
➕ tools/test_cursor_death_parity.py (+58 -0)
➕ tools/test_hardcore_respawn_parity.py (+49 -0)
📝 tools/test_locator_bar_parity.py (+72 -4)
➕ tools/test_pearl_death_parity.py (+56 -0)

📄 Description

What and why

Fixes #1329.

A stack held on the inventory cursor when the player died stayed on the cursor through the respawn, even with keep_inventory off, so it could be put back into the new inventory. In vanilla, LivingEntity.tickDeath removes the dead player 20 ticks after death. PlayerList.respawn removes it too if the player respawns sooner. Player.remove then calls inventoryMenu.removed, and for a removed player dropOrPlaceInInventory drops the cursor stack where the player died. This does not depend on keep_inventory.

  • Server players (server thread, LAN, dedicated): each guest now has a death_time. The dead guest's cursor stack is dropped at 20 ticks, or at respawn if that comes first.
  • In-frame player (--no-server-thread): the same at 20 ticks after death, thrown from the eyes like Player.drop but without the drop statistics or arm swing (thrownFromHand is false). player_drop's throw is split out as throw_from_eyes for this.

The 2x2 crafting grid, which InventoryMenu.removed also clears, is not changed here.

Vanilla reference

  • LivingEntity.tickDeath, Player.remove
  • AbstractContainerMenu.removed, AbstractContainerMenu.dropOrPlaceInInventory, InventoryMenu.removed
  • ServerPlayer.drop (statistics only when thrown from the hand)

New harness tools/test_cursor_death_parity.py: a vanilla dedicated server and Horizon's each serve the same flat world with keep_inventory off. A LocatorBarClient player is given 7 diamonds, picks them up onto the cursor (new pickup NAME SLOT command, a PICKUP ContainerClick), moves 10 blocks from spawn, runs /kill @s, waits and respawns (new respawn NAME command). It then asks whether an item lies at the death site. The inventory slots, respawn, teleport and that reply are compared exactly. Both servers answer that one item is there. I did not run it against the unfixed build. Without the fix nothing is dropped, so the reply would differ.

The harness covers the dedicated server path. The in-frame path builds but no harness exercises it.

Ran: python3 tools/parity.py cursor_death. parity.py --changed origin/main selects nearly every harness for a horizon-client change, so I only ran this one. The build (cargo blaze build -p horizon-client) is clean.

Self-check

pr_ready (tools/pr_ready.py --quick on device-591, against origin/main at bd591f985, 3 min 0 s)

Check Result
Scope ✅ 6 files, +202 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 267 passed (27 s)
rustfmt ✅ (5 s)
clippy ✅ (11 s)
tests: horizon-client ✅ 1236 passed (2 min 14 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 331 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 319 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🔄 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/1849 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/1329-cursor-death` --- ### 📝 Commits (6) - [`0481dbd`](https://github.com/horizon-rust/horizon/commit/0481dbdb81e49134f42dccafb58474504466a440) Make hardcore players spectators when they respawn - [`10efca9`](https://github.com/horizon-rust/horizon/commit/10efca9e6cd922ff7b9a4a3cc3f5a467e97f52f2) Discard a dead player's ender pearl when the rule says so - [`5bfc649`](https://github.com/horizon-rust/horizon/commit/5bfc649edd18aaf9738dc428bc24ae9e991cf87d) Drop the cursor stack of a dead player - [`50727eb`](https://github.com/horizon-rust/horizon/commit/50727eb5c3d389628549c9237bbcca76029c3b79) Harnesses: one scaffold for one-player dedicated server scripts - [`94bc569`](https://github.com/horizon-rust/horizon/commit/94bc569a7fb518fb8c56538c3c774edf0e20b71c) Merge #1843 into #1847: share LocatorBarClient's respawn command and the harness scaffold - [`75951a7`](https://github.com/horizon-rust/horizon/commit/75951a769a7bc67ee4eb026df8fbd31b087f6fca) Merge #1847 into #1849: LocatorBarClient's respawn and use commands, the harness scaffold ### 📊 Changes **12 files changed** (+356 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+19 -1) 📝 `crates/horizon-client/src/game/agent.rs` (+6 -2) 📝 `crates/horizon-client/src/game/chat.rs` (+2 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+19 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+31 -1) 📝 `crates/horizon-client/src/game/screens.rs` (+22 -5) 📝 `crates/horizon-client/src/lan/guest.rs` (+3 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/LocatorBarClient.java` (+19 -1) ➕ `tools/test_cursor_death_parity.py` (+58 -0) ➕ `tools/test_hardcore_respawn_parity.py` (+49 -0) 📝 `tools/test_locator_bar_parity.py` (+72 -4) ➕ `tools/test_pearl_death_parity.py` (+56 -0) </details> ### 📄 Description ## What and why Fixes #1329. A stack held on the inventory cursor when the player died stayed on the cursor through the respawn, even with `keep_inventory` off, so it could be put back into the new inventory. In vanilla, `LivingEntity.tickDeath` removes the dead player 20 ticks after death. `PlayerList.respawn` removes it too if the player respawns sooner. `Player.remove` then calls `inventoryMenu.removed`, and for a removed player `dropOrPlaceInInventory` drops the cursor stack where the player died. This does not depend on `keep_inventory`. - Server players (server thread, LAN, dedicated): each guest now has a `death_time`. The dead guest's cursor stack is dropped at 20 ticks, or at respawn if that comes first. - In-frame player (`--no-server-thread`): the same at 20 ticks after death, thrown from the eyes like `Player.drop` but without the drop statistics or arm swing (`thrownFromHand` is false). `player_drop`'s throw is split out as `throw_from_eyes` for this. The 2x2 crafting grid, which `InventoryMenu.removed` also clears, is not changed here. ## Vanilla reference - `LivingEntity.tickDeath`, `Player.remove` - `AbstractContainerMenu.removed`, `AbstractContainerMenu.dropOrPlaceInInventory`, `InventoryMenu.removed` - `ServerPlayer.drop` (statistics only when thrown from the hand) New harness `tools/test_cursor_death_parity.py`: a vanilla dedicated server and Horizon's each serve the same flat world with `keep_inventory` off. A LocatorBarClient player is given 7 diamonds, picks them up onto the cursor (new `pickup NAME SLOT` command, a PICKUP ContainerClick), moves 10 blocks from spawn, runs `/kill @s`, waits and respawns (new `respawn NAME` command). It then asks whether an item lies at the death site. The inventory slots, respawn, teleport and that reply are compared exactly. Both servers answer that one item is there. I did not run it against the unfixed build. Without the fix nothing is dropped, so the reply would differ. The harness covers the dedicated server path. The in-frame path builds but no harness exercises it. Ran: `python3 tools/parity.py cursor_death`. `parity.py --changed origin/main` selects nearly every harness for a horizon-client change, so I only ran this one. The build (`cargo blaze build -p horizon-client`) is clean. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on device-591, against origin/main at bd591f985, 3 min 0 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +202 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 267 passed (27 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (11 s) | | tests: horizon-client | ✅ 1236 passed (2 min 14 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 331 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 319 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12: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#3814
No description provided.