[PR #2642] [MERGED] Pick blocks and entities on the server like vanilla #4495

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

📋 Pull Request Information

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

Base: main ← Head: fix/pick-item-server


📝 Commits (1)

  • f92cf81 Pick blocks and entities on the server like vanilla

📊 Changes

5 files changed (+179 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+13 -1)
📝 crates/horizon-client/src/game/lan_actions.rs (+56 -7)
➕ crates/horizon-client/src/game/pick_entity.rs (+98 -0)
📝 crates/horizon-client/src/game/remote.rs (+10 -1)
📝 crates/horizon-protocol/src/packets/play.rs (+2 -0)

📄 Description

What and why

Middle-click (Pick Block) on a server did the wrong thing. The server replaced the selected hotbar slot with the block's item, never looked for the item in the inventory, did nothing in survival, and dropped the Ctrl data. Middle-click on an entity was never sent at all, so a cow gave the block behind it.

Now the server follows vanilla tryPickItem: a matching stack is selected (or swapped into the hotbar from the main inventory), a creative player gets the item in a suitable hotbar slot when none matches, and the held slot is sent back. Ctrl keeps the block entity data in creative. Entities are picked too: the client sends PickItemFromEntity and the server answers with the entity's pick result (spawn egg for mobs, the item for boats, minecarts, armor stands, cushions, paintings, item frames and end crystals). The local in-frame pick does the same.

Vanilla reference

  • ServerGamePacketListenerImpl.handlePickItemFromBlock, handlePickItemFromEntity, tryPickItem
  • Minecraft.pickBlockOrEntity
  • Entity.getPickResult and its overrides (Mob, ItemFrame, Painting, ArmorStand, Cushion, AbstractBoat, the minecarts, EndCrystal)

Self-check

cargo check -p horizon-client passes.


🔄 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/2642 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/pick-item-server` --- ### 📝 Commits (1) - [`f92cf81`](https://github.com/horizon-rust/horizon/commit/f92cf816b17e8376d497c67a4d9edea9f2facb25) Pick blocks and entities on the server like vanilla ### 📊 Changes **5 files changed** (+179 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+13 -1) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+56 -7) ➕ `crates/horizon-client/src/game/pick_entity.rs` (+98 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+10 -1) 📝 `crates/horizon-protocol/src/packets/play.rs` (+2 -0) </details> ### 📄 Description ## What and why Middle-click (Pick Block) on a server did the wrong thing. The server replaced the selected hotbar slot with the block's item, never looked for the item in the inventory, did nothing in survival, and dropped the Ctrl data. Middle-click on an entity was never sent at all, so a cow gave the block behind it. Now the server follows vanilla `tryPickItem`: a matching stack is selected (or swapped into the hotbar from the main inventory), a creative player gets the item in a suitable hotbar slot when none matches, and the held slot is sent back. Ctrl keeps the block entity data in creative. Entities are picked too: the client sends `PickItemFromEntity` and the server answers with the entity's pick result (spawn egg for mobs, the item for boats, minecarts, armor stands, cushions, paintings, item frames and end crystals). The local in-frame pick does the same. ## Vanilla reference - `ServerGamePacketListenerImpl.handlePickItemFromBlock`, `handlePickItemFromEntity`, `tryPickItem` - `Minecraft.pickBlockOrEntity` - `Entity.getPickResult` and its overrides (`Mob`, `ItemFrame`, `Painting`, `ArmorStand`, `Cushion`, `AbstractBoat`, the minecarts, `EndCrystal`) ## Self-check `cargo check -p horizon-client` passes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:17:35 +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#4495
No description provided.