Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Fix EntityShootBowEvent/ProjectileLaunchEvent consuming arrows when cancelled

Open notTamion opened this issue 2 years ago • 12 comments

closes #9919 (inventory desync doesn't seem to be an issue anymore since the arrow just gets consumed even when cancelled) closes #7702 (same here) closes #11113 closes #10665


Download the paperclip jar for this pull request: paper-9949.zip

notTamion avatar Nov 17 '23 19:11 notTamion

due to mojang moving logic around the arrow itemstack will now get removed before the event is even called. easiest way to deal with this seems to just give the player the itemstack back. This pr also still fixes to desync happening with PlayerReadyBowEvent and EntityShootBowEvent

EDIT: not sure if i should add an extra patch just to fix that itemstack removal so i will just leave it in this patch for now

notTamion avatar Apr 28 '24 16:04 notTamion

Rather certain this is not going to work out nicely regarding infinitely enchantment. Also may leave the inventory in a different state than it was in initially?

lynxplay avatar Jul 22 '24 09:07 lynxplay

We could either add some checks regarding those enchantments (not sure about the state changes though) or we do some refactoring and remove the item after the event is called. i will take a second look at moving that removal to after the event call later

notTamion avatar Jul 22 '24 12:07 notTamion

Yea I think I may be in favour of removing item post event call. How to track that nicely is going to be a fun challenge. We also need to make sure that nothing there runs that could be affected by not removing items.

Regarding removal anyway, if the diff ends up with some form of tracking wrapper around Item stack, we may also be able to remove and precisely readd.

lynxplay avatar Jul 22 '24 12:07 lynxplay

Problem: EntityShootBowEvent is called for Crossbows. Is that intended behaivour? If it is what are we supposed to do when the event is cancelled/consumeItem is set to false? just leaving the arrow in the crossbow would basically allow for rapid fire with consumeItem on false

notTamion avatar Jul 22 '24 13:07 notTamion

In 1.20.4, that field was simply ignored for crossbows. So it would always "consume".

lynxplay avatar Jul 22 '24 13:07 lynxplay

not fully fix.

Jiangyuluo avatar Aug 16 '24 09:08 Jiangyuluo

How is that?

notTamion avatar Aug 16 '24 09:08 notTamion