Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add PlayerPickItemEvent

Open RodneyMKay opened this issue 4 years ago • 4 comments

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

RodneyMKay avatar May 07 '21 21:05 RodneyMKay

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.

stale[bot] avatar Aug 19 '21 12:08 stale[bot]

My apologies for the delay. I rebased the branch and addressed all aforementioned issues. Thanks for the feedback :)

RodneyMKay avatar Sep 08 '21 20:09 RodneyMKay

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.

Owen1212055 avatar Oct 22 '22 19:10 Owen1212055

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.

yannicklamprecht avatar May 10 '23 06:05 yannicklamprecht