Paper
Paper copied to clipboard
Add PlayerPickItemEvent
This pull request adds an event for players middle clicking a block to get an item out of their inventory. It allows for cancellation, changing the hotbar slot that is being replaced and the slot that the item is coming from.
I also made a small plugin for testing the event. (info on how to use it in a comment in the source code) [UPDATED] Source Code: https://gist.github.com/RodneyMKay/6580f7d7c55bca9aa432ef99d3d5f6cc Jar: https://www.dropbox.com/s/qcyf2ci5ejufqsq/PlayerPickItemEventTest-1.0-SNAPSHOT.jar?dl=0
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
My apologies for the delay. I rebased the branch and addressed all aforementioned issues. Thanks for the feedback :)
I have updated the documentation a bit to include that this event is not fired in creative mode. However, after testing, it seems to work just fine.
I have updated the documentation a bit to include that this event is not fired in creative mode. However, after testing, it seems to work just fine.
Yeah, Creative:
- if block is present in your hotbar, switches to the block
- if it is not, it will send the creative add inventory item packet that is sent with the saved hotbars as well. -> there was another event for it, probably InventoryCreativeEvent
- on entities it triggers getting the respective spawn egg.
Should the sneak state at the time of click be part of the event? As sneaking will change the behaviour in creative. -> not pick by type instead copy block entity data as well.
Survival:
- if block is present in inf -> see creative present logic -> if no block -> likely nothing is triggered
How is it with spectator mode?
- should this event be triggered when middle clicking on entities? Action here would be spectating an entity.