[PR #1059] [MERGED] fix: prevent spectators from dropping hotbar items #3011

Closed
opened 2026-11-02 16:00:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1059
Author: @rdbtCVS
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @ludovic111

Base: main ← Head: fix/spectator-item-drop-1053


📝 Commits (1)

  • a29d293 fix: prevent spectators from dropping hotbar items

📊 Changes

5 files changed (+211 additions, -7 deletions)

View changed files

➕ crates/horizon-client/examples/held_drop_fixture.rs (+29 -0)
📝 crates/horizon-client/src/game.rs (+6 -3)
📝 crates/horizon-client/src/items.rs (+25 -4)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaHeldDropOracle.java (+109 -0)
➕ tools/test_held_drop_parity.py (+42 -0)

📄 Description

What and why

Fixes #1053.

Spectators could press Q or Ctrl+Q to remove items from the selected hotbar slot and spawn dropped items. Reject selected-slot drops before removing inventory contents when the player is a spectator, so the existing caller also skips item spawning, swinging and drop statistics. Survival, creative and adventure drops retain their existing behavior.

Add a regression test covering both drop shortcuts and dropping again after leaving spectator, plus a vanilla parity harness covering all four game modes, both shortcuts, selected slots 0/8, empty/single/partial/full stacks, and repeated presses.

Vanilla reference

Followed the pinned 26.3 net.minecraft.client.Minecraft.handleKeybinds using tools/rea_vanilla.py: its drop-key loop checks !player.isSpectator() before calling MultiPlayerGameMode.dropItem.

tools/test_held_drop_parity.py invokes the unmodified vanilla key handler up through that loop. A controlled drop callback removes from vanilla's actual Inventory; the Rust probe runs the production take_held_drop helper. All 128 selected-stack/drop-count snapshots match vanilla. Networking, spawned entities, animation and statistics are outside this harness's scope.

Self-check

  • Vanilla held-drop parity: passed (128 snapshots).
  • Public tree and outgoing branch history: passed.
  • Full client test suite: 1,031 passed.
  • Python tests: 251 passed.
  • Formatting and workspace Clippy with warnings denied: passed.
  • The completed self-check below supersedes the earlier run interrupted by disk exhaustion. Other affected parity harnesses remain for CI.

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at defaa7cd2, 12 min 48 s)

Check Result
Scope ✅ 5 files, +211 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 251 passed (37 s)
rustfmt ✅ (8 s)
clippy ✅ (1 min 29 s)
tests: horizon-client ✅ 1031 passed (10 min 31 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 276 affected, to run in CI (--quick): ambient_sound, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo, basic_feature, biome_chunk, biome_generation and 264 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/1059 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/20/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/spectator-item-drop-1053` --- ### 📝 Commits (1) - [`a29d293`](https://github.com/horizon-rust/horizon/commit/a29d293e8ecb30d1935cc60e1e33289b503d1624) fix: prevent spectators from dropping hotbar items ### 📊 Changes **5 files changed** (+211 additions, -7 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/held_drop_fixture.rs` (+29 -0) 📝 `crates/horizon-client/src/game.rs` (+6 -3) 📝 `crates/horizon-client/src/items.rs` (+25 -4) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaHeldDropOracle.java` (+109 -0) ➕ `tools/test_held_drop_parity.py` (+42 -0) </details> ### 📄 Description ## What and why Fixes #1053. Spectators could press Q or Ctrl+Q to remove items from the selected hotbar slot and spawn dropped items. Reject selected-slot drops before removing inventory contents when the player is a spectator, so the existing caller also skips item spawning, swinging and drop statistics. Survival, creative and adventure drops retain their existing behavior. Add a regression test covering both drop shortcuts and dropping again after leaving spectator, plus a vanilla parity harness covering all four game modes, both shortcuts, selected slots 0/8, empty/single/partial/full stacks, and repeated presses. ## Vanilla reference Followed the pinned 26.3 `net.minecraft.client.Minecraft.handleKeybinds` using `tools/rea_vanilla.py`: its drop-key loop checks `!player.isSpectator()` before calling `MultiPlayerGameMode.dropItem`. `tools/test_held_drop_parity.py` invokes the unmodified vanilla key handler up through that loop. A controlled drop callback removes from vanilla's actual `Inventory`; the Rust probe runs the production `take_held_drop` helper. All **128 selected-stack/drop-count snapshots match vanilla**. Networking, spawned entities, animation and statistics are outside this harness's scope. ## Self-check - Vanilla held-drop parity: passed (128 snapshots). - Public tree and outgoing branch history: passed. - Full client test suite: 1,031 passed. - Python tests: 251 passed. - Formatting and workspace Clippy with warnings denied: passed. - The completed self-check below supersedes the earlier run interrupted by disk exhaustion. Other affected parity harnesses remain for CI. **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at defaa7cd2, 12 min 48 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +211 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 251 passed (37 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (1 min 29 s) | | tests: horizon-client | ✅ 1031 passed (10 min 31 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 276 affected, to run in CI (--quick): ambient_sound, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo, basic_feature, biome_chunk, biome_generation and 264 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-02 16:00:49 +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#3011
No description provided.