Fix EntityShootBowEvent/ProjectileLaunchEvent consuming arrows when cancelled
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
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
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?
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
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.
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
In 1.20.4, that field was simply ignored for crossbows. So it would always "consume".
not fully fix.
How is that?