[PR #397] [MERGED] Sort buttons for the inventory and chests (extra, off by default) #2534

Closed
opened 2026-11-02 15:56:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/inventory-sort


📝 Commits (2)

  • 05a1e10 Mouse Tweaks-style inventory controls, an extra off by default
  • 3761f2a Sort buttons for the inventory and chests, an extra off by default

📊 Changes

14 files changed (+939 additions, -40 deletions)

View changed files

📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+4 -0)
📝 crates/horizon-client/src/creative.rs (+10 -0)
📝 crates/horizon-client/src/extras.rs (+80 -3)
📝 crates/horizon-client/src/game.rs (+22 -1)
📝 crates/horizon-client/src/game/agent.rs (+92 -14)
📝 crates/horizon-client/src/game/remote.rs (+23 -4)
📝 crates/horizon-client/src/game/stations.rs (+1 -1)
➕ crates/horizon-client/src/game/tweaks.rs (+416 -0)
➕ crates/horizon-client/src/inv_sort.rs (+239 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/menu.rs (+3 -2)
📝 crates/horizon-client/src/options_horizon.rs (+10 -11)
📝 crates/horizon-client/src/options_ui.rs (+1 -3)
📝 docs/extras.md (+37 -1)

📄 Description

Sorting for the inventory and chest-like containers, an extra that is off by default (Extras → Inventory → "Sort buttons", plus an optional "Sort key"). Part of #332.

What it does

  • A small button right of the container's title (chests, barrels, ender chests, shulker boxes) sorts the container; one right of the "Inventory" line sorts the main inventory (the hotbar stays as it is). The key, once bound on the Extras page, sorts the part under the cursor (the container when the cursor is over no slot).
  • Order: partial stacks of one item merge, then creative tab order (the search tab's list), then name; full stacks before the partial one; empty slots last. It needs an empty hand.
  • It is done with ordinary left clicks planned by inv_sort::plan, so a vanilla server accepts it.

The Extras page binds any extra key the way it bound the zoom key (Item::key_name, Extras::set_key).

How tested

  • inv_sort unit tests: a mixed inventory sorts and merges as expected, and a sorted one plans no clicks. The planned clicks are replayed as left PICKUPs through the menu engine (the one checked against the server jar) on 40 random chests: hand empty at the end, item totals unchanged, result in order.
  • In game (offscreen, survival):
    • inventory: sword, dirt 10, stone 30, dirt 20, stone 64, pearl 5, pearl 14 → stone 64, stone 30, dirt 30, pearl 16, pearl 3, sword
    • chest: dirt 5, stone 7, dirt 9, oak log 3, stone 60 → oak log 3, stone 64, stone 3, dirt 14
    • the key with the cursor over the inventory sorts only the inventory
  • Screenshots: the buttons line up with the "Chest" and "Inventory" labels and stay clear of the survival screen's recipe book button.

With the extra off no button is drawn, and sort_press and sort_key_press return false before anything else runs.

Self-check:

cargo fmt --all --check                                   ok
cargo clippy --workspace --all-targets -- -D warnings     ok
cargo test -p horizon-client                              ok (689 + 44 + 15 + 2 + 2 + 2 on the integration commit)
tools/parity.py --changed origin/main                     80 passed, 0 failed (56 min), one run over an integration commit of all the inventory PRs (this one included)

Stacked on #396. Part of #332.

🤖 Generated with Claude Code


🔄 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/397 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/inventory-sort` --- ### 📝 Commits (2) - [`05a1e10`](https://github.com/horizon-rust/horizon/commit/05a1e10bbe1ed86488b43add6e4ccf3b809673f2) Mouse Tweaks-style inventory controls, an extra off by default - [`3761f2a`](https://github.com/horizon-rust/horizon/commit/3761f2a5fbd51c846e135239a043198486d37694) Sort buttons for the inventory and chests, an extra off by default ### 📊 Changes **14 files changed** (+939 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+4 -0) 📝 `crates/horizon-client/src/creative.rs` (+10 -0) 📝 `crates/horizon-client/src/extras.rs` (+80 -3) 📝 `crates/horizon-client/src/game.rs` (+22 -1) 📝 `crates/horizon-client/src/game/agent.rs` (+92 -14) 📝 `crates/horizon-client/src/game/remote.rs` (+23 -4) 📝 `crates/horizon-client/src/game/stations.rs` (+1 -1) ➕ `crates/horizon-client/src/game/tweaks.rs` (+416 -0) ➕ `crates/horizon-client/src/inv_sort.rs` (+239 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/menu.rs` (+3 -2) 📝 `crates/horizon-client/src/options_horizon.rs` (+10 -11) 📝 `crates/horizon-client/src/options_ui.rs` (+1 -3) 📝 `docs/extras.md` (+37 -1) </details> ### 📄 Description Sorting for the inventory and chest-like containers, an extra that is **off by default** (Extras → Inventory → "Sort buttons", plus an optional "Sort key"). Part of #332. ## What it does - A small button right of the container's title (chests, barrels, ender chests, shulker boxes) sorts the container; one right of the "Inventory" line sorts the main inventory (the hotbar stays as it is). The key, once bound on the Extras page, sorts the part under the cursor (the container when the cursor is over no slot). - Order: partial stacks of one item merge, then creative tab order (the search tab's list), then name; full stacks before the partial one; empty slots last. It needs an empty hand. - It is done with ordinary left clicks planned by `inv_sort::plan`, so a vanilla server accepts it. The Extras page binds any extra key the way it bound the zoom key (`Item::key_name`, `Extras::set_key`). ## How tested - `inv_sort` unit tests: a mixed inventory sorts and merges as expected, and a sorted one plans no clicks. **The planned clicks are replayed as left `PICKUP`s through the menu engine** (the one checked against the server jar) on 40 random chests: hand empty at the end, item totals unchanged, result in order. - In game (offscreen, survival): - inventory: sword, dirt 10, stone 30, dirt 20, stone 64, pearl 5, pearl 14 → stone 64, stone 30, dirt 30, pearl 16, pearl 3, sword - chest: dirt 5, stone 7, dirt 9, oak log 3, stone 60 → oak log 3, stone 64, stone 3, dirt 14 - the key with the cursor over the inventory sorts only the inventory - Screenshots: the buttons line up with the "Chest" and "Inventory" labels and stay clear of the survival screen's recipe book button. With the extra off no button is drawn, and `sort_press` and `sort_key_press` return false before anything else runs. Self-check: ``` cargo fmt --all --check ok cargo clippy --workspace --all-targets -- -D warnings ok cargo test -p horizon-client ok (689 + 44 + 15 + 2 + 2 + 2 on the integration commit) tools/parity.py --changed origin/main 80 passed, 0 failed (56 min), one run over an integration commit of all the inventory PRs (this one included) ``` Stacked on #396. Part of #332. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:56:59 +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#2534
No description provided.