PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.97k stars 2.31k forks source link

Cancelling the PlayerReadyArrowEvent causes inventory desync of the arrow item stack #7702

Open aerulion opened 2 years ago

aerulion commented 2 years ago

Expected behavior

When canceling the PlayerReadyArrowEvent the arrow item stack should not be used.

Observed/Actual behavior

When the event is cancelled the item stack's amount will still decrement until the player clicks on the item / updates the inventory.

Steps/models to reproduce

  1. Cancel the PlayerReadyArrowEvent.
  2. Shoot an arrow in survival mode.

Plugin and Datapack List

Just a single test plugin doing nothing but cancelling the event.

Paper version

This server is running Paper version git-Paper-277 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 87e11bf) You are running the latest version Previous version: git-Paper-216 (MC: 1.18.1)

Other

No response

aerulion commented 2 years ago

Some more information I found out that might help: The desync does only occur when no other suitable arrow is found. When a different non-cancelled arrow is in the players inventory the event works completely as expected. The event seems the get called before starting the bow pulling animation, but cancelling the event doesn't cancel the bow pulling animation and the desync only occurs as soon as the player lets go of the mouse button / shoots the bow.

Doc94 commented 2 years ago

Well the issue is more when cancel a use item.. if you use PlayerInteractEvent for try cancel the Bow (like in Spigot) the same error happen but with a few differences... like if use event.setUseItemInHand(Event.Result.DENY); the arrow consume when load but when fire the arrow show again in inventory... the desync is more like for any item in use...

Another issue i found with PlayerReadyArrowEvent was the case... this event is only called when check inventory, but not for the OFF_HAND maybe can make a PR for this error... but about the desync in cancel use items not find a solution.