Pause sorting in the storage terminal while shift is held - #207
Conversation
While the shift key is held down, ingredients keep the position they had in the storage terminal, so that quantity changes caused by shift-clicking items in or out don't move them around anymore. Ingredients that are new since sorting was paused are appended at the end. As soon as shift is released, the regular sorting is applied again. This can be disabled with the new guiStoragePauseSortingWhileShifting client config option. Closes #154 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GuGBvU7WNr6XhwVxbGdLmY
| * @param previousView A previously shown ingredients view. | ||
| * @param sorter An optional sorter that is used for ordering the new ingredients. | ||
| */ | ||
| protected void sortByPreviousOrder(List<InstanceWithMetadata<T>> ingredientsView, |
There was a problem hiding this comment.
Something seems to be going wrong when I test this out.
It looks like the crafting options can jump around when holding shift.
For example, I had a crafting option with 4 x planks, which first was shown after a 32 x stone stack, but then jumped before it, even though I was sorting by itemstack quantity.
There was a problem hiding this comment.
Good catch, that was a real bug, fixed in 43c628e.
The positions of the previously shown ingredients were keyed by ingredient only (with the quantity ignored), so a crafting option and the stored stack of that same item shared one position. As soon as the view was rebuilt while shift was held, the crafting option was given the position of the stored stack, and jumped right next to it. In your case there must have been a stored planks stack before the stone, which the planks crafting option then jumped to.
Positions are now keyed by ingredient and crafting option (via InstanceWithMetadata.createComparator, so a stored ingredient and a crafting option for the same item are distinct keys), which keeps them in place.
Generated by Claude Code
Crafting options shared their position with the stored ingredient of the same item, causing them to jump next to that stored ingredient as soon as the view was rebuilt while sorting was paused. Positions are now determined based on the ingredient and its crafting option. Furthermore, the paused sorting order is now reset from within resetFilteredIngredientsViews, and the paused state is checked from within getFilteredIngredientsView. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GuGBvU7WNr6XhwVxbGdLmY
Closes #154
What
While the shift key is held down, ingredients in the storage terminal keep the position they had, so shift-clicking stacks in or out no longer moves them around. As soon as shift is released, the regular sorting is applied again.
How
Instead of skipping the view refresh entirely (which would freeze quantities and hide newly inserted ingredients),
TerminalStorageTabIngredientComponentClientkeeps rebuilding its filtered view while sorting is paused, but orders it by the previously shown view instead of by the active sorters:The pause state is checked in
getSlots/getSlotCount(so once per render frame). When sorting resumes, all views are re-sorted and the currently selected slot is re-located via the existingupdateActiveInstancelogic.Explicit user actions that change the way ingredients are shown always apply immediately, even with shift held (e.g. when typing capitals in the search field): the sort buttons, the crafting filter button and
setInstanceFilterforget the paused order.The behaviour can be disabled with the new
guiStoragePauseSortingWhileShiftingclient config option (enabled by default).Notes
IIngredientComponentTerminalStorageHandler, which seemed out of scope for this change. Happy to add it if you'd like that behaviour too../gradlew buildpasses (the repo has no unit tests, and this MC version has no game tests). The GUI behaviour itself has not been verified in-game.Generated by Claude Code