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

ProjectileHitEvent fires twice for Fireballs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Debian GNU/Linux 11 (bullseye) x86_64 5.10.0-23-amd64 

      Intel i5-6600K (4) @ 3.900GHz

    • This server is running CraftBukkit version 4300-Spigot-a759b62-7070de8 (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
    • Yes

      Upon hitting an entity or a block, a Fireball will fire two instances of ProjectileHitEvent on the same tick. This includes small fireballs, wither skulls, and likely every other subinterface.

      This behavior is not exhibited with non-fireball projectiles such as arrows.

       

      import org.bukkit.Bukkit;
      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.entity.ProjectileHitEvent;
      import org.bukkit.plugin.java.JavaPlugin;
      
      public final class SamplePlugin extends JavaPlugin implements Listener {
          @Override
          public void onEnable() {
              this.getServer().getPluginManager().registerEvents(this, this);
          }
          @EventHandler(ignoreCancelled = true)
          private void onSkullHit(final ProjectileHitEvent event) {
              if (event.getHitEntity() != null) {
                  Bukkit.broadcastMessage(event.getEntityType().toString() + " hit an entity at " + event.getEntity().getWorld().getFullTime());
              }
              if (event.getHitBlock() != null) {
                  Bukkit.broadcastMessage(event.getEntityType().toString() + " hit a block at " + event.getEntity().getWorld().getFullTime());
              }
          }
      }
      

      Expected Output:

      [12:43:19] [Server thread/INFO]: ARROW hit an entity at 6541
      [12:43:20] [Server thread/INFO]: SMALL_FIREBALL hit a block at 6550
      [12:43:25] [Server thread/INFO]: ARROW hit a block at 6654
      [12:43:25] [Server thread/INFO]: SMALL_FIREBALL hit an entity at 6655

      Actual Output:

      [12:43:19] [Server thread/INFO]: ARROW hit an entity at 6541
      [12:43:20] [Server thread/INFO]: SMALL_FIREBALL hit a block at 6550
      [12:43:20] [Server thread/INFO]: SMALL_FIREBALL hit a block at 6550
      [12:43:25] [Server thread/INFO]: ARROW hit a block at 6654
      [12:43:25] [Server thread/INFO]: SMALL_FIREBALL hit an entity at 6655
      [12:43:25] [Server thread/INFO]: SMALL_FIREBALL hit an entity at 6655

       

        1. spigot-bug-clip.mp4
          6.57 MB
          FullPotato

            Unassigned Unassigned
            holographicftw@gmail.com FullPotato
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: