public final class RotationUtils extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
DEG_TO_RAD
Constant that a degree value is multiplied by to get the equivalent radian value
|
static double |
RAD_TO_DEG
Constant that a radian value is multiplied by to get the equivalent degree value
|
Modifier and Type | Method and Description |
---|---|
static Rotation |
calcRotationFromCoords(net.minecraft.util.math.BlockPos orig,
net.minecraft.util.math.BlockPos dest)
Calculates the rotation from BlockPosdest to BlockPosorig
|
static Rotation |
calcRotationFromVec3d(net.minecraft.util.math.Vec3d orig,
net.minecraft.util.math.Vec3d dest,
Rotation current)
Calculates the rotation from Vecdest to Vecorig and makes the
return value relative to the specified current rotations.
|
static net.minecraft.util.math.Vec3d |
calcVec3dFromRotation(Rotation rotation)
Calculates the look vector for the specified yaw/pitch rotations.
|
static java.util.Optional<Rotation> |
reachable(net.minecraft.client.entity.EntityPlayerSP entity,
net.minecraft.util.math.BlockPos pos,
double blockReachDistance)
Determines if the specified entity is able to reach the center of any of the sides
of the specified block.
|
static java.util.Optional<Rotation> |
reachable(net.minecraft.client.entity.EntityPlayerSP entity,
net.minecraft.util.math.BlockPos pos,
double blockReachDistance,
boolean wouldSneak) |
static java.util.Optional<Rotation> |
reachable(IPlayerContext ctx,
net.minecraft.util.math.BlockPos pos) |
static java.util.Optional<Rotation> |
reachable(IPlayerContext ctx,
net.minecraft.util.math.BlockPos pos,
boolean wouldSneak) |
static java.util.Optional<Rotation> |
reachableCenter(net.minecraft.entity.Entity entity,
net.minecraft.util.math.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.
|
static java.util.Optional<Rotation> |
reachableOffset(net.minecraft.entity.Entity entity,
net.minecraft.util.math.BlockPos pos,
net.minecraft.util.math.Vec3d offsetPos,
double blockReachDistance,
boolean wouldSneak)
Determines if the specified entity is able to reach the specified block with
the given offsetted position.
|
static Rotation |
wrapAnglesToRelative(Rotation current,
Rotation target)
Wraps the target angles to a relative value from the current angles.
|
public static final double DEG_TO_RAD
public static final double RAD_TO_DEG
public static Rotation calcRotationFromCoords(net.minecraft.util.math.BlockPos orig, net.minecraft.util.math.BlockPos dest)
orig
- The origin positiondest
- The destination positionpublic static Rotation wrapAnglesToRelative(Rotation current, Rotation target)
current
- The current anglestarget
- The target anglespublic static Rotation calcRotationFromVec3d(net.minecraft.util.math.Vec3d orig, net.minecraft.util.math.Vec3d dest, Rotation current)
orig
- The origin positiondest
- The destination positioncurrent
- The current rotationswrapAnglesToRelative(Rotation, Rotation)
public static net.minecraft.util.math.Vec3d calcVec3dFromRotation(Rotation rotation)
rotation
- The input rotationpublic static java.util.Optional<Rotation> reachable(IPlayerContext ctx, net.minecraft.util.math.BlockPos pos)
ctx
- Context for the viewing entitypos
- The target block positionreachable(EntityPlayerSP, BlockPos, double)
public static java.util.Optional<Rotation> reachable(IPlayerContext ctx, net.minecraft.util.math.BlockPos pos, boolean wouldSneak)
public static java.util.Optional<Rotation> reachable(net.minecraft.client.entity.EntityPlayerSP entity, net.minecraft.util.math.BlockPos pos, double blockReachDistance)
Optional.empty()
if the entity is
unable to reach any of the sides of the block.entity
- The viewing entitypos
- The target block positionblockReachDistance
- The block reach distance of the entitypublic static java.util.Optional<Rotation> reachable(net.minecraft.client.entity.EntityPlayerSP entity, net.minecraft.util.math.BlockPos pos, double blockReachDistance, boolean wouldSneak)
public static java.util.Optional<Rotation> reachableOffset(net.minecraft.entity.Entity entity, net.minecraft.util.math.BlockPos pos, net.minecraft.util.math.Vec3d offsetPos, double blockReachDistance, boolean wouldSneak)
Optional.empty()
if
the entity is unable to reach the block with the offset applied.entity
- The viewing entitypos
- The target block positionoffsetPos
- The position of the block with the offset applied.blockReachDistance
- The block reach distance of the entitypublic static java.util.Optional<Rotation> reachableCenter(net.minecraft.entity.Entity entity, net.minecraft.util.math.BlockPos pos, double blockReachDistance, boolean wouldSneak)
entity
- The viewing entitypos
- The target block positionblockReachDistance
- The block reach distance of the entity