[PR #7847] Menus: one quick move spreads a stack like vanilla's repeated quickMoveStack #7861

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

📋 Pull Request Information

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

Base: main ← Head: test/menu-quick-move-repeat


📝 Commits (2)

  • 74a52b9 Test that one quick move spreads a stack like vanilla's repeat
  • 84eb77f Ledger: AbstractContainerMenu.doClick

📊 Changes

2 files changed (+68 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/lan/menu.rs (+67 -0)
📝 tools/port_map/game2-007.tsv (+1 -0)

📄 Description

What this checks

AbstractContainerMenu.doClick does not call quickMoveStack once for a
shift-click; it repeats the call while the clicked slot still holds the item it
just moved:

ItemStack moved = this.quickMoveStack(player, slotIndex);                 // 694-701
while (!moved.isEmpty() && ItemStack.isSameItem(slot.getItem(), moved)) { // 703-721
   moved = this.quickMoveStack(player, slotIndex);                        // 724-731
}

The reason is moveItemStackTo itself: its merge pass fills every matching
stack, but its empty-slot pass places into one empty slot and breaks, so a
stack that needs more room than one slot takes one call per slot.

Horizon has two quick-move engines. menu.rs::Menu::click already repeats the
call exactly as above. lan/menu.rs::click (the guest's container menus) calls
quick_move once — and its move_to fills every empty slot of the range in
one pass, so the single call reaches the same end state as vanilla's loop, for a
full inventory too (both move nothing). This PR pins that equivalence; it
changes no behaviour.

Proof

lan::menu::tests::one_quick_move_spreads_a_stack_like_vanillas_repeat drives
lan::menu::click (what lan::containers::Hub::container_click calls) with a
Rules whose snowball stack size is 16:

  • 40 snowballs in a chest slot: 16 in menu slot 36, 16 in 35, 8 in 34, chest
    slot empty — the same spread vanilla's moveItemStackTo reaches over three
    calls (its reverse order fills the hotbar's end first).
  • Only two slots of room: 8 snowballs stay in the chest, which is where
    vanilla's loop stops (its third call moves nothing and returns EMPTY).
  • A full inventory: the slot keeps its 5 snowballs and the click reports no
    changed slots.

The test fails if move_to is changed to vanilla's one-slot-per-call rule
without adding the loop: with break after the first placement, the first case
panics on assert!(view.get(0).is_none()), the chest still holding 24 of the 40
snowballs and the hotbar only 16. That is the divergence this pins.

cargo test -q -p horizon-client-lib --lib lan::menu → 7 passed (and 1479
tests in the crate). cargo clippy -q -p horizon-client-lib --lib --all-targets
silent, cargo fmt -p horizon-client-lib -- --check clean.
tools/port_ledger.py map-check tools/port_map/game2-007.tsv → 148 rows, no
problems.

The row

AbstractContainerMenu.doClick had no ledger row; the automatic map credited it
to Game::click_filtered, which is a call-graph guess. The row now names
menu.rs::Menu::click, where the dispatch and the repeat live, and says that
the guest copy does it in one pass.

Not proven

Not seen in the running game. The equivalence depends on move_to remaining
exhaustive over empty slots, which is why the comment and the test are in the
same commit; the local engine's loop is unchanged and untested here (its
move_to is a different function that also fills a single empty slot per call).


🔄 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/7847 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `test/menu-quick-move-repeat` --- ### 📝 Commits (2) - [`74a52b9`](https://github.com/horizon-rust/horizon/commit/74a52b916de20e516e245d90079944dd242df4d9) Test that one quick move spreads a stack like vanilla's repeat - [`84eb77f`](https://github.com/horizon-rust/horizon/commit/84eb77ff5ff31cff87075ba5f7ee7625d957f104) Ledger: AbstractContainerMenu.doClick ### 📊 Changes **2 files changed** (+68 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/menu.rs` (+67 -0) 📝 `tools/port_map/game2-007.tsv` (+1 -0) </details> ### 📄 Description ## What this checks `AbstractContainerMenu.doClick` does not call `quickMoveStack` once for a shift-click; it repeats the call while the clicked slot still holds the item it just moved: ``` ItemStack moved = this.quickMoveStack(player, slotIndex); // 694-701 while (!moved.isEmpty() && ItemStack.isSameItem(slot.getItem(), moved)) { // 703-721 moved = this.quickMoveStack(player, slotIndex); // 724-731 } ``` The reason is `moveItemStackTo` itself: its merge pass fills every matching stack, but its empty-slot pass places into **one** empty slot and `break`s, so a stack that needs more room than one slot takes one call per slot. Horizon has two quick-move engines. `menu.rs::Menu::click` already repeats the call exactly as above. `lan/menu.rs::click` (the guest's container menus) calls `quick_move` once — and its `move_to` fills **every** empty slot of the range in one pass, so the single call reaches the same end state as vanilla's loop, for a full inventory too (both move nothing). This PR pins that equivalence; it changes no behaviour. ## Proof `lan::menu::tests::one_quick_move_spreads_a_stack_like_vanillas_repeat` drives `lan::menu::click` (what `lan::containers::Hub::container_click` calls) with a `Rules` whose snowball stack size is 16: - 40 snowballs in a chest slot: 16 in menu slot 36, 16 in 35, 8 in 34, chest slot empty — the same spread vanilla's `moveItemStackTo` reaches over three calls (its reverse order fills the hotbar's end first). - Only two slots of room: 8 snowballs stay in the chest, which is where vanilla's loop stops (its third call moves nothing and returns `EMPTY`). - A full inventory: the slot keeps its 5 snowballs and the click reports no changed slots. The test fails if `move_to` is changed to vanilla's one-slot-per-call rule without adding the loop: with `break` after the first placement, the first case panics on `assert!(view.get(0).is_none())`, the chest still holding 24 of the 40 snowballs and the hotbar only 16. That is the divergence this pins. `cargo test -q -p horizon-client-lib --lib lan::menu` → 7 passed (and 1479 tests in the crate). `cargo clippy -q -p horizon-client-lib --lib --all-targets` silent, `cargo fmt -p horizon-client-lib -- --check` clean. `tools/port_ledger.py map-check tools/port_map/game2-007.tsv` → 148 rows, no problems. ## The row `AbstractContainerMenu.doClick` had no ledger row; the automatic map credited it to `Game::click_filtered`, which is a call-graph guess. The row now names `menu.rs::Menu::click`, where the dispatch and the repeat live, and says that the guest copy does it in one pass. ## Not proven Not seen in the running game. The equivalence depends on `move_to` remaining exhaustive over empty slots, which is why the comment and the test are in the same commit; the local engine's loop is unchanged and untested here (its `move_to` is a different function that also fills a single empty slot per call). --- <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#7861
No description provided.