[PR #7635] Menus: a drag only starts with a quick-craft type the player may use #7728

Open
opened 2026-11-03 07:23:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7635
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/menu-clone-drag-type


📝 Commits (2)

  • e550c9d Menus: a drag only starts with a quick-craft type the player may use
  • 078bdb4 Test the drags a survival guest may not start

📊 Changes

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

View changed files

📝 crates/horizon-client/src/lan/menu.rs (+112 -1)

📄 Description

Behaviour

A quick-craft drag (click-and-drag a stack over several slots) now only starts
with a type the player may use. Type 2 is the clone drag, which vanilla allows
for players with infinite materials only, and type 3 is not a type at all. A
survival guest that sent either still had the whole held stack dropped into the
first slot the drag touched; in vanilla the drag never starts and nothing moves.

Vanilla

AbstractContainerMenu.doClick, QUICK_CRAFT arm. The click's button packs the
status in the low two bits and the type above it:

public static int getQuickcraftHeader(int i) { return i & 3; }        // status
public static int getQuickcraftType(int i)   { return (i >> 2) & 3; } // type

and offsets 75-123 of doClick:

if (this.quickcraftStatus == 0) {
   this.quickcraftType = getQuickcraftType(button);                  // 82-87
   if (isValidQuickcraftType(this.quickcraftType, player)) {         // 90-99
      this.quickcraftStatus = 1;
      this.quickcraftSlots.clear();
   } else {
      this.resetQuickCraft();                                        // 119-120
   }

isValidQuickcraftType(int, Player):

0 -> true
1 -> true
2 -> player.hasInfiniteMaterials()      // 18-26: Player.hasInfiniteMaterials
anything else -> false                  // 27

The status guard just above (offsets 28-55) lets a start through only while
quickcraftStatus is 0, so a start that arrives mid-drag falls into
resetQuickCraft() and returns instead of taking the drag over.

What Horizon got wrong

lan::menu::quick_craft's start stage was
*drag = view.guest.carried.is_some().then_some((kind, Vec::new())): any type
started a drag, and a second start replaced the type of a drag already under
way. The end stage's per-slot amount comes from the type, so a survival type-2
or type-3 drag placed max_stack items in the first slot where vanilla moves
nothing.

The change

The start stage refuses a type the player may not use (0 and 1 for anyone, 2
with infinite materials, 3 for no one) and refuses a start that arrives while a
drag is open — vanilla's resetQuickCraft() on both counts.

Proof

lan::menu::tests::a_clone_drag_needs_infinite_materials sends a whole drag
(start, two slots, end — buttons type << 2 | 0/1/2) over an empty chest.

Without the change the type-3 drag fails with

assertion `left == right` failed: type 3
  left: Some(ItemStack { item: "minecraft:stone", count: 64, damage: 0, extra: None })
 right: None

— the whole held stack is now in menu slot 0 where vanilla leaves it alone (the
type-2 iteration fails the same way).

With the change both types leave the slots empty and the cursor full, and the
two paths that must keep working do: a type-0 charitable drag over the same two
slots still splits 64 into 32 + 32 and empties the cursor, and a creative
guest's type-2 drag fills both slots with 64 while keeping its own 64.

cargo test -q -p horizon-client-lib --lib lan::menu → 6 passed;
cargo clippy -q -p horizon-client-lib --lib silent; rustfmt --edition 2024 --check clean.

Proven: the type gate and the status gate against the bytecode above, plus
the charitable and creative paths.
Not proven: not seen in the running game — a vanilla client only sends legal
drags, so this needs a modified client; Slot.mayPlace and Slot.canDragTo are
modelled only as the menu's enabled/may_place, so a slot that refuses a drag
is out of scope.


🔄 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/7635 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/menu-clone-drag-type` --- ### 📝 Commits (2) - [`e550c9d`](https://github.com/horizon-rust/horizon/commit/e550c9d85c09efc5c52417563deabf5b2fb2cbea) Menus: a drag only starts with a quick-craft type the player may use - [`078bdb4`](https://github.com/horizon-rust/horizon/commit/078bdb45f4a0349735ccecd682b4832097db9458) Test the drags a survival guest may not start ### 📊 Changes **1 file changed** (+112 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/menu.rs` (+112 -1) </details> ### 📄 Description ## Behaviour A quick-craft drag (click-and-drag a stack over several slots) now only starts with a type the player may use. Type 2 is the clone drag, which vanilla allows for players with infinite materials only, and type 3 is not a type at all. A survival guest that sent either still had the whole held stack dropped into the first slot the drag touched; in vanilla the drag never starts and nothing moves. ## Vanilla `AbstractContainerMenu.doClick`, QUICK_CRAFT arm. The click's button packs the status in the low two bits and the type above it: ``` public static int getQuickcraftHeader(int i) { return i & 3; } // status public static int getQuickcraftType(int i) { return (i >> 2) & 3; } // type ``` and offsets 75-123 of `doClick`: ``` if (this.quickcraftStatus == 0) { this.quickcraftType = getQuickcraftType(button); // 82-87 if (isValidQuickcraftType(this.quickcraftType, player)) { // 90-99 this.quickcraftStatus = 1; this.quickcraftSlots.clear(); } else { this.resetQuickCraft(); // 119-120 } ``` `isValidQuickcraftType(int, Player)`: ``` 0 -> true 1 -> true 2 -> player.hasInfiniteMaterials() // 18-26: Player.hasInfiniteMaterials anything else -> false // 27 ``` The status guard just above (offsets 28-55) lets a start through only while `quickcraftStatus` is 0, so a start that arrives mid-drag falls into `resetQuickCraft()` and returns instead of taking the drag over. ## What Horizon got wrong `lan::menu::quick_craft`'s start stage was `*drag = view.guest.carried.is_some().then_some((kind, Vec::new()))`: any type started a drag, and a second start replaced the type of a drag already under way. The end stage's per-slot amount comes from the type, so a survival type-2 or type-3 drag placed `max_stack` items in the first slot where vanilla moves nothing. ## The change The start stage refuses a type the player may not use (0 and 1 for anyone, 2 with infinite materials, 3 for no one) and refuses a start that arrives while a drag is open — vanilla's `resetQuickCraft()` on both counts. ## Proof `lan::menu::tests::a_clone_drag_needs_infinite_materials` sends a whole drag (start, two slots, end — buttons `type << 2 | 0/1/2`) over an empty chest. Without the change the type-3 drag fails with ``` assertion `left == right` failed: type 3 left: Some(ItemStack { item: "minecraft:stone", count: 64, damage: 0, extra: None }) right: None ``` — the whole held stack is now in menu slot 0 where vanilla leaves it alone (the type-2 iteration fails the same way). With the change both types leave the slots empty and the cursor full, and the two paths that must keep working do: a type-0 charitable drag over the same two slots still splits 64 into 32 + 32 and empties the cursor, and a creative guest's type-2 drag fills both slots with 64 while keeping its own 64. `cargo test -q -p horizon-client-lib --lib lan::menu` → 6 passed; `cargo clippy -q -p horizon-client-lib --lib` silent; `rustfmt --edition 2024 --check` clean. **Proven:** the type gate and the status gate against the bytecode above, plus the charitable and creative paths. **Not proven:** not seen in the running game — a vanilla client only sends legal drags, so this needs a modified client; `Slot.mayPlace` and `Slot.canDragTo` are modelled only as the menu's `enabled`/`may_place`, so a slot that refuses a drag is out of scope. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7728
No description provided.