Class RotationUtils

java.lang.Object
baritone.api.utils.RotationUtils

public final class RotationUtils extends Object
Since:
9/25/2018
Author:
Brady
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Constant that a degree value is multiplied by to get the equivalent radian value
    static final float
     
    static final double
    Constant that a radian value is multiplied by to get the equivalent degree value
    static final float
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.world.phys.Vec3
    Calculates the look vector for the specified yaw/pitch rotations.
    static Rotation
    calcRotationFromCoords(net.minecraft.core.BlockPos orig, net.minecraft.core.BlockPos dest)
    Calculates the rotation from BlockPosdest to BlockPosorig
    static Rotation
    calcRotationFromVec3d(net.minecraft.world.phys.Vec3 orig, net.minecraft.world.phys.Vec3 dest, Rotation current)
    Calculates the rotation from Vecdest to Vecorig and makes the return value relative to the specified current rotations.
    static net.minecraft.world.phys.Vec3
    Deprecated.
    reachable(IPlayerContext ctx, net.minecraft.core.BlockPos pos)
     
    reachable(IPlayerContext ctx, net.minecraft.core.BlockPos pos, boolean wouldSneak)
     
    reachable(IPlayerContext ctx, net.minecraft.core.BlockPos pos, double blockReachDistance)
    Determines if the specified entity is able to reach the center of any of the sides of the specified block.
    reachable(IPlayerContext ctx, net.minecraft.core.BlockPos pos, double blockReachDistance, boolean wouldSneak)
     
    reachable(net.minecraft.client.player.LocalPlayer entity, net.minecraft.core.BlockPos pos, double blockReachDistance)
    Deprecated.
    reachable(net.minecraft.client.player.LocalPlayer entity, net.minecraft.core.BlockPos pos, double blockReachDistance, boolean wouldSneak)
    Deprecated.
    reachableCenter(IPlayerContext ctx, net.minecraft.core.BlockPos pos, double blockReachDistance, boolean wouldSneak)
    Determines if the specified entity is able to reach the specified block where it is looking at the direct center of it's hitbox.
    reachableCenter(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos, double blockReachDistance, boolean wouldSneak)
    Deprecated.
    reachableOffset(IPlayerContext ctx, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.Vec3 offsetPos, double blockReachDistance, boolean wouldSneak)
    Determines if the specified entity is able to reach the specified block with the given offsetted position.
    reachableOffset(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.Vec3 offsetPos, double blockReachDistance, boolean wouldSneak)
    Deprecated.
    static Rotation
    Wraps the target angles to a relative value from the current angles.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • calcRotationFromCoords

      public static Rotation calcRotationFromCoords(net.minecraft.core.BlockPos orig, net.minecraft.core.BlockPos dest)
      Calculates the rotation from BlockPosdest to BlockPosorig
      Parameters:
      orig - The origin position
      dest - The destination position
      Returns:
      The rotation from the origin to the destination
    • 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(net.minecraft.world.phys.Vec3 orig, net.minecraft.world.phys.Vec3 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 net.minecraft.world.phys.Vec3 calcLookDirectionFromRotation(Rotation rotation)
      Calculates the look vector for the specified yaw/pitch rotations.
      Parameters:
      rotation - The input rotation
      Returns:
      Look vector for the rotation
    • calcVec3dFromRotation

      @Deprecated public static net.minecraft.world.phys.Vec3 calcVec3dFromRotation(Rotation rotation)
      Deprecated.
    • reachable

      public static Optional<Rotation> reachable(IPlayerContext ctx, net.minecraft.core.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(IPlayerContext ctx, net.minecraft.core.BlockPos pos, boolean wouldSneak)
    • reachable

      public static Optional<Rotation> reachable(IPlayerContext ctx, net.minecraft.core.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(IPlayerContext ctx, net.minecraft.core.BlockPos pos, double blockReachDistance, boolean wouldSneak)
    • reachableOffset

      public static Optional<Rotation> reachableOffset(IPlayerContext ctx, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.Vec3 offsetPos, double blockReachDistance, boolean wouldSneak)
      Determines if the specified entity is able to reach the specified block with the given offsetted position. The return type will be Optional.empty() if the entity is unable to reach the block with the offset applied.
      Parameters:
      ctx - Context for the viewing entity
      pos - The target block position
      offsetPos - The position of the block with the offset applied.
      blockReachDistance - The block reach distance of the entity
      Returns:
      The optional rotation
    • reachableCenter

      public static Optional<Rotation> reachableCenter(IPlayerContext ctx, net.minecraft.core.BlockPos pos, double blockReachDistance, boolean wouldSneak)
      Determines if the specified entity is able to reach the specified block where it is looking at the direct center of it's hitbox.
      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

      @Deprecated public static Optional<Rotation> reachable(net.minecraft.client.player.LocalPlayer entity, net.minecraft.core.BlockPos pos, double blockReachDistance)
      Deprecated.
    • reachable

      @Deprecated public static Optional<Rotation> reachable(net.minecraft.client.player.LocalPlayer entity, net.minecraft.core.BlockPos pos, double blockReachDistance, boolean wouldSneak)
      Deprecated.
    • reachableOffset

      @Deprecated public static Optional<Rotation> reachableOffset(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.Vec3 offsetPos, double blockReachDistance, boolean wouldSneak)
      Deprecated.
    • reachableCenter

      @Deprecated public static Optional<Rotation> reachableCenter(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos pos, double blockReachDistance, boolean wouldSneak)
      Deprecated.