Class EventRotate


public class EventRotate extends CancellableEvent
EventRotate

Event fired when the client is about to rotate the player. This event allows addons to modify rotation values.

WARNING: If another feature already rotated, changing yaw or pitch will likely break that feature.

To remain safe, only modify rotation values when isFree() returns true.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    Whether the client is already rotating.
    float
    The pitch rotation value
    float
    The yaw rotation value
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    get(InteractionMode mode, float yaw, float pitch, boolean clientRotating)
    Gets the event instance
    Gets the interaction mode
    boolean
    Returns whether this rotation event is free to modify.
    void
    rotate(net.minecraft.util.math.Vec3d target)
    Calculates and sets the rotation to face the specified position.
    void
    rotate(net.minecraft.util.math.Vec3d eyes, net.minecraft.util.math.Vec3d target)
    Calculates and sets the rotation to face the specified position from the given eye position.

    Methods inherited from class dev.boze.api.event.CancellableEvent

    cancel, isCancelled, setCancelled

    Methods inherited from class java.lang.Object

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

    • yaw

      public float yaw
      The yaw rotation value
    • pitch

      public float pitch
      The pitch rotation value
    • clientRotating

      public boolean clientRotating
      Whether the client is already rotating. If true, modifying yaw/pitch can break client modules.
  • Constructor Details

    • EventRotate

      public EventRotate()
  • Method Details

    • get

      public static EventRotate get(InteractionMode mode, float yaw, float pitch, boolean clientRotating)
      Gets the event instance
      Parameters:
      mode - The interaction mode
      yaw - The yaw value
      pitch - The pitch value
      clientRotating - Whether the client is already rotating
      Returns:
      The event instance
    • getMode

      public InteractionMode getMode()
      Gets the interaction mode
      Returns:
      The interaction mode
    • isFree

      public boolean isFree()
      Returns whether this rotation event is free to modify. A rotation event is free if it's not cancelled and the client is not already rotating.
      Returns:
      true if the rotation can be safely modified, false otherwise
    • rotate

      public void rotate(net.minecraft.util.math.Vec3d eyes, net.minecraft.util.math.Vec3d target)
      Calculates and sets the rotation to face the specified position from the given eye position. This method should only be called when isFree() returns true.
      Parameters:
      eyes - The eye position to calculate from
      target - The target position to rotate towards
    • rotate

      public void rotate(net.minecraft.util.math.Vec3d target)
      Calculates and sets the rotation to face the specified position. This method should only be called when isFree() returns true.
      Parameters:
      target - The target position to rotate towards