1.15.2 PlayerAnimationEvent, check right and left click

Discussion in 'Spigot Plugin Development' started by Xsm0deus, Jan 19, 2020.

  1. Hi, I used a playeranimationevent in a plugin awhile ago cause I wanted to add something to the left click function in adventure mode which doesn't call playerinteractevent, but since in 1.15 they animated the arm on right click, now my thing works on both left and right click. Is there a way to check if it's right click or left click on playeranimationevent?
    • Agree Agree x 1
  2. Not sure if this would work, but you could create a hashmap that contains a Boolean that is true only when a player left clicks, using the left click events. then on the animation event check that Boolean and if it’s not true, cancel the event. Then just set it to false again.
  3. Those don't work with adventure mode
  4. or just use a set, and if theyre in the set, cancel it. remove them afterwards. should almost never need a map<K, Boolean>
  6. api doesnt havge the functionality youre looking for. protocollib would. check the inbound animation/interact packet and see which interaction it is.
  7. md_5

    Administrator Developer

    The protocol doesn't have the functionality either... If it did it would be in the API
  8. idk why i didnt think of that. makes total sense lol
  9. Any ideas? I used playeranimationevent because it doesn't fire playerinteract in adventure mode.
  10. It should send the hand? https://wiki.vg/Protocol#Animation_.28serverbound.29

    To OP:
    PlayerInteractEvent is called in adventure mode if the player leftclicks air, not a block. If the player leftclicks a block no data is sent to the server while in adventure mode.
  11. md_5

    Administrator Developer

    Hand is unrelated to left/right clicking
    • Informative Informative x 1
  12. Ah yes you're right, my bad. I just looked at it briefly.
  13. Yeah and besides I am trying to left click a block in adventure mode, might have to figure out some alternative in survival mode with interact.
  14. This is still an issue, has anyone found a clean workaround? Using a Set is not stable enough for my builds, I need something direct, a way to differentiate between left-clicking and right-clicking a block in Adventure mode. I'm willing to use Protocol to set up my own event if necessary, but as far as I've read, Protocol can't even distinguish this.