Class EntityKnockbackEvent

All Implemented Interfaces:
Cancellable
Direct Known Subclasses:
EntityKnockbackByEntityEvent

public class EntityKnockbackEvent extends EntityEvent implements Cancellable
Called when a living entity receives knockback.
  • Constructor Details Link icon

  • Method Details Link icon

    • getEntity Link icon

      @NotNull public LivingEntity getEntity()
      Description copied from class: EntityEvent
      Returns the Entity involved in this event
      Overrides:
      getEntity in class EntityEvent
      Returns:
      Entity who is involved in this event
    • getCause Link icon

      @NotNull public EntityKnockbackEvent.KnockbackCause getCause()
      Gets the cause of the knockback.
      Returns:
      the cause of the knockback
    • getForce Link icon

      public double getForce()
      Gets the raw force of the knockback.
      This value is based on factors such as the Enchantment.KNOCKBACK level of an attacker and the Attribute.GENERIC_KNOCKBACK_RESISTANCE of the entity.
      Returns:
      the knockback force
    • getKnockback Link icon

      @NotNull public Vector getKnockback()
      Gets the raw knockback force that will be applied to the entity.
      This value is read-only, changes made to it will not have any effect on the final knockback received.
      Returns:
      the raw knockback
      See Also:
    • getFinalKnockback Link icon

      @NotNull public Vector getFinalKnockback()
      Gets the force that will be applied to the entity.
      In contrast to getKnockback() this value is affected by the entities current velocity and whether they are touching the ground.

      Note: this method returns a copy, changes must be applied with setFinalKnockback(Vector).

      Returns:
      the final knockback
    • setFinalKnockback Link icon

      @NotNull public void setFinalKnockback(@NotNull Vector knockback)
      Sets the force that will be applied to the entity.
      Parameters:
      knockback - the force to apply
    • isCancelled Link icon

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if this event is cancelled
    • setCancelled Link icon

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.
      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - true if you wish to cancel this event
    • getHandlers Link icon

      @NotNull public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList Link icon

      @NotNull public static HandlerList getHandlerList()