[PR #4852] [MERGED] Creative-slot packets follow vanilla's rules on the server #5893

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

📋 Pull Request Information

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

Base: main ← Head: fix/creative-slot-validation


📝 Commits (1)

  • 9f4f39a Creative-slot packets follow vanilla's rules on the server

📊 Changes

4 files changed (+175 additions, -9 deletions)

View changed files

📝 crates/horizon-bots/src/main.rs (+25 -0)
📝 crates/horizon-client/src/game/commands/items.rs (+1 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+26 -8)
➕ tools/server_creative_slot_e2e.py (+123 -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): ServerboundSetCreativeModeSlotPacket now follows ServerGamePacketListenerImpl.handleSetCreativeModeSlot and its codec.

  • Slots 1 to 45 only (validSlot). The server took slot 0 too, the crafting result.
  • No stack bigger than its own stack size (validData: count <= getMaxStackSize(), so the max_stack_size component counts). The set path didn't check this, so a modified client could put 2 swords or 64 ender pearls in a slot. The drop path (slot < 0) checked only the base item's stack size; it now uses the same rule.
  • A count over 99 disconnects. The packet's codec (ItemStack.validatedStreamCodec) encodes the stack with ItemStack.CODEC, whose count is 1 to 99, so vanilla fails the packet and disconnects the player. The console logs <name> sent an invalid creative stack: ....

validateStrict (damageable and stackable at once, the sizes of contained items) isn't on this path in vanilla (only ItemInput, applyComponentsAndValidate and ItemStackTemplate.validate call it), so it isn't added here.

Test

horizon-bots --give SLOT:ID:COUNT,... sends creative-slot packets once joined. tools/server_creative_slot_e2e.py runs a creative dedicated server:

  • stone ×64 into 36 and ×1 into 45 (offhand): kept;
  • a diamond sword ×2 into 37 and ender pearls ×17 into 38: ignored;
  • stone into 0 and into 46: ignored;
  • stone ×100: disconnected with the reason, and the console says why.
slots 1..45 within the stack size are kept; slot 0, slot 46 and oversized stacks are ignored
a stack of 100 disconnects: disconnected: )Invalid packet: count 100 is not in 1..99

On main the same run fails: the inventory is {0: stone ×64, 1: diamond_sword ×2, 2: ender_pearl ×17}.

python3 tools/parity.py dedicated_server server_entities server_player_damage: 3 passed. lunge_motion fails on main too (known).

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 3bfec3857, 5 min 22 s)

Check Result
Scope ✅ 4 files, +175 −9
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (46 s)
rustfmt ✅ (5 s)
clippy ✅ (56 s)
tests: horizon-bots, horizon-client ✅ 1230 passed (3 min 20 s)
doc tests ✅ 0 passed (1 s)
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/4852 **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/creative-slot-validation` --- ### 📝 Commits (1) - [`9f4f39a`](https://github.com/horizon-rust/horizon/commit/9f4f39addc8f3958a7c32240cb9020b6e074f77a) Creative-slot packets follow vanilla's rules on the server ### 📊 Changes **4 files changed** (+175 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-bots/src/main.rs` (+25 -0) 📝 `crates/horizon-client/src/game/commands/items.rs` (+1 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+26 -8) ➕ `tools/server_creative_slot_e2e.py` (+123 -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): `ServerboundSetCreativeModeSlotPacket` now follows `ServerGamePacketListenerImpl.handleSetCreativeModeSlot` and its codec. - **Slots 1 to 45 only** (`validSlot`). The server took slot 0 too, the crafting result. - **No stack bigger than its own stack size** (`validData`: `count <= getMaxStackSize()`, so the `max_stack_size` component counts). The set path didn't check this, so a modified client could put 2 swords or 64 ender pearls in a slot. The drop path (slot < 0) checked only the base item's stack size; it now uses the same rule. - **A count over 99 disconnects.** The packet's codec (`ItemStack.validatedStreamCodec`) encodes the stack with `ItemStack.CODEC`, whose count is 1 to 99, so vanilla fails the packet and disconnects the player. The console logs `<name> sent an invalid creative stack: ...`. `validateStrict` (damageable and stackable at once, the sizes of contained items) isn't on this path in vanilla (only `ItemInput`, `applyComponentsAndValidate` and `ItemStackTemplate.validate` call it), so it isn't added here. ### Test `horizon-bots --give SLOT:ID:COUNT,...` sends creative-slot packets once joined. `tools/server_creative_slot_e2e.py` runs a creative dedicated server: - stone ×64 into 36 and ×1 into 45 (offhand): kept; - a diamond sword ×2 into 37 and ender pearls ×17 into 38: ignored; - stone into 0 and into 46: ignored; - stone ×100: disconnected with the reason, and the console says why. ``` slots 1..45 within the stack size are kept; slot 0, slot 46 and oversized stacks are ignored a stack of 100 disconnects: disconnected: )Invalid packet: count 100 is not in 1..99 ``` On main the same run fails: `the inventory is {0: stone ×64, 1: diamond_sword ×2, 2: ender_pearl ×17}`. `python3 tools/parity.py dedicated_server server_entities server_player_damage`: 3 passed. `lunge_motion` fails on main too (known). **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 3bfec3857, 5 min 22 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +175 −9 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (46 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (56 s) | | tests: horizon-bots, horizon-client | ✅ 1230 passed (3 min 20 s) | | doc tests | ✅ 0 passed (1 s) | | 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:44 +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#5893
No description provided.