Package com.sucy.skill.api.projectile
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
Represents a projectile that uses an item as the actual projectile.
-
Constructor Summary
ConstructorsConstructorDescriptionItemProjectile(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 TypeMethodDescriptionvoidcancel()Removes the item on cancelling the taskprotected org.bukkit.event.Eventexpire()Handles expiring due to range or leaving loaded chunksprotected doubleorg.bukkit.LocationRetrieves the location of the projectileprotected org.bukkit.util.Vectorprotected org.bukkit.event.Eventhit(org.bukkit.entity.LivingEntity entity) Handles hitting an entityprotected org.bukkit.event.Eventland()Handles landing on terrainprotected booleanlanded()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.voidrun()Updates the projectile's position.protected voidsetVelocity(org.bukkit.util.Vector velocity) 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.Methods inherited from class com.sucy.skill.api.projectile.CustomProjectile
applyLanded, calcRain, calcSpread, checkCollision, getMetadata, getShooter, hasMetadata, isTraveling, isValid, removeMetadata, setAllyEnemy, setCallback, setMetadataMethods inherited from class org.bukkit.scheduler.BukkitRunnable
getTaskId, isCancelled, runTask, runTaskAsynchronously, runTaskLater, runTaskLaterAsynchronously, runTaskTimer, runTaskTimerAsynchronously
-
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 projectileloc- the location to shoot fromitem- the item to represent the projectilevel- the velocity of the projectilecollideWalls- 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:
getLocationin interfaceFollowable- Specified by:
getLocationin classCustomProjectile- Returns:
- location of the projectile
-
expire
protected org.bukkit.event.Event expire()Handles expiring due to range or leaving loaded chunks- Specified by:
expirein classCustomProjectile
-
land
protected org.bukkit.event.Event land()Handles landing on terrain- Specified by:
landin classCustomProjectile
-
hit
protected org.bukkit.event.Event hit(org.bukkit.entity.LivingEntity entity) Handles hitting an entity- Specified by:
hitin classCustomProjectile- Parameters:
entity- entity the projectile hit
-
landed
protected boolean landed()- Specified by:
landedin classCustomProjectile- Returns:
- true if item is on the ground, false otherwise
-
getCollisionRadius
protected double getCollisionRadius()- Specified by:
getCollisionRadiusin classCustomProjectile- Returns:
- squared radius for colliding
-
getVelocity
protected org.bukkit.util.Vector getVelocity()- Specified by:
getVelocityin classCustomProjectile
-
setVelocity
protected void setVelocity(org.bukkit.util.Vector velocity) - Specified by:
setVelocityin classCustomProjectile
-
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:
cancelin classCustomProjectile
-
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 projectilescenter- the center velocity of the spreadloc- location to shoot fromitem- the item to use for the projectileangle- angle of the spreadamount- number of projectiles to firecallback- optional callback for when projectiles hitlifespan- maximum duration of the projectilecollideWalls- 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 projectilescenter- the center location to rain onitem- the item to use for the projectileradius- radius of the circleheight- height above the center locationspeed- speed of the projectilesamount- number of projectiles to firecallback- optional callback for when projectiles hitlifespan- maximum duration of the projectilecollideWalls- whether to consider wall collisions as the projectiles landing- Returns:
- list of fired projectiles
-