Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EntityShootBowEvent/ProjectileLaunchEvent consuming arrows when cancelled #9949

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

notTamion
Copy link
Contributor

@notTamion notTamion commented Nov 17, 2023

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 notTamion requested a review from a team as a code owner November 17, 2023 19:19
@notTamion notTamion force-pushed the fix-inventory-desync branch 3 times, most recently from f69833b to 76a43b6 Compare December 9, 2023 21:27
@Warriorrrr Warriorrrr added the build-pr-jar Enables a workflow to build Paperclip jars on the pull request. label Jan 19, 2024
@notTamion notTamion force-pushed the fix-inventory-desync branch from 76a43b6 to fdb3a73 Compare February 24, 2024 18:33
@notTamion notTamion force-pushed the fix-inventory-desync branch from fdb3a73 to 3bbd3fc Compare April 28, 2024 16:25
@notTamion
Copy link
Contributor Author

notTamion commented Apr 28, 2024

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 notTamion changed the title Fix inventory desync with Arrows Fix inventory desync with Arrows and fix EntityShootBowEvent consuming Arrow when cancelled Apr 28, 2024
@notTamion notTamion force-pushed the fix-inventory-desync branch from 3bbd3fc to add3db6 Compare July 20, 2024 18:45
@notTamion notTamion changed the title Fix inventory desync with Arrows and fix EntityShootBowEvent consuming Arrow when cancelled Fix EntityShootBowEvent/ProjectileLaunchEvent consuming arrows when cancelled Jul 20, 2024
@lynxplay
Copy link
Contributor

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?

@notTamion
Copy link
Contributor Author

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

@lynxplay
Copy link
Contributor

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.

@notTamion
Copy link
Contributor Author

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

@lynxplay
Copy link
Contributor

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

@notTamion notTamion force-pushed the fix-inventory-desync branch 3 times, most recently from 0128d2b to a83b1d4 Compare July 22, 2024 18:13
@Jiangyuluo
Copy link

not fully fix.

@notTamion
Copy link
Contributor Author

How is that?

@FN-FAL113
Copy link

FN-FAL113 commented Sep 22, 2024

up, broken on 1.20.6/1.21.1

@lynxplay lynxplay force-pushed the fix-inventory-desync branch 2 times, most recently from b7697e7 to 963fbf7 Compare September 29, 2024 21:15
Copy link
Contributor

@Lulu13022002 Lulu13022002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this patch introduce a new dupe for arrow. Crossbow doesn't consume the arrow when the item is used in survival but the player can still launched the projectile.

And some diff around EntityShootBowEvent#setConsumeItem deprecation has been removed during the rebase.

@Jiangyuluo
Copy link

This issue still exists in the latest version. The build version provided by 9949 may still become invalid in some cases (which I cannot accurately explain)

@lynxplay
Copy link
Contributor

lynxplay commented Oct 2, 2024

which I cannot accurately explain

Can you try at least? Or show it via screenshots/video?
If we missed something in the latest build of the PR we'd obviously like to fix that before merging this.

@lynxplay lynxplay force-pushed the fix-inventory-desync branch from ca2cd21 to 1ec5810 Compare October 2, 2024 12:33
@lynxplay
Copy link
Contributor

lynxplay commented Oct 2, 2024

Resolved your comments lulu, now with a cuter looking entity load crossbow event impl.

Copy link
Contributor

@Lulu13022002 Lulu13022002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrows with the intangible_projectile component launched in survival with a bow are not consumed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-pr-jar Enables a workflow to build Paperclip jars on the pull request. pre-softspoon
Projects
Status: Awaiting review
8 participants