Class AProjectile
java.lang.Object
me.deecaad.weaponmechanics.weapon.projectile.AProjectile
- Direct Known Subclasses:
RemoveOnBlockCollisionProjectile,WeaponProjectile
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAProjectile(org.bukkit.entity.LivingEntity shooter, org.bukkit.Location location, org.bukkit.util.Vector motion) protectedAProjectile(org.bukkit.Location location, org.bukkit.util.Vector motion) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDistanceTravelled(double amount) voidaddProjectileScript(ProjectileScript<?> script) intorg.bukkit.Locationorg.bukkit.block.Blockme.deecaad.core.compatibility.entity.FakeEntitydoubledoublegetDrag()doubleintUsed to fetch any temporary data from projectilesorg.bukkit.util.Vectororg.bukkit.util.Vectorintdouble-1.0 means not useddouble-1.0 means not usedorg.bukkit.util.Vectordoubleorg.bukkit.util.Vectororg.bukkit.entity.LivingEntityUsed to fetch any temporary data from projectilesorg.bukkit.WorldgetWorld()doublegetX()doublegetY()doublegetZ()booleanisDead()booleanReturns true if the calling thread is the ticking thread for this projectile.booleanbooleanvoidonCollide(me.deecaad.core.utils.ray.RayTraceResult hit) Override this method to do something when projectile collides with block or living entity.voidonEnd()Override this method to do something on endvoidonStart()Override this method to do something on startvoidremove()Marks projectile for removal and will be removed on next tick or in this tick if this method is called within the tick method.protected voidscriptEvent(Consumer<ProjectileScript<?>> consumer) voidThis can store temporary data for projectilesvoidsetLocation(org.bukkit.util.Vector location) voidsetMotion(org.bukkit.util.Vector motion) Updates motion length at same timevoidsetRawLocation(org.bukkit.util.Vector location) Main difference compared tosetLocation(Vector)is that this doesn't update projectile last location.voidThis can store temporary data for projectilesvoidspawnDisguise(me.deecaad.core.compatibility.entity.FakeEntity disguise) If this projectile already has disguise spawned, this call is ignoredbooleantick()Projectile base tickprotected voidupdateDisguise(boolean forceTeleport) This method can't be used multiple times on same tickabstract booleanThis method updates the projectile's position/velocity, and handles all physics interactions during that movement.
-
Constructor Details
-
AProjectile
protected AProjectile(org.bukkit.Location location, org.bukkit.util.Vector motion) -
AProjectile
protected AProjectile(org.bukkit.entity.LivingEntity shooter, org.bukkit.Location location, org.bukkit.util.Vector motion)
-
-
Method Details
-
isOwnedByCurrentRegion
public boolean isOwnedByCurrentRegion()Returns true if the calling thread is the ticking thread for this projectile.- Returns:
- true if the calling thread is the ticking thread for this projectile
-
getGravity
public double getGravity()- Returns:
- gravity of projectile
-
getMinimumSpeed
public double getMinimumSpeed()-1.0 means not used- Returns:
- minimum speed of projectile
-
isRemoveAtMinimumSpeed
public boolean isRemoveAtMinimumSpeed()- Returns:
- whether to remove projectile when minimum speed is reached
-
getMaximumSpeed
public double getMaximumSpeed()-1.0 means not used- Returns:
- maximum speed of projectile
-
isRemoveAtMaximumSpeed
public boolean isRemoveAtMaximumSpeed()- Returns:
- whether to remove projectile when maximum speed is reached
-
getDrag
public double getDrag()- Returns:
- base speed decreasing
-
getMaximumAliveTicks
public int getMaximumAliveTicks()- Returns:
- the maximum amount of ticks projectile can be alive
-
getDisguise
@Nullable public me.deecaad.core.compatibility.entity.FakeEntity getDisguise()- Returns:
- the disguise of projectile, or null if not used
-
getShooter
@Nullable public org.bukkit.entity.LivingEntity getShooter()- Returns:
- the shooter of projectile
-
getWorld
public org.bukkit.World getWorld()- Returns:
- the world where this projectile is in
-
getLastLocation
public org.bukkit.util.Vector getLastLocation()- Returns:
- the clone of last location
-
getLocation
public org.bukkit.util.Vector getLocation()- Returns:
- the clone of current location
-
getBukkitLocation
public org.bukkit.Location getBukkitLocation()- Returns:
- the current location as a bukkit location
-
getCurrentBlock
public org.bukkit.block.Block getCurrentBlock() -
getX
public double getX() -
getY
public double getY() -
getZ
public double getZ() -
setLocation
public void setLocation(org.bukkit.util.Vector location) - Parameters:
location- the new location for projectile
-
setRawLocation
public void setRawLocation(org.bukkit.util.Vector location) Main difference compared tosetLocation(Vector)is that this doesn't update projectile last location.- Parameters:
location- the new location for projectile
-
getMotion
public org.bukkit.util.Vector getMotion()- Returns:
- the clone of current motion
-
getMotionLength
public double getMotionLength()- Returns:
- the current motion's length
-
getNormalizedMotion
public org.bukkit.util.Vector getNormalizedMotion()- Returns:
- the normalized current motion
-
setMotion
public void setMotion(org.bukkit.util.Vector motion) Updates motion length at same time- Parameters:
motion- the new motion for projectile
-
getAliveTicks
public int getAliveTicks()- Returns:
- the amount of ticks this projectile has been alive
-
getDistanceTravelled
public double getDistanceTravelled()- Returns:
- the distance projectile has travelled where 1.0 equals 1 block
-
addDistanceTravelled
public void addDistanceTravelled(double amount) - Parameters:
amount- adds this amount to distance travelled
-
getTag
Used to fetch any temporary data from projectiles- Parameters:
key- the key to fetch- Returns:
- the value of key or null if not found
-
setTag
This can store temporary data for projectiles- Parameters:
key- the key to usevalue- the value for key
-
getIntTag
Used to fetch any temporary data from projectiles- Parameters:
key- the key to fetch- Returns:
- the value of key or 0 if not found
-
setIntTag
This can store temporary data for projectiles- Parameters:
key- the key to usevalue- the value for key
-
isDead
public boolean isDead()- Returns:
- true if projectile is marked for removal or is already dead
-
addProjectileScript
-
remove
public void remove()Marks projectile for removal and will be removed on next tick or in this tick if this method is called within the tick method. -
tick
public boolean tick()Projectile base tick- Returns:
- true if projectile should be removed from projectile runnable
-
spawnDisguise
public void spawnDisguise(me.deecaad.core.compatibility.entity.FakeEntity disguise) If this projectile already has disguise spawned, this call is ignored- Parameters:
disguise- the disguise to spawn
-
updateDisguise
protected void updateDisguise(boolean forceTeleport) This method can't be used multiple times on same tick- Parameters:
forceTeleport- true to force teleport packet
-
updatePosition
public abstract boolean updatePosition()This method updates the projectile's position/velocity, and handles all physics interactions during that movement. This method also updatesdistanceTravelled.- Returns:
- true if projectile should be removed from projectile runnable
-
onStart
public void onStart()Override this method to do something on start -
onEnd
public void onEnd()Override this method to do something on end -
onCollide
public void onCollide(me.deecaad.core.utils.ray.RayTraceResult hit) Override this method to do something when projectile collides with block or living entity.- Parameters:
hit- the collided block or living entity
-
scriptEvent
-