Class PlayerHitObjectEvent

All Implemented Interfaces:
Cancellable

public final class PlayerHitObjectEvent extends PlayerObjectEvent
Called when a player hits an object (e.g furniture, doors, lamps etc).
Example: Destroy object after a single hit
1@EventMethod
2public void onObjectHit(PlayerObjectHitEvent event){
3 //Call "removeObject()" on the "World" object. Retrieve typeID and position coordinates from the event
4 world.removeObject(event.getObjectTypeID(), event.getObjectPositionX(), event.getObjectPositionY(), event.getObjectPositionZ());
5}
See Also:
  • Method Details

    • getDamage

      public short getDamage()
      Gets the amount of damage the player causes by hitting the object.
      Returns:
      the amount of damage dealt with this hit.
    • setDamage

      public void setDamage(short damage)
      Sets the amount of damage the player should inflict with this hit.
      Parameters:
      damage - the new amount of damage.
    • getHitPosition

      public Vector3f getHitPosition()
      Gets the world coordinates where the object was hit exactly.
      Returns:
      coordinates where the object was hit.