Class ItemProjectile

java.lang.Object
org.bukkit.scheduler.BukkitRunnable
com.sucy.skill.api.projectile.CustomProjectile
com.sucy.skill.api.projectile.ItemProjectile
All Implemented Interfaces:
Followable, Runnable, org.bukkit.metadata.Metadatable

public class ItemProjectile extends CustomProjectile

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

  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemProjectile(org.bukkit.entity.LivingEntity thrower, org.bukkit.Location loc, org.bukkit.inventory.ItemStack item, org.bukkit.util.Vector vel, int lifespan, boolean collideWalls)
    Constructs a new item projectile.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes the item on cancelling the task
    protected org.bukkit.event.Event
    Handles expiring due to range or leaving loaded chunks
    protected double
     
    org.bukkit.Location
    Retrieves the location of the projectile
    protected org.bukkit.util.Vector
     
    protected org.bukkit.event.Event
    hit(org.bukkit.entity.LivingEntity entity)
    Handles hitting an entity
    protected org.bukkit.event.Event
    Handles landing on terrain
    protected boolean
     
    rain(org.bukkit.entity.LivingEntity shooter, org.bukkit.Location center, org.bukkit.inventory.ItemStack item, double radius, double height, double speed, int amount, ProjectileCallback callback, int lifespan, boolean collideWalls)
    Fires a spread of projectiles from the location.
    void
    run()
    Updates the projectile's position.
    protected void
    setVelocity(org.bukkit.util.Vector velocity)
     
    spread(org.bukkit.entity.LivingEntity shooter, org.bukkit.util.Vector center, org.bukkit.Location loc, org.bukkit.inventory.ItemStack item, double angle, int amount, ProjectileCallback callback, int lifespan, boolean collideWalls)
    Fires a spread of projectiles from the location.

    Methods inherited from class org.bukkit.scheduler.BukkitRunnable

    getTaskId, isCancelled, runTask, runTaskAsynchronously, runTaskLater, runTaskLaterAsynchronously, runTaskTimer, runTaskTimerAsynchronously

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ItemProjectile

      public ItemProjectile(org.bukkit.entity.LivingEntity thrower, org.bukkit.Location loc, org.bukkit.inventory.ItemStack item, org.bukkit.util.Vector vel, int lifespan, 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 ArrayList<ItemProjectile> spread(org.bukkit.entity.LivingEntity shooter, org.bukkit.util.Vector center, org.bukkit.Location loc, org.bukkit.inventory.ItemStack item, double angle, int amount, ProjectileCallback callback, int lifespan, boolean collideWalls)
      Fires a spread of projectiles from the location.
      Parameters:
      shooter - entity shooting the projectiles
      center - 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 ArrayList<ItemProjectile> rain(org.bukkit.entity.LivingEntity shooter, org.bukkit.Location center, org.bukkit.inventory.ItemStack item, double radius, double height, double speed, int amount, ProjectileCallback callback, int lifespan, 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