PaperMC / Paper

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

PlayerReadyArrowEvent is fired on two different occasions #8796

Open Thatsmusic99 opened 1 year ago

Thatsmusic99 commented 1 year ago

Expected behavior

From the description of the docs, PlayerReadyArrowEvent is meant to be fired when a player is firing a bow and the server is choosing an arrow to use.

Observed/Actual behavior

Instead, the event is fired when the player starts charging their bow shot, AND when they fire their bow.

For reference: https://gyazo.com/69d88758ac6e1054c0cd4824d4d8f6d0

Steps/models to reproduce

  1. Have a plugin that listens to the event PlayerReadyArrowEvent.
  2. Charge your bow shot. Event gets fired.
  3. Shoot! Event gets fired, and so does your arrow.

Plugin and Datapack List

Plugins: ATHENA, LuckPerms, Vault

No datapacks installed.

Paper version

This server is running Paper version git-Paper-379 (MC: 1.19.3) (Implementing API version 1.19.3-R0.1-SNAPSHOT) (Git: 567ff90) You are running the latest version Previous version: git-Paper-371 (MC: 1.19.3)

Other

No response

Badbird5907 commented 1 year ago

The conversation we had on discord: https://discord.com/channels/289587909051416579/555462289851940864/1064990526736187512

Machine-Maker commented 1 year ago

I think this is "Works as Intended".

Called when a player is firing a bow and the server is choosing an arrow to use.

is the exact description of the event (and it can probably be improved), but the server does choose the arrow to use twice. It chooses once when you start using the bow, to see if it should actually start using it, and then it chooses again when you release using the bow to create the arrow entity.

I could maybe see an argument for only firing it that second occasion, but we would need to make sure the behavior of the first call could be replicated with some other event.

Thatsmusic99 commented 1 year ago

Yeah, I was taking a look at what caused that and saw it was internally used when readying and firing. Just may need clarification on the docs, I just also find it odd that two slightly unrelated scenarios fire the same event.

Machine-Maker commented 1 year ago

I think a solid fix for this is to add a boolean to the event on whether this is just a check if the player can use the bow or crossbow. I did as such in https://github.com/PaperMC/Paper/pull/9065