InventoryAction for shift-clicking between player hotbar and player inventory #10774
Labels
status: needs triage
type: bug
Something doesn't work as it was intended to.
version: 1.20.6
Game version 1.20.6
Expected behavior
HOTBAR_SWAP or HOTBAR_MOVE_AND_READD are the closest approximations but neither accurately describe this.
A different action like MOVE_TO_HOTBAR or MOVE_TO_INVENTORY would make sense here.
Observed/Actual behavior
Actual InventoryAction is MOVE_TO_OTHER_INVENTORY
Steps/models to reproduce
This also applies to any inventory which does not allow the item (e.g Chest in Brewing Stand) - it will move between inventory and hotbar, instead of into the inventory. The game does not attempt to move it into the inventory.
Plugin and Datapack List
No datapacks.
Only plugin used is a dedicated plugin to listen to InventoryClickEvent and send message to user with the Action name.
Paper version
This server is running Paper version 1.20.6-90-master@b149584 (2024-05-22T17:30:13Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT)
Other
Assuming a new action is unreasonable as it would break backwards compatibility, updating the documentation for MOVE_TO_OTHER_INVENTORY to reflect that it may actually be between hotbar and player inventory is a good compromise,
Currently the only way to tell if it will in-fact move to the other inventory, or move between hotbar and inventory, to check the action, then to know if the item is allowed in the inventory (or if the player has opened their own inventory) - which cannot easily be tested in the API so would require hardcoding valid items for inventory, which can change, or a workaround like attempting to add the item, checking if it was added, removing it again if it was, then continuing.
A new InventoryAction would mean no need for these bad workarounds as the checks are already done by the game, and are just not reflected in the event.
Assuming a new action is unreasonable, if backwards/forwards compatibility is valued more, updating the documentation for MOVE_TO_OTHER_INVENTORY to reflect that it may actually be between hotbar and player inventory is a good compromise,
Alternatively, it could make sense to add a new field to the event entirely, for example "isAllowed", which if false and MOVE_TO_OTHER_INVENTORY, is equivalent to swapping between hotbar and inventory. - This would be a good use for Event.Result.ALLOW also, if it was able to ignore the "isAllowed" check when set to this result instead of DEFAULT.
The text was updated successfully, but these errors were encountered: