Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InventoryAction for shift-clicking between player hotbar and player inventory #10774

Open
lexiccn opened this issue May 23, 2024 · 0 comments
Open
Labels
status: needs triage type: bug Something doesn't work as it was intended to. version: 1.20.6 Game version 1.20.6

Comments

@lexiccn
Copy link

lexiccn commented May 23, 2024

Expected behavior

  • Shift-clicking item in player inventory moves as many as it can to hotbar, rest are left in inventory
  • No InventoryAction properly matches this description

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

  • Shift-click item in player inventory (after opening with E, not in another inventory)
  • Item moves as many as it can to hotbar, rest are left in inventory
  • Listen for InventoryClickEvent
  • Log InventoryClickEvent#getAction

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.

@lexiccn lexiccn added status: needs triage type: bug Something doesn't work as it was intended to. labels May 23, 2024
@papermc-sniffer papermc-sniffer bot added the version: 1.20.6 Game version 1.20.6 label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage type: bug Something doesn't work as it was intended to. version: 1.20.6 Game version 1.20.6
Projects
Status: 🕑 Needs Triage
Development

No branches or pull requests

1 participant