-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add PlayerUseBowWithoutProjectileEvent #11774
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
Add PlayerUseBowWithoutProjectileEvent #11774
Conversation
paper-api/src/main/java/io/papermc/paper/event/player/PlayerUseBowWithoutProjectileEvent.java
Outdated
Show resolved
Hide resolved
| return item.clone(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this event is only specific to bows, I think that this should be getBowItem() or something more specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tries to draw a bow or load a crossbow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be able to find a better name I guess, but certainly not related to bows xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant bows, which applies to both crossbows/bow. But not sure, maybe leave as is then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess something like weapon item?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cant you use anything as "bow" now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just getWeapon()?
|
Maybe ProjectileWeaponItem, because thats the superclass of both bow and crossbow, although that's a really long name. PlayerMissingProjectileItem? (And isn't PlayerReadyArrowEvent confusing then, because its fired for crossbows and firework rockets aswell?) |
… adjust javadocs, fix using old parameter name when calling event in Player#getProjectile
|
Using this event to set an arrow fails when the player looks at a block instead of air (it still gets called). Edit: And the bow does not animate the pulling back of the string when holding a shield in the offhand but the arrow still gets fired. |
I'm toying around with the same idea, and what I've noticed is that, if you hold the bow on the off hand, the bow does pull back. If you listen to However, for some reason, cancelling the off hand event sadly does not make the main hand bow work... Cancelling the off hand does make the off hand bow not work tho. |
|
Another thing that I have found out: If you slap a @Override
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
if (packet.getHand() != InteractionHand.MAIN_HAND)
return;the bow DOES get pulled when using the main hand, so theorically it is possible to fix the issue. |
|
After debugging, I found out that the issue lies within the (not saying that it SHOULD be removed, but I wonder what's the |
|
For the sake of avoiding other server owners and developers banging their wall against the head trying to figure out how to do this: I wanted to create a plugin that uses the bow behavior to with a custom bow that does not require arrows (context: created a cue stick model for a bow, and I created a custom plugin to play billiards (more bow force = more ball velocity) without needing any weird hacks like spawning fake arrows in their inventory) To do this, I needed to create this patch (similar to this PR's patch but calls before any of the other arrow related events) Changing the server to say that "hey there's an arrow for your bow!" DOES work if you are aiming at the sky, but does NOT work if you are looking at a block, because the client knows that there isn't an arrow in the inventory, so it thinks "okay let's use Use Item On Block instead of Use Item!", and while that SHOULD also work fine, the server cancels the bow use event when interacting with the off hand, due to a To """fix""" that in my plugin, I listen to the interact event and just change the player's active item if they are interacting with their off-hand while holding the cue stick. Not a great solution, but it does work pretty well. |
… adjust javadocs, fix using old parameter name when calling event in Player#getProjectile
…leEvent' into feat/PlayerUseBowWithoutProjectileEvent
|
Thoughts on expanding the scope of this event? |
I would go with PlayerSelectProjectileForWeaponEvent or something along that way, but other than that, I also vote for calling this event generally when selecting a projectile regardless of whether you have any valid projectiles in your inventory or not... |
# Conflicts: # paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch
|
@SoSeDiK Does your implementation suffer from the same bug as mine?
(Setting an arrow when the player has none.)
|
# Conflicts: # paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch
Yea, sadly have to use interact event workarounds on plugin's side, basically same solution as yours |
|
Nearly a year huh. I think this PR reached the point in time where it has been feature creeped to death with the unfortunate realization that messing with player state like this in such a place does not work out well.
breaks the main reason this PR is being proposed in my head (given people want to use this to supply projectiles when none are present). Thank you for everyone involved, I hope my decision is understandable. |
#11669
(Still dont have a better name for the event)