Class YawRotation

java.lang.Object
com.hypixel.hytale.builtin.triggervolumes.YawRotation

public final class YawRotation extends Object
Helpers for applying a prefab paste or world-gen yaw to trigger volume data. The paste yaw follows the entity transform convention: a yaw of theta moves world offsets exactly like Vector3d.rotateY(double) and composes with block rotations as Rotation.ofDegrees(toDegrees(theta)).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Yaws below this magnitude (radians) are treated as no rotation.
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    addDegrees(float degrees, float yawRadians)
    Adds the yaw to a facing in degrees, normalized to [0, 360).
    static int
    quarterTurns(float yawRadians)
    Number of exact quarter turns in the yaw (0..3), or -1 when the yaw is not a multiple of 90 degrees.
    static Rotation
    rotate(Rotation rotation, int quarterTurns)
    Composes quarter turns onto a block rotation.
    static void
    rotate(org.joml.Vector3d vector, float yawRadians)
    Rotates the vector's XZ components around the origin by the yaw.
    static void
    rotateBlockOffset(org.joml.Vector3d offset, float yawRadians, org.joml.Vector3d volumeOrigin)
    Rotates a block-targeting offset (relative to volumeOrigin) about that origin, using the target cell's CENTER as the pivot point rather than the offset vector's corner.

    Methods inherited from class Object

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

    • EPSILON

      public static final double EPSILON
      Yaws below this magnitude (radians) are treated as no rotation.
      See Also:
  • Method Details

    • rotate

      public static void rotate(@Nonnull org.joml.Vector3d vector, float yawRadians)
      Rotates the vector's XZ components around the origin by the yaw. Quarter-turn yaws use exact component swaps so block-aligned coordinates stay exact instead of picking up cos(pi/2) floating-point dust that would change floor() results.
    • rotateBlockOffset

      public static void rotateBlockOffset(@Nonnull org.joml.Vector3d offset, float yawRadians, @Nonnull org.joml.Vector3d volumeOrigin)
      Rotates a block-targeting offset (relative to volumeOrigin) about that origin, using the target cell's CENTER as the pivot point rather than the offset vector's corner. This matches how real blocks rotate on the grid, so an even-sized volume (origin on a cell boundary) rotates its placements the same as an odd-sized one (origin on a cell center); it reduces to a plain offset rotation for odd volumes. Only the X and Z components change; Y is left untouched.

      The resolved block stays floor(volumeOrigin + offset), so callers rotate here and then resolve normally. The offset gains fractional X/Z (the cell-center remainder), which is expected.

    • quarterTurns

      public static int quarterTurns(float yawRadians)
      Number of exact quarter turns in the yaw (0..3), or -1 when the yaw is not a multiple of 90 degrees. Fields limited to 90-degree steps (block rotations) only compose at exact quarter turns and stay unchanged for arbitrary yaws.
    • rotate

      @Nonnull public static Rotation rotate(@Nonnull Rotation rotation, int quarterTurns)
      Composes quarter turns onto a block rotation.
    • addDegrees

      public static float addDegrees(float degrees, float yawRadians)
      Adds the yaw to a facing in degrees, normalized to [0, 360).