Class RotationUtils

java.lang.Object
com.zenith.feature.pathfinder.util.RotationUtils

public class RotationUtils extends Object
  • Field Details

    • DEG_TO_RAD

      public static final double DEG_TO_RAD
      Constant that a degree value is multiplied by to get the equivalent radian value
      See Also:
    • DEG_TO_RAD_F

      public static final float DEG_TO_RAD_F
      See Also:
    • RAD_TO_DEG

      public static final double RAD_TO_DEG
      Constant that a radian value is multiplied by to get the equivalent degree value
      See Also:
    • RAD_TO_DEG_F

      public static final float RAD_TO_DEG_F
      See Also:
  • Method Details

    • wrapAnglesToRelative

      public static Rotation wrapAnglesToRelative(Rotation current, Rotation target)
      Wraps the target angles to a relative value from the current angles. This is done by subtracting the current from the target, normalizing it, and then adding the current angles back to it.
      Parameters:
      current - The current angles
      target - The target angles
      Returns:
      The wrapped angles
    • calcRotationFromVec3d

      public static Rotation calcRotationFromVec3d(org.cloudburstmc.math.vector.Vector3d orig, org.cloudburstmc.math.vector.Vector3d dest, Rotation current)
      Calculates the rotation from Vecdest to Vecorig and makes the return value relative to the specified current rotations.
      Parameters:
      orig - The origin position
      dest - The destination position
      current - The current rotations
      Returns:
      The rotation from the origin to the destination
      See Also:
    • calcLookDirectionFromRotation

      public static org.cloudburstmc.math.vector.Vector3d calcLookDirectionFromRotation(Rotation rotation)
      Calculates the look vector for the specified yaw/pitch rotations.
      Parameters:
      rotation - The input rotation
      Returns:
      Look vector for the rotation
    • reachable

      public static Optional<Rotation> reachable(PlayerContext ctx, BlockPos pos)
      Parameters:
      ctx - Context for the viewing entity
      pos - The target block position
      Returns:
      The optional rotation
      See Also:
    • reachable

      public static Optional<Rotation> reachable(PlayerContext ctx, BlockPos pos, boolean wouldSneak)
    • reachable

      public static Optional<Rotation> reachable(PlayerContext ctx, BlockPos pos, double blockReachDistance)
      Determines if the specified entity is able to reach the center of any of the sides of the specified block. It first checks if the block center is reachable, and if so, that rotation will be returned. If not, it will return the first center of a given side that is reachable. The return type will be Optional.empty() if the entity is unable to reach any of the sides of the block.
      Parameters:
      ctx - Context for the viewing entity
      pos - The target block position
      blockReachDistance - The block reach distance of the entity
      Returns:
      The optional rotation
    • reachable

      public static Optional<Rotation> reachable(PlayerContext ctx, BlockPos pos, double blockReachDistance, boolean wouldSneak)