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. LukeEff

    LukeEff Previously Thatgangster

    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>
     
  5.  
  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.