java.lang.Object
me.deecaad.weaponmechanics.weapon.projectile.AProjectile
Direct Known Subclasses:
RemoveOnBlockCollisionProjectile, WeaponProjectile

public abstract class AProjectile extends Object
  • 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 to setLocation(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

      public String getTag(String key)
      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

      public void setTag(String key, String value)
      This can store temporary data for projectiles
      Parameters:
      key - the key to use
      value - the value for key
    • getIntTag

      public int getIntTag(String key)
      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

      public void setIntTag(String key, int value)
      This can store temporary data for projectiles
      Parameters:
      key - the key to use
      value - the value for key
    • isDead

      public boolean isDead()
      Returns:
      true if projectile is marked for removal or is already dead
    • addProjectileScript

      public void addProjectileScript(ProjectileScript<?> script)
    • 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 updates distanceTravelled.
      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

      protected void scriptEvent(Consumer<ProjectileScript<?>> consumer)