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 double
static final String
protected Supplier
<org.bukkit.entity.LivingEntity> static final String
static final String
static final String
protected double
static final String
static final String
static final String
Fields 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 TypeMethodDescriptionvoid
cancel()
Removes the item on cancelling the taskprotected org.bukkit.event.Event
expire()
Handles expiring due to range or leaving loaded chunksprotected double
org.bukkit.entity.Item
getItem()
org.bukkit.Location
Retrieves the location of the projectileprotected org.bukkit.util.Vector
protected org.bukkit.event.Event
hit
(org.bukkit.entity.LivingEntity entity) Handles hitting an entityprotected org.bukkit.event.Event
land()
Handles landing on terrainprotected boolean
landed()
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.void
run()
Updates the projectile's position.protected void
setVelocity
(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, setMetadata
Methods 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:
getLocation
in interfaceFollowable
- Specified by:
getLocation
in classCustomProjectile
- 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 classCustomProjectile
-
land
protected org.bukkit.event.Event land()Handles landing on terrain- Specified by:
land
in classCustomProjectile
-
hit
protected org.bukkit.event.Event hit(org.bukkit.entity.LivingEntity entity) Handles hitting an entity- Specified by:
hit
in classCustomProjectile
- Parameters:
entity
- entity the projectile hit
-
landed
protected boolean landed()- Specified by:
landed
in classCustomProjectile
- Returns:
- true if item is on the ground, false otherwise
-
getCollisionRadius
protected double getCollisionRadius()- Specified by:
getCollisionRadius
in classCustomProjectile
- Returns:
- squared radius for colliding
-
getVelocity
protected org.bukkit.util.Vector getVelocity()- Specified by:
getVelocity
in classCustomProjectile
-
setVelocity
protected void setVelocity(org.bukkit.util.Vector velocity) - Specified by:
setVelocity
in 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:
cancel
in 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()
-