Class RotationUtils
java.lang.Object
com.zenith.feature.pathfinder.util.RotationUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleConstant that a degree value is multiplied by to get the equivalent radian valuestatic final floatstatic final doubleConstant that a radian value is multiplied by to get the equivalent degree valuestatic final float -
Method Summary
Modifier and TypeMethodDescriptionstatic org.cloudburstmc.math.vector.Vector3dcalcLookDirectionFromRotation(Rotation rotation) Calculates the look vector for the specified yaw/pitch rotations.static RotationcalcRotationFromVec3d(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.reachable(PlayerContext ctx, BlockPos pos) reachable(PlayerContext ctx, BlockPos pos, boolean wouldSneak) 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.reachable(PlayerContext ctx, BlockPos pos, double blockReachDistance, boolean wouldSneak) static RotationwrapAnglesToRelative(Rotation current, Rotation target) Wraps the target angles to a relative value from the current angles.
-
Field Details
-
DEG_TO_RAD
public static final double DEG_TO_RADConstant 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_DEGConstant 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
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 anglestarget- 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 positiondest- The destination positioncurrent- 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
- Parameters:
ctx- Context for the viewing entitypos- The target block position- Returns:
- The optional rotation
- See Also:
-
reachable
-
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 beOptional.empty()if the entity is unable to reach any of the sides of the block.- Parameters:
ctx- Context for the viewing entitypos- The target block positionblockReachDistance- 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)
-