[PR #2413] [MERGED] Answer the server's held slot like vanilla #4292

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2413
Author: @mahirsn
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: fix/set-held-slot-echo


📝 Commits (1)

  • 766bfbc fix(client): answer the server's held slot like vanilla

📊 Changes

1 file changed (+8 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/remote.rs (+8 -3)

📄 Description

🤖 Opened by mahirsn's AI agent (Claude Code), not by mahirsn.

What and why

A server's ClientboundSetHeldSlotPacket set Horizon's selected slot and marked it as already sent (r.carried), so Horizon never answered with ServerboundSetCarriedItemPacket. Vanilla answers on the next tick. Servers that check this (anti-bot limbos send a held slot and wait for the answer) kept the player waiting until they kicked them.

Also:

  • a slot outside the hotbar (some servers send -1 first) was clamped to 0; vanilla ignores it;
  • the slot of the last server stayed selected after a new login, so Horizon sent it before the server asked anything; vanilla starts each login from slot 0.

Vanilla reference

  • ClientPacketListener.handleSetHeldSlot: only Inventory.isHotbarSlot(slot) slots, Inventory.setSelectedSlot; MultiPlayerGameMode.carriedIndex is not touched.
  • MultiPlayerGameMode.ensureHasSentCarriedItem (from tick): sends ServerboundSetCarriedItemPacket when the selected slot differs from carriedIndex.
  • ClientPacketListener.handleLogin: a new MultiPlayerGameMode (carriedIndex 0) and a new LocalPlayer (slot 0).

Checked against a vanilla 26.3 dedicated server through a packet log: the server sends set_held_slot 5 on join (saved slot). Before: no set_carried_item (0/3 joins). After: set_carried_item 5 on the next tick (3/3).

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on marc, against upstream/main at 7674ef77c, 44 s)

Check Result
Scope ✅ 1 files, +8 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (5 s)
clippy ✅ (10 s)
tests: horizon-client ✅ 1335 passed (27 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 ➖ not run (--quick): CI's parity job picks the affected harnesses
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/2413 **Author:** [@mahirsn](https://github.com/mahirsn) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/set-held-slot-echo` --- ### 📝 Commits (1) - [`766bfbc`](https://github.com/horizon-rust/horizon/commit/766bfbcdfa6d602518e0fe70657092c54f63b692) fix(client): answer the server's held slot like vanilla ### 📊 Changes **1 file changed** (+8 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/remote.rs` (+8 -3) </details> ### 📄 Description > 🤖 Opened by mahirsn's AI agent (Claude Code), not by mahirsn. ## What and why A server's `ClientboundSetHeldSlotPacket` set Horizon's selected slot **and** marked it as already sent (`r.carried`), so Horizon never answered with `ServerboundSetCarriedItemPacket`. Vanilla answers on the next tick. Servers that check this (anti-bot limbos send a held slot and wait for the answer) kept the player waiting until they kicked them. Also: - a slot outside the hotbar (some servers send `-1` first) was clamped to 0; vanilla ignores it; - the slot of the last server stayed selected after a new login, so Horizon sent it before the server asked anything; vanilla starts each login from slot 0. ## Vanilla reference - `ClientPacketListener.handleSetHeldSlot`: only `Inventory.isHotbarSlot(slot)` slots, `Inventory.setSelectedSlot`; `MultiPlayerGameMode.carriedIndex` is not touched. - `MultiPlayerGameMode.ensureHasSentCarriedItem` (from `tick`): sends `ServerboundSetCarriedItemPacket` when the selected slot differs from `carriedIndex`. - `ClientPacketListener.handleLogin`: a new `MultiPlayerGameMode` (`carriedIndex` 0) and a new `LocalPlayer` (slot 0). Checked against a vanilla 26.3 dedicated server through a packet log: the server sends `set_held_slot 5` on join (saved slot). Before: no `set_carried_item` (0/3 joins). After: `set_carried_item 5` on the next tick (3/3). ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on marc, against upstream/main at 7674ef77c, 44 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +8 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (5 s) | | clippy | ✅ (10 s) | | tests: horizon-client | ✅ 1335 passed (27 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 | ➖ not run (--quick): CI's parity job picks the affected harnesses | | 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:16:06 +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#4292
No description provided.