Class PlayerGravitySnapVegetationEvent

All Implemented Interfaces:
Cancellable

public final class PlayerGravitySnapVegetationEvent extends PlayerVegetationEvent implements Cancellable
Called when a floating plant "snaps down" to the ground instead of breaking after losing contact to the ground (gravity). If the event is cancelled, the plant 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 plant, otherwise the change is ignored.
See Also:
  • Method Details

    • getPlant

      public Plant getPlant()
      Description copied from class: PlayerVegetationEvent
      Gets the plant.
      Overrides:
      getPlant in class PlayerVegetationEvent
      Returns:
      the plant element.
    • getOldPosition

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

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

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

      public Quaternion getRotation()
      Gets the new rotation of the plant (i.e. the rotation after the snap).
      Returns:
      the new plant rotation as a Quaternion.
    • getScale

      public Vector3f getScale()
      Gets the scale factor of the plant along the x, y and z axis. By default, it's 1 1 1.
      Returns:
      the plant scale factor, as a Vector3f.
    • setPosition

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

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

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