Class GroundFollowProjectile

java.lang.Object
com.hypixel.hytale.server.core.modules.projectile.component.GroundFollowProjectile
All Implemented Interfaces:
Component<EntityStore>, Cloneable

public class GroundFollowProjectile extends Object implements Component<EntityStore>
Makes a projectile follow the terrain surface instead of colliding with it: each tick its foot snaps to the ground ahead, climbing steps up to maxClimb blocks and dropping ledges up to maxDrop blocks. A taller wall or a deeper cliff ends the projectile's course (the miss chain runs there). Solidity is tested at block granularity (a slab or filler counts as a full block), the same approximation the NPC spawn probes use.
  • Field Details

  • Constructor Details

    • GroundFollowProjectile

      public GroundFollowProjectile(int maxClimb, int maxDrop)
  • Method Details

    • setSpawnSnap

      public void setSpawnSnap(int blocks)
      Arms the one-time spawn snap: on its first move the projectile drops up to this many blocks onto the ground. The launcher derives the value from the caster's own height above ground, so a cast a grounded gate allowed slightly airborne still produces a projectile that starts on the surface.
    • getComponentType

      public static ComponentType<EntityStore, GroundFollowProjectile> getComponentType()
    • findGroundAhead

      public int findGroundAhead(@Nonnull World world, int blockX, int footBlockY, int blockZ)
      Finds the foot Y the projectile lands on in the given column, scanning down from the highest allowed step to the deepest allowed drop.
      Parameters:
      world - The world to probe.
      blockX - The X block coordinate of the probed column.
      footBlockY - The current foot Y block coordinate.
      blockZ - The Z block coordinate of the probed column.
      Returns:
      the new foot Y block coordinate, or BLOCKED when a wall exceeds the climb allowance, the drop exceeds the drop allowance, or the chunk is not loaded.
    • consumeSpawnSnap

      public boolean consumeSpawnSnap()
      Consumes the one-time spawn snap. When it returns true, snap the foot to the ground below the spawn point with snapToGroundAtSpawn(World, int, int, int).
    • snapToGroundAtSpawn

      public int snapToGroundAtSpawn(@Nonnull World world, int blockX, int footBlockY, int blockZ)
      Finds the foot Y for the one-time spawn snap: the ground at or below the spawn point, dropping up to the armed snap distance.
      Returns:
      the new foot Y block coordinate, or BLOCKED when no ground is within reach.
    • findGroundBelow

      public static int findGroundBelow(@Nonnull World world, int blockX, int footBlockY, int blockZ, int drop)
      Finds the ground at or below the given foot, dropping up to the given allowance.
      Returns:
      the foot Y on the found surface, or BLOCKED when none is in reach.
    • clone

      @Nonnull public Component<EntityStore> clone()
      Specified by:
      clone in interface Component<EntityStore>
      Returns:
      a clone instance of the original component instance.