[PR #7636] Menus: a double-click collects from the side of its button #7729

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

📋 Pull Request Information

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

Base: main ← Head: fix/menu-pickup-all-order


📝 Commits (3)

  • 4ec7e2c Menus: a double-click collects from the side of its button
  • 7a22132 Test both directions of a double-click collect
  • 71c59f8 Double-click an empty slot in the pickup-all test

📊 Changes

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

View changed files

📝 crates/horizon-client/src/lan/menu.rs (+46 -3)

📄 Description

Behaviour

A double-click on a slot collects the same item out of the rest of the menu
into the cursor. The direction of that sweep follows the button: button 1 walks
the slots from the last one backwards, button 0 from the first forwards.
Horizon always walked forwards, so a collect that cannot take everything (the
cursor is near a full stack) took from the wrong end of the menu — it emptied
the first matching slot where vanilla empties the last.

Vanilla

AbstractContainerMenu.doClick, PICKUP_ALL arm (offsets 1615-1870):

if (slot.hasItem() && !slot.mayPickup(player)) return;             // 1653-1671
int i8 = button == 0 ? 0 : this.slots.size() - 1;                  // 1671-1688
int i9 = button == 0 ? 1 : -1;                                     // 1690-1699
for (int i10 = 0; i10 < 2; i10++) {                                // two passes
   for (int i11 = i8; i11 >= 0 && i11 < this.slots.size()
        && carried.getCount() < carried.getMaxStackSize(); i11 += i9) {
      Slot slot2 = this.slots.get(i11);
      if (slot2.hasItem() && canItemQuickReplace(slot2, carried, true)
          && slot2.mayPickup(player) && this.canTakeItemForPickAll(carried, slot2)) {
         ItemStack itemStack3 = slot2.getItem();
         if (i10 != 0 || itemStack3.getCount() != itemStack3.getMaxStackSize()) {
            ItemStack itemStack4 = slot2.safeTake(itemStack3.getCount(),
                carried.getMaxStackSize() - carried.getCount(), player);
            carried.grow(itemStack4.getCount());
         }
      }
   }
}

The first pass skips stacks that are already full (offset 1805-1823:
i10 != 0 || count != maxStack), the second takes the rest, and both walk in
i9's direction from i8.

The button that reaches this arm is the right one: AbstractContainerScreen.mouseReleased
only builds a PICKUP_ALL click when the released button is 1
(doubleclick && slot != null && event.button() == 1 && canTakeItemForPickAll(EMPTY, slot),
offsets 64-101) and then calls slotClicked(slot, slotIndex, event, PICKUP_ALL)
(offsets 222-230).

What Horizon got wrong

lan::menu::pickup_all never looked at the button — its signature did not even
take it — and swept 0..view.len(), so the two directions were the same sweep.

The change

pickup_all takes the button and builds its scan order from it: forwards for
button 0, backwards for button 1. A click whose button is neither is not a
menu click at all (isContainerClickButton is button == 0 || button == 1),
but click already routes those to the other modes.

Proof

lan::menu::tests::pickup_all_walks_from_the_buttons_side fills a chest's slots
0 and 1 with 5 stone each and puts 63 stone on the cursor, one short of a full
stack, so exactly one item can be collected.

Without the change, a button-1 double-click on slot 0 gives
view.get(0) == Some(5 stone) / view.get(1) == Some(4 stone) read backwards:
the slot 0 assert fails with left: Some(4), right: Some(5) and slot 1 keeps 5,
because the forward sweep took the stone out of the first slot.

With the change: slot 0 keeps 5, slot 1 drops to 4, the cursor reaches 64. A
button-0 double-click then takes from the first slot (slot 0 → 4, slot 1 → 4).

Proven: the direction of both passes against the bytecode above, and that
the two-pass order (partial stacks before full ones) is unchanged.
Not proven: not seen in the running game; Slot.mayPickup and
canTakeItemForPickAll are not modelled by this click engine (mayPickup has
no Horizon counterpart, and the inventory menu's result slot is skipped by
index instead), so a slot that refuses the collect 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/7636 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/menu-pickup-all-order` --- ### 📝 Commits (3) - [`4ec7e2c`](https://github.com/horizon-rust/horizon/commit/4ec7e2c96d1ef61cfaaf66563b63ba606102ca91) Menus: a double-click collects from the side of its button - [`7a22132`](https://github.com/horizon-rust/horizon/commit/7a221321bcf7bfd9cf981c5917b27109af5952ef) Test both directions of a double-click collect - [`71c59f8`](https://github.com/horizon-rust/horizon/commit/71c59f86c70d5fc71ddb60bfee3e10d583a44211) Double-click an empty slot in the pickup-all test ### 📊 Changes **1 file changed** (+46 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/menu.rs` (+46 -3) </details> ### 📄 Description ## Behaviour A double-click on a slot collects the same item out of the rest of the menu into the cursor. The direction of that sweep follows the button: button 1 walks the slots from the last one backwards, button 0 from the first forwards. Horizon always walked forwards, so a collect that cannot take everything (the cursor is near a full stack) took from the wrong end of the menu — it emptied the first matching slot where vanilla empties the last. ## Vanilla `AbstractContainerMenu.doClick`, PICKUP_ALL arm (offsets 1615-1870): ``` if (slot.hasItem() && !slot.mayPickup(player)) return; // 1653-1671 int i8 = button == 0 ? 0 : this.slots.size() - 1; // 1671-1688 int i9 = button == 0 ? 1 : -1; // 1690-1699 for (int i10 = 0; i10 < 2; i10++) { // two passes for (int i11 = i8; i11 >= 0 && i11 < this.slots.size() && carried.getCount() < carried.getMaxStackSize(); i11 += i9) { Slot slot2 = this.slots.get(i11); if (slot2.hasItem() && canItemQuickReplace(slot2, carried, true) && slot2.mayPickup(player) && this.canTakeItemForPickAll(carried, slot2)) { ItemStack itemStack3 = slot2.getItem(); if (i10 != 0 || itemStack3.getCount() != itemStack3.getMaxStackSize()) { ItemStack itemStack4 = slot2.safeTake(itemStack3.getCount(), carried.getMaxStackSize() - carried.getCount(), player); carried.grow(itemStack4.getCount()); } } } } ``` The first pass skips stacks that are already full (offset 1805-1823: `i10 != 0 || count != maxStack`), the second takes the rest, and both walk in `i9`'s direction from `i8`. The button that reaches this arm is the right one: `AbstractContainerScreen.mouseReleased` only builds a PICKUP_ALL click when the released button is 1 (`doubleclick && slot != null && event.button() == 1 && canTakeItemForPickAll(EMPTY, slot)`, offsets 64-101) and then calls `slotClicked(slot, slotIndex, event, PICKUP_ALL)` (offsets 222-230). ## What Horizon got wrong `lan::menu::pickup_all` never looked at the button — its signature did not even take it — and swept `0..view.len()`, so the two directions were the same sweep. ## The change `pickup_all` takes the button and builds its scan order from it: forwards for button 0, backwards for button 1. A click whose button is neither is not a menu click at all (`isContainerClickButton` is `button == 0 || button == 1`), but `click` already routes those to the other modes. ## Proof `lan::menu::tests::pickup_all_walks_from_the_buttons_side` fills a chest's slots 0 and 1 with 5 stone each and puts 63 stone on the cursor, one short of a full stack, so exactly one item can be collected. Without the change, a button-1 double-click on slot 0 gives `view.get(0) == Some(5 stone)` / `view.get(1) == Some(4 stone)` read backwards: the slot 0 assert fails with `left: Some(4), right: Some(5)` and slot 1 keeps 5, because the forward sweep took the stone out of the first slot. With the change: slot 0 keeps 5, slot 1 drops to 4, the cursor reaches 64. A button-0 double-click then takes from the first slot (slot 0 → 4, slot 1 → 4). **Proven:** the direction of both passes against the bytecode above, and that the two-pass order (partial stacks before full ones) is unchanged. **Not proven:** not seen in the running game; `Slot.mayPickup` and `canTakeItemForPickAll` are not modelled by this click engine (`mayPickup` has no Horizon counterpart, and the inventory menu's result slot is skipped by index instead), so a slot that refuses the collect 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#7729
No description provided.