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
Represents a projectile that uses an item as the actual projectile.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doublestatic final Stringprotected Supplier<org.bukkit.entity.LivingEntity> static final Stringstatic final Stringstatic final Stringprotected doublestatic final Stringstatic final Stringstatic final StringFields inherited from class studio.magemonkey.fabled.api.projectile.CustomProjectile
ally, callback, enemy, settings -
Constructor Summary
ConstructorsConstructorDescriptionItemProjectile(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. -
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.entity.ItemgetItem()org.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 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.voidrun()Updates the projectile's position.protected voidsetVelocity(org.bukkit.util.Vector velocity) 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.Methods inherited from class studio.magemonkey.fabled.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
-
Field Details
-
HOMING
- See Also:
-
HOMING_TARGET
- See Also:
-
HOMING_DIST
- See Also:
-
REMEMBER
- See Also:
-
CORRECTION
- See Also:
-
WALL
- See Also:
-
RADIUS
- See Also:
-
homing
-
correction
protected double correction -
radius
protected double radius
-
-
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 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 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 projectilesdirection- 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 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 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
-
getItem
public org.bukkit.entity.Item getItem()
-