PaperMC / PaperMC/Paper

InventoryAction for shift-clicking between player hotbar and player inventory

Open
#10,774 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: needs triage type: bug version: 1.20.6
Dominant language
Java
Stars
12.7k
Forks
3.5k
Avg merge
3d 13h
Merged PRs (30d)
11

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the InventoryAction and InventoryClickEvent API entry points, then reproduce the shift-click cases described in the issue and inspect InventoryClickEvent#getAction. Done means the API accurately distinguishes the movement, or its MOVE_TO_OTHER_INVENTORY documentation explicitly covers these cases, with the compatibility impact resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.