Class Transform

java.lang.Object
com.hypixel.hytale.math.vector.Transform

public class Transform extends Object
A class that represents a position and rotation in 3D space.
  • Field Details

    • CODEC

      @Nonnull public static final BuilderCodec<Transform> CODEC
      The codec used to parse Transform instances.
    • PARTIAL_TELEPORT_CODEC

      @Nonnull public static final BuilderCodec<Transform> PARTIAL_TELEPORT_CODEC
      The codec used to parse Transform instances with default rotation values of Float.NaN. This allows player teleports to have rotational values of Float.NaN and be ignored by the client - enabling relative teleports. CODEC should always be used when default rotation values of zero are supported.
    • CODEC_DEGREES

      @Nonnull public static final BuilderCodec<Transform> CODEC_DEGREES
      The codec used to parse Transform instances but with the angles as degrees
    • X_IS_RELATIVE

      public static final int X_IS_RELATIVE
      A bitmask constant indicating that the X component is relative.
      See Also:
    • Y_IS_RELATIVE

      public static final int Y_IS_RELATIVE
      A bitmask constant indicating that the Y component is relative.
      See Also:
    • Z_IS_RELATIVE

      public static final int Z_IS_RELATIVE
      A bitmask constant indicating that the Z component is relative.
      See Also:
    • YAW_IS_RELATIVE

      public static final int YAW_IS_RELATIVE
      A bitmask constant indicating that the Yaw component is relative.
      See Also:
    • PITCH_IS_RELATIVE

      public static final int PITCH_IS_RELATIVE
      A bitmask constant indicating that the Pitch component is relative.
      See Also:
    • ROLL_IS_RELATIVE

      public static final int ROLL_IS_RELATIVE
      A bitmask constant indicating that the Roll component is relative.
      See Also:
    • RELATIVE_TO_BLOCK

      public static final int RELATIVE_TO_BLOCK
      A bitmask constant indicating that the transform is relative to a block position.
      See Also:
  • Constructor Details

    • Transform

      public Transform()
      Empty Constructor for a Transform instance.

      Used by the codec to instantiate Transform instances.

    • Transform

      public Transform(@Nonnull org.joml.Vector3ic position)
      Default Constructor for a Transform instance.
      Parameters:
      position - The position of the transform.
    • Transform

      public Transform(@Nonnull org.joml.Vector3dc position)
      Default Constructor for a Transform instance.
      Parameters:
      position - The position of the transform.
    • Transform

      public Transform(double x, double y, double z)
      Default Constructor for a Transform instance.
      Parameters:
      x - The x position of the transform.
      y - The y position of the transform.
      z - The z position of the transform.
    • Transform

      public Transform(double x, double y, double z, float pitch, float yaw, float roll)
      Default Constructor for a Transform instance.
      Parameters:
      x - The x position of the transform.
      y - The y position of the transform.
      z - The z position of the transform.
      pitch - The pitch rotation of the transform.
      yaw - The yaw rotation of the transform.
      roll - The roll rotation of the transform.
    • Transform

      public Transform(@Nonnull Transform transform)
      Create a new Transform whose values will be copied from the given transform.
      Parameters:
      transform - provides the initial values for the new transform
    • Transform

      public Transform(@Nonnull org.joml.Vector3dc position, @Nonnull Rotation3fc rotation)
      Constructor for a Transform instance that copies the given position and rotation.
      Parameters:
      position - The position to copy into the transform.
      rotation - The rotation to copy into the transform.
    • Transform

      public Transform(@Nonnull org.joml.Vector3d position, @Nonnull Rotation3f rotation)
      Default Constructor for a Transform instance.
      Parameters:
      position - The position of the transform.
      rotation - The rotation of the transform.
  • Method Details

    • set

      public void set(@Nonnull Transform transform)
      Called to assign the values from another transform to this one.
      Parameters:
      transform - The transform to copy from.
    • getPosition

      @Nonnull public org.joml.Vector3d getPosition()
      Returns:
      the position of the transform.
    • setPosition

      public void setPosition(@Nonnull org.joml.Vector3dc position)
      Called to set the position of the transform.
      Parameters:
      position - The given position to set.
    • getRotation

      @Nonnull public Rotation3f getRotation()
      Returns:
      the rotation of the transform.
    • setRotation

      public void setRotation(@Nonnull Rotation3fc rotation)
      Called to set the rotation of the transform.
      Parameters:
      rotation - The given rotation to set.
    • getDirection

      @Nonnull public org.joml.Vector3d getDirection()
      Returns:
      The direction of the rotation
    • getDirection

      @Nonnull public static org.joml.Vector3d getDirection(float pitch, float yaw)
      Called to get the direction vector from the given pitch and yaw.
      Parameters:
      pitch - The pitch of the rotation.
      yaw - The yaw of the rotation.
      Returns:
      The direction of the rotation.
    • getAxisDirection

      @Nonnull public org.joml.Vector3i getAxisDirection()
      Returns:
      The direction of the rotation locked to an axis
    • getAxisDirection

      @Nonnull public org.joml.Vector3i getAxisDirection(float pitch, float yaw)
      Called to get the axis direction vector from the given pitch and yaw.
      Parameters:
      pitch - The pitch of the rotation.
      yaw - The yaw of the rotation.
      Returns:
      The direction of the rotation locked to an axis
    • getAxis

      @Nonnull public Axis getAxis()
      Returns:
      The axis of the rotation
    • clone

      @Nonnull public Transform clone()
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • applyMaskedRelativeTransform

      public static void applyMaskedRelativeTransform(@Nonnull Transform transform, byte relativeMask, @Nonnull org.joml.Vector3dc sourcePosition, @Nonnull Rotation3fc sourceRotation, @Nonnull org.joml.Vector3ic blockPosition)
      Modifies the transform provided using the provided relative mask and source positions.

      The mask bits are as follows: 0b0000001 = X is relative 0b0000010 = Y is relative 0b0000100 = Z is relative 0b0001000 = Yaw is relative 0b0010000 = Pitch is relative 0b0100000 = Roll is relative 0b1000000 = Is relative to block

      Parameters:
      transform - The transform to modify
      relativeMask - The mask to use for selectively apply relative transformations.
      sourcePosition - The position to use as the source for a relative transformation.
      sourceRotation - The rotation to use as the source for a relative transformation.
      blockPosition - The block position to use as the source for a relative block transformation.