Record Class ModelRotation

java.lang.Object
java.lang.Record
kr.toxicity.model.api.tracker.ModelRotation
Record Components:
x - the pitch (x-rotation) in degrees
y - the yaw (y-rotation) in degrees

public record ModelRotation(float x, float y) extends Record
Represents the rotation of a model in degrees.

This record stores pitch (x) and yaw (y) values and provides utility methods for conversion.

Since:
1.15.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ModelRotation
    A rotation of (0, 0).
    static final ModelRotation
    An invalid rotation value used for initialization or error states.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModelRotation(float x, float y)
    Creates an instance of a ModelRotation record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    byte
    Returns the pitch packed as a byte (Minecraft protocol format).
    byte
    Returns the yaw packed as a byte (Minecraft protocol format).
    @NotNull ModelRotation
    Returns a new rotation with only the pitch component.
    float
    Returns the pitch in radians.
    float
    Returns the yaw in radians.
    final String
    Returns a string representation of this record class.
    float
    x()
    Returns the value of the x record component.
    float
    y()
    Returns the value of the y record component.
    @NotNull ModelRotation
    yaw()
    Returns a new rotation with only the yaw component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EMPTY

      public static final ModelRotation EMPTY
      A rotation of (0, 0).
      Since:
      1.15.2
    • INVALID

      public static final ModelRotation INVALID
      An invalid rotation value used for initialization or error states.
      Since:
      1.15.2
  • Constructor Details

    • ModelRotation

      public ModelRotation(float x, float y)
      Creates an instance of a ModelRotation record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
  • Method Details

    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • pitch

      @NotNull public @NotNull ModelRotation pitch()
      Returns a new rotation with only the pitch component.
      Returns:
      the pitch-only rotation
      Since:
      1.15.2
    • yaw

      @NotNull public @NotNull ModelRotation yaw()
      Returns a new rotation with only the yaw component.
      Returns:
      the yaw-only rotation
      Since:
      1.15.2
    • radianX

      public float radianX()
      Returns the pitch in radians.
      Returns:
      the pitch in radians
      Since:
      1.15.2
    • radianY

      public float radianY()
      Returns the yaw in radians.
      Returns:
      the yaw in radians
      Since:
      1.15.2
    • packedX

      public byte packedX()
      Returns the pitch packed as a byte (Minecraft protocol format).
      Returns:
      the packed pitch
      Since:
      1.15.2
    • packedY

      public byte packedY()
      Returns the yaw packed as a byte (Minecraft protocol format).
      Returns:
      the packed yaw
      Since:
      1.15.2
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • x

      public float x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public float y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component