Class ItemProjectile

java.lang.Object
org.bukkit.scheduler.BukkitRunnable
studio.magemonkey.fabled.api.projectile.CustomProjectile
studio.magemonkey.fabled.api.projectile.ItemProjectile
All Implemented Interfaces:
Runnable, org.bukkit.metadata.Metadatable, Followable

public class ItemProjectile extends CustomProjectile

Represents a projectile that uses an item as the actual projectile.

  • Field Details

  • Constructor Details

    • ItemProjectile

      public ItemProjectile(org.bukkit.entity.LivingEntity thrower, int level, org.bukkit.Location loc, Settings settings, org.bukkit.inventory.ItemStack item, org.bukkit.util.Vector vel, int lifespan, int distance, boolean collideWalls)

      Constructs a new item projectile.

      Parameters:
      thrower - the entity throwing the projectile
      loc - the location to shoot from
      item - the item to represent the projectile
      vel - the velocity of the projectile
      collideWalls - whether to consider wall collisions as the projectile landing
  • Method Details

    • getLocation

      public org.bukkit.Location getLocation()
      Retrieves the location of the projectile
      Specified by:
      getLocation in interface Followable
      Specified by:
      getLocation in class CustomProjectile
      Returns:
      location of the projectile
    • expire

      protected org.bukkit.event.Event expire()
      Handles expiring due to range or leaving loaded chunks
      Specified by:
      expire in class CustomProjectile
    • land

      protected org.bukkit.event.Event land()
      Handles landing on terrain
      Specified by:
      land in class CustomProjectile
    • hit

      protected org.bukkit.event.Event hit(org.bukkit.entity.LivingEntity entity)
      Handles hitting an entity
      Specified by:
      hit in class CustomProjectile
      Parameters:
      entity - entity the projectile hit
    • landed

      protected boolean landed()
      Specified by:
      landed in class CustomProjectile
      Returns:
      true if item is on the ground, false otherwise
    • getCollisionRadius

      protected double getCollisionRadius()
      Specified by:
      getCollisionRadius in class CustomProjectile
      Returns:
      squared radius for colliding
    • getVelocity

      protected org.bukkit.util.Vector getVelocity()
      Specified by:
      getVelocity in class CustomProjectile
    • setVelocity

      protected void setVelocity(org.bukkit.util.Vector velocity)
      Specified by:
      setVelocity in class CustomProjectile
    • run

      public void run()

      Updates the projectile's position.

      This is for the repeating task and if you call it yourself, it will move faster than it should.

    • cancel

      public void cancel()
      Removes the item on cancelling the task
      Overrides:
      cancel in class CustomProjectile
    • spread

      public static List<ItemProjectile> spread(org.bukkit.entity.LivingEntity shooter, int level, org.bukkit.util.Vector direction, org.bukkit.Location loc, Settings settings, org.bukkit.inventory.ItemStack item, double angle, int amount, ProjectileCallback callback, int lifespan, int distance, boolean collideWalls)
      Fires a spread of projectiles from the location.
      Parameters:
      shooter - entity shooting the projectiles
      direction - the center velocity of the spread
      loc - location to shoot from
      item - the item to use for the projectile
      angle - angle of the spread
      amount - number of projectiles to fire
      callback - optional callback for when projectiles hit
      lifespan - maximum duration of the projectile
      collideWalls - whether to consider wall collisions as the projectiles landing
      Returns:
      list of fired projectiles
    • rain

      public static List<ItemProjectile> rain(org.bukkit.entity.LivingEntity shooter, int level, org.bukkit.Location center, Settings settings, org.bukkit.inventory.ItemStack item, double radius, double height, double speed, int amount, ProjectileCallback callback, int lifespan, int distance, boolean collideWalls)
      Fires a spread of projectiles from the location.
      Parameters:
      shooter - entity shooting the projectiles
      center - the center location to rain on
      item - the item to use for the projectile
      radius - radius of the circle
      height - height above the center location
      speed - speed of the projectiles
      amount - number of projectiles to fire
      callback - optional callback for when projectiles hit
      lifespan - maximum duration of the projectile
      collideWalls - whether to consider wall collisions as the projectiles landing
      Returns:
      list of fired projectiles
    • getItem

      public org.bukkit.entity.Item getItem()