Interface Projectile

All Superinterfaces:
Audience, CommandSender, Entity, HoverEventSource<HoverEvent.ShowEntity>, Metadatable, Nameable, Permissible, PersistentDataHolder, Pointered, ServerOperator, Sound.Emitter
All Known Subinterfaces:
AbstractArrow, AbstractWindCharge, Arrow, BreezeWindCharge, DragonFireball, Egg, EnderPearl, Fireball, Firework, FishHook, LargeFireball, LingeringPotion, LlamaSpit, ShulkerBullet, SizedFireball, SmallFireball, Snowball, SpectralArrow, SplashPotion, ThrowableProjectile, ThrownExpBottle, ThrownPotion, TippedArrow, Trident, WindCharge, WitherSkull

public interface Projectile extends Entity
Represents a shootable entity.
  • Method Details

    • getShooter

      Retrieve the shooter of this projectile.
      Returns:
      the ProjectileSource that shot this projectile
      See Also:
    • setShooter

      void setShooter(@Nullable @Nullable ProjectileSource source)
      Set the shooter of this projectile.
      Parameters:
      source - the ProjectileSource that shot this projectile
    • doesBounce

      @Deprecated(forRemoval=true) boolean doesBounce()
      Deprecated, for removal: This API element is subject to removal in a future version.
      does not do anything
      Determine if this projectile should bounce or not when it hits.
      Returns:
      true if it should bounce.
    • setBounce

      @Deprecated(forRemoval=true) void setBounce(boolean doesBounce)
      Deprecated, for removal: This API element is subject to removal in a future version.
      does not do anything
      Set whether or not this projectile should bounce or not when it hits something.
      Parameters:
      doesBounce - whether or not it should bounce.
    • hasLeftShooter

      boolean hasLeftShooter()
      Gets whether the projectile has left the hitbox of their shooter and can now hit entities.
      Returns:
      has left shooter's hitbox
    • setHasLeftShooter

      void setHasLeftShooter(boolean leftShooter)
      Sets whether the projectile has left the hitbox of their shooter and can now hit entities. This is recalculated each tick if the projectile has a shooter.
      Parameters:
      leftShooter - has left shooter's hitbox
    • hasBeenShot

      boolean hasBeenShot()
      Gets whether the projectile has been shot into the world and has sent a projectile shot game event.
      Returns:
      has been shot into the world
    • setHasBeenShot

      void setHasBeenShot(boolean beenShot)
      Sets whether the projectile has been shot into the world and has sent a projectile shot game event in the next tick. Setting this to false will cause a game event to fire and the value to be set back to true.
      Parameters:
      beenShot - has been in shot into the world
    • canHitEntity

      boolean canHitEntity(@NotNull @NotNull Entity entity)
      Gets whether this projectile can hit an entity.

      This method returns true under the following conditions:

      - The shooter can see the entity (Player.canSee(Entity))

      - The entity is alive and not a spectator

      - The projectile has left the hitbox of the shooter (hasLeftShooter())

      - If this is an arrow with piercing, it has not pierced the entity already

      Parameters:
      entity - the entity to check if this projectile can hit
      Returns:
      true if this projectile can damage the entity, false otherwise
    • hitEntity

      void hitEntity(@NotNull @NotNull Entity entity)
      Makes this projectile hit a specific entity. This uses the current position of the projectile for the hit point. Using this method will result in ProjectileHitEvent being called.
      Parameters:
      entity - the entity to hit
      See Also:
    • hitEntity

      void hitEntity(@NotNull @NotNull Entity entity, @NotNull Vector vector)
      Makes this projectile hit a specific entity from a specific point. Using this method will result in ProjectileHitEvent being called.
      Parameters:
      entity - the entity to hit
      vector - the direction to hit from
      See Also:
    • getOwnerUniqueId

      @Nullable UUID getOwnerUniqueId()
      Gets the owner's UUID
      Returns:
      the owner's UUID, or null if not owned
      See Also: