Class PlayerGravitySnapObjectEvent

All Implemented Interfaces:
Cancellable

public final class PlayerGravitySnapObjectEvent extends PlayerObjectEvent
Called when a floating object "snaps down" to the ground instead of breaking after losing contact to the ground (gravity). If the event is cancelled, the object does not move (it may break in a later integrity check instead).
The new position and rotation can be changed. The new position has to stay within the chunk of the object, otherwise the change is ignored.
See Also:
  • Method Details

    • getObject

      public ObjectElement getObject()
      Description copied from class: PlayerObjectEvent
      Gets the object element.
      Overrides:
      getObject in class PlayerObjectEvent
      Returns:
      the object element.
    • getOldPosition

      public Vector3f getOldPosition()
      Gets the world position of the object before the snap.
      Returns:
      the old global object position as a Vector3f.
    • getOldRotation

      public Quaternion getOldRotation()
      Gets the rotation of the object before the snap.
      Returns:
      the old object rotation as a Quaternion.
    • getPosition

      public Vector3f getPosition()
      Gets the new world position of the object (i.e. the position after the snap).
      Returns:
      the new global object position as a Vector3f.
    • getRotation

      public Quaternion getRotation()
      Gets the new rotation of the object (i.e. the rotation after the snap). The rotation may differ from the old rotation if the object adapts to the slope of the ground.
      Returns:
      the new object rotation as a Quaternion.
    • setPosition

      public void setPosition(Vector3f position)
      Changes the new world position of the object. The position has to stay within the chunk of the object, otherwise it is ignored.
      Parameters:
      position - the new object world position.
    • setPosition

      public void setPosition(float x, float y, float z)
      Changes the new world position of the object. The position has to stay within the chunk of the object, otherwise it is ignored.
      Parameters:
      x - the new object world x position.
      y - the new object world y position.
      z - the new object world z position.
    • setRotation

      public void setRotation(Quaternion rotation)
      Changes the new rotation of the object.
      Parameters:
      rotation - the new object rotation. Set to null to reset the rotation (Quaternion.IDENTITY).