Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6421

PlayerInteractEvent gets called for RIGHT_CLICK_AIR and LEFT_CLICK_AIR when throwing snowballs or enderpearls

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • None
    • None
    • 3042-Spigot-a25e8ed-3512408 (MC: 1.16.5)
    • Yes

      When throwing a snowball or an enderpearl by right-clicking air, the event is fired both for Action RIGHT_CLICK_AIR and LEFT_CLICK_AIR.

      I don't know if that's intended, it's at least confusing as obviously no left click is involved.

      This also happens in CraftBukkit version 3042-Bukkit-3512408.

      How to reproduce (.jar included as attachment):

      package de.jeff_media.jira.spigot6421;
      
      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.player.PlayerInteractEvent;
      import org.bukkit.inventory.EquipmentSlot;
      import org.bukkit.plugin.java.JavaPlugin;
      
      public class Main extends JavaPlugin implements Listener {
      
          @Override
          public void onEnable() {
              getServer().getPluginManager().registerEvents(this,this);
          }
      
          @EventHandler
          public void onInteract(PlayerInteractEvent event) {
              if(event.getHand() == EquipmentSlot.HAND) {
                  event.getPlayer().sendMessage(event.getAction().name());
              }
          }
      }
      

      Then throw a snowball in the air. It will print both RIGHT_CLICK_AIR and LEFT_CLICK_AIR. With "normal" items, it only prints RIGHT_CLICK_AIR as expected.

            Unassigned Unassigned
            mfnalex mfnalex
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: