Skip to main content

Overview

The ModelRotation class represents the rotation of a model in degrees, storing pitch (x) and yaw (y) values. It provides utility methods for conversion between degrees, radians, and Minecraft’s packed byte format.

Class Definition

Parameters:
  • x - The pitch (x-rotation) in degrees
  • y - The yaw (y-rotation) in degrees

Constants

EMPTY

A rotation of (0, 0), representing no rotation.

INVALID

An invalid rotation value (Float.MAX_VALUE, Float.MAX_VALUE) used for initialization or error states.

Methods

pitch()

Returns a new rotation with only the pitch component.
Returns: The pitch-only rotation (x, 0) Example:

yaw()

Returns a new rotation with only the yaw component.
Returns: The yaw-only rotation (0, y) Example:

radianX()

Returns the pitch in radians.
Returns: The pitch in radians Example:

radianY()

Returns the yaw in radians.
Returns: The yaw in radians Example:

packedX()

Returns the pitch packed as a byte in Minecraft protocol format.
Returns: The packed pitch value Note: Minecraft uses packed bytes to represent rotations in network packets, where a full 360° rotation is represented by 256 discrete steps.

packedY()

Returns the yaw packed as a byte in Minecraft protocol format.
Returns: The packed yaw value

Usage Example

Equality and Hashing

The ModelRotation record uses packed values for equality checks and hash code calculation, ensuring that rotations are compared based on their Minecraft protocol representation rather than raw float values.

See Also