1.16.5 PlayerInteractEvent with empty hand

Discussion in 'Spigot Plugin Development' started by cricri_21, Jun 12, 2021.

  1. I guess the anwser is "not possible" but I ask in case there is a magic way :

    Is there an event that detect a right click (on air or on block) but without any item in the hand ?

    PlayerInteractEvent is almost perfect because I want to call it many times when the right click if kept pressed, but the player must hold something in main or secondary hand. In more details, I want to add a small value to the current velocity when the player keeps right click pressed while gliding, to simulate acceleration. It works perfectly if the player holds something with PlayerInteractEvent but not called at all without it.
     
    #1 cricri_21, Jun 12, 2021
    Last edited: Jun 12, 2021
  2. Simply check if the item is holding is null, then do your things ^^
     
  3. The event does not fire at all if I right click air without any item held. I tried to use a packet listener with ProtocolLib and listen to client side packet USE_ITEM but, as @LMBishop said, there is no packet for this when the hand is empty. :/
     
  4. Hey, if you want a hacky way, you could spawn a hidden armor stand a front of the player and check if he's right click it.
     
    • Agree Agree x 2
  5. Ahah yes it would work ! Thanks for the idea, but I'm afraid it's too laggy if many players, since I have to detect this with a PlayerMoveEvent.
    I'll try it anyway, thank you !