[PR #4888] [MERGED] Container clicks past the menu are ignored, as in vanilla #5919

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

📋 Pull Request Information

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

Base: main ← Head: fix/container-click-slot-range


📝 Commits (2)

  • 2541cba Container clicks past the menu are ignored, as in vanilla
  • 94e2666 lan_bot: a click past a chest's menu is ignored

📊 Changes

5 files changed (+244 additions, -1 deletions)

View changed files

📝 crates/horizon-bots/src/main.rs (+52 -0)
📝 crates/horizon-client/src/lan/containers.rs (+12 -1)
📝 crates/horizon-client/src/lan/hub.rs (+13 -0)
📝 crates/horizon-client/tests/lan_bot.rs (+69 -0)
➕ tools/server_container_click_e2e.py (+98 -0)

📄 Description

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

Phase 5 of the anticheat work (vanilla's own packet checks, always on as parity): container clicks and bundle selection stay within the open menu.

  • A click past the menu is ignored (handleContainerClick → AbstractContainerMenu.isValidSlotIndex: -999, or a slot below the menu's slot count). The hub's chest menus mapped slot n past the container to the player's inventory with player_slot(n - size), which wraps past the inventory's 36 slots. So a modified client could click a chest's slot 63 and throw, clone or take the stack in inventory slot 9, from outside the menu.
  • Bundle selection the same (setSelectedBundleItemIndex: a slot of the menu only).
  • An unknown click type reads as PICKUP. ContainerInput's codec is ByIdMap.continuous(..., OutOfBoundsStrategy.ZERO). Before, the hub ignored such a click, and the game's menus treated it as PICKUP_ALL.
  • A bundle index below -1 disconnects (ServerboundSelectBundleItemPacket's constructor throws Invalid selectedItemIndex).

Test

  • horizon-bots --click X,Y,Z:SLOT:BUTTON:MODE opens a block, then clicks in its window. tools/server_container_click_e2e.py runs a dedicated server: the bot opens a chest and throws the whole stack (THROW, button 1) from slot 63.
    • On main: slot 9's stone is thrown (... threw the stone in inventory slot 9).
    • With this PR: a click past the chest menu (slot 63) is ignored: the stone in slot 9 stays.
  • lan_bot a_click_past_the_menu_is_ignored: the hub-level test fails on main's containers.rs and passes here.
  • python3 tools/parity.py dedicated_server server_entities server_player_damage: 3 passed.
  • python3 tools/lan_e2e.py --check chest --check containers --check large_chest --check shulker_menu --check clicks: all pass.
  • --check menu-transfer fails, the same way on a branch without this change. Its stale count takes the inventory screen's armour and offhand ids (500–504) for container slots (≥ 300).

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 6eac54099, 5 min 1 s)

Check Result
Scope ✅ 5 files, +244 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (40 s)
rustfmt ✅ (4 s)
clippy ✅ (55 s)
tests: horizon-bots, horizon-client ✅ 1254 passed (2 min 51 s)
doc tests ✅ 0 passed
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 33 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 21 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/4888 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/container-click-slot-range` --- ### 📝 Commits (2) - [`2541cba`](https://github.com/horizon-rust/horizon/commit/2541cba00548d53301b01810d921703628b8be2d) Container clicks past the menu are ignored, as in vanilla - [`94e2666`](https://github.com/horizon-rust/horizon/commit/94e2666542a148e0b41172e23dd08036c4a33e2e) lan_bot: a click past a chest's menu is ignored ### 📊 Changes **5 files changed** (+244 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-bots/src/main.rs` (+52 -0) 📝 `crates/horizon-client/src/lan/containers.rs` (+12 -1) 📝 `crates/horizon-client/src/lan/hub.rs` (+13 -0) 📝 `crates/horizon-client/tests/lan_bot.rs` (+69 -0) ➕ `tools/server_container_click_e2e.py` (+98 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Phase 5 of the anticheat work (vanilla's own packet checks, always on as parity): container clicks and bundle selection stay within the open menu. - **A click past the menu is ignored** (`handleContainerClick` → `AbstractContainerMenu.isValidSlotIndex`: -999, or a slot below the menu's slot count). The hub's chest menus mapped slot `n` past the container to the player's inventory with `player_slot(n - size)`, which wraps past the inventory's 36 slots. So a modified client could click a chest's slot 63 and throw, clone or take the stack in inventory slot 9, from outside the menu. - **Bundle selection the same** (`setSelectedBundleItemIndex`: a slot of the menu only). - **An unknown click type reads as PICKUP.** `ContainerInput`'s codec is `ByIdMap.continuous(..., OutOfBoundsStrategy.ZERO)`. Before, the hub ignored such a click, and the game's menus treated it as PICKUP_ALL. - **A bundle index below -1 disconnects** (`ServerboundSelectBundleItemPacket`'s constructor throws `Invalid selectedItemIndex`). ### Test - `horizon-bots --click X,Y,Z:SLOT:BUTTON:MODE` opens a block, then clicks in its window. `tools/server_container_click_e2e.py` runs a dedicated server: the bot opens a chest and throws the whole stack (THROW, button 1) from slot 63. - On main: slot 9's stone is thrown (`... threw the stone in inventory slot 9`). - With this PR: `a click past the chest menu (slot 63) is ignored: the stone in slot 9 stays`. - `lan_bot` `a_click_past_the_menu_is_ignored`: the hub-level test fails on main's `containers.rs` and passes here. - `python3 tools/parity.py dedicated_server server_entities server_player_damage`: 3 passed. - `python3 tools/lan_e2e.py --check chest --check containers --check large_chest --check shulker_menu --check clicks`: all pass. - `--check menu-transfer` fails, the same way on a branch without this change. Its `stale` count takes the inventory screen's armour and offhand ids (500–504) for container slots (≥ 300). **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 6eac54099, 5 min 1 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +244 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (40 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (55 s) | | tests: horizon-bots, horizon-client | ✅ 1254 passed (2 min 51 s) | | doc tests | ✅ 0 passed | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 33 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 21 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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 05:15:54 +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#5919
No description provided.