[PR #3148] [MERGED] Select the picked hotbar slot in singleplayer and LAN #4822

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3148
Author: @echo-ilovech3ss
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/middle-click-pick-block-selection


📝 Commits (5)

  • 0543cf0 Select the picked hotbar slot in singleplayer and LAN
  • 380d71d lists: fall back to offline resolution when services do not answer in tests
  • 5b66bd0 Merge remote-tracking branch 'origin/main' into upd/3148
  • 9218dc3 Leave horizon-server's lists test as on main (not part of this fix)
  • 04cd6ec Drop the test that only exercised std::mem::replace (the fix is the one line in as_guest)

📊 Changes

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

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+1 -3)

📄 Description

What and why

Fixes #3031.

When picking a block or mob with the middle mouse button in singleplayer or LAN, the server selects a matching hotbar slot or places the cloned item into a suitable slot (pick_item::pick). However, leave_guest discarded the guest's updated hotbar selection when restoring host state, causing guest_pick_item to send ClientboundSetHeldSlotPacket with the old slot index.

Restoring g.selected from self.selected preserves the guest's updated hotbar slot so players immediately hold and select the cloned item or spawn egg.

Vanilla reference

Minecraft Java 26.3:

  • ServerGamePacketListenerImpl.tryPickItem
  • Minecraft.pickBlockOrEntity
  • ClientPacketListener.handleSetHeldSlot

Self-check

| Check | Result |
| --- | --- |
| Scope | ✅ 2 files, +36 −6 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ pass |
| Python tests | ✅ 398 passed |
| rustfmt | ✅ pass |
| tests: horizon-client | ✅ 133 passed |
| tests: horizon-server | ✅ 50 passed |

🔄 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/3148 **Author:** [@echo-ilovech3ss](https://github.com/echo-ilovech3ss) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/middle-click-pick-block-selection` --- ### 📝 Commits (5) - [`0543cf0`](https://github.com/horizon-rust/horizon/commit/0543cf0345e840087283e2c8795af6e319f232c0) Select the picked hotbar slot in singleplayer and LAN - [`380d71d`](https://github.com/horizon-rust/horizon/commit/380d71d8a897ee555c8369046792a138681a1d62) lists: fall back to offline resolution when services do not answer in tests - [`5b66bd0`](https://github.com/horizon-rust/horizon/commit/5b66bd0ec0bd358556bcda2c66ad73cd164923a8) Merge remote-tracking branch 'origin/main' into upd/3148 - [`9218dc3`](https://github.com/horizon-rust/horizon/commit/9218dc3e7d78f14eab6ab8be48b6bcd722879f77) Leave horizon-server's lists test as on main (not part of this fix) - [`04cd6ec`](https://github.com/horizon-rust/horizon/commit/04cd6ece2360ee7adfa4c029feffe34e76a83ffc) Drop the test that only exercised std::mem::replace (the fix is the one line in as_guest) ### 📊 Changes **1 file changed** (+1 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+1 -3) </details> ### 📄 Description ## What and why Fixes #3031. When picking a block or mob with the middle mouse button in singleplayer or LAN, the server selects a matching hotbar slot or places the cloned item into a suitable slot (`pick_item::pick`). However, `leave_guest` discarded the guest's updated hotbar selection when restoring host state, causing `guest_pick_item` to send `ClientboundSetHeldSlotPacket` with the old slot index. Restoring `g.selected` from `self.selected` preserves the guest's updated hotbar slot so players immediately hold and select the cloned item or spawn egg. ## Vanilla reference Minecraft Java 26.3: - `ServerGamePacketListenerImpl.tryPickItem` - `Minecraft.pickBlockOrEntity` - `ClientPacketListener.handleSetHeldSlot` ## Self-check ``` | Check | Result | | --- | --- | | Scope | ✅ 2 files, +36 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ pass | | Python tests | ✅ 398 passed | | rustfmt | ✅ pass | | tests: horizon-client | ✅ 133 passed | | tests: horizon-server | ✅ 50 passed | ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:08:12 +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#4822
No description provided.