Interface PlayerAttackEntityEvent

All Superinterfaces:
Cancellable, Event, PlayerEvent

public interface PlayerAttackEntityEvent extends PlayerEvent, Cancellable
Fired when a player swings at an entity, before any damage is applied.
Since:
0.1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Returns the attack cooldown charge of this swing, between 0 and 1.
    float
    Returns the damage about to be dealt, in half-hearts, cooldown, critical hit, smash attack and enchantments already applied.
    boolean
    Returns true when this swing landed as a critical hit.
    boolean
    Returns true when this swing is a smash attack of a mace.
    boolean
    Returns true when this swing also hits the entities around the target.
    double
    Returns the extra knockback strength the swing adds to the push every hit gives.
    void
    setDamage(float damage)
    Changes the damage about to be dealt.
    void
    setKnockback(double knockback)
    Changes the extra knockback of the swing.
    void
    setSweeping(boolean sweeping)
    Keeps the swing on its target, or lets it sweep.
    Returns the entity being hit.
    Returns the item the player swings, ItemStack.EMPTY for a bare hand.

    Methods inherited from interface Cancellable

    isCancelled, setCancelled

    Methods inherited from interface PlayerEvent

    player
  • Method Details

    • target

      Entity target()
      Returns the entity being hit.
      Returns:
      the entity being hit
      Since:
      0.1.0
    • weapon

      ItemStack weapon()
      Returns the item the player swings, ItemStack.EMPTY for a bare hand.
      Returns:
      the item the player swings, ItemStack.EMPTY for a bare hand
      Since:
      0.1.0
    • damage

      float damage()
      Returns the damage about to be dealt, in half-hearts, cooldown, critical hit, smash attack and enchantments already applied.
      Returns:
      the damage about to be dealt, in half-hearts, cooldown, critical hit, smash attack and enchantments already applied
      Since:
      0.1.0
    • setDamage

      void setDamage(float damage)
      Changes the damage about to be dealt.
      Parameters:
      damage - the damage to deal instead; <= 0 makes the hit harmless
      Since:
      0.1.0
    • knockback

      double knockback()
      Returns the extra knockback strength the swing adds to the push every hit gives.
      Returns:
      the extra knockback strength the swing adds to the push every hit gives
      Since:
      0.1.0
    • setKnockback

      void setKnockback(double knockback)
      Changes the extra knockback of the swing.
      Parameters:
      knockback - the extra knockback to apply instead; 0 keeps only the push every hit gives
      Since:
      0.1.0
    • attackStrength

      float attackStrength()
      Returns the attack cooldown charge of this swing, between 0 and 1.
      Returns:
      the attack cooldown charge of this swing, between 0 and 1
      Since:
      0.1.0
    • isCritical

      boolean isCritical()
      Returns true when this swing landed as a critical hit.
      Returns:
      true when this swing landed as a critical hit
      Since:
      0.1.0
    • isSmash

      boolean isSmash()
      Returns true when this swing is a smash attack of a mace.
      Returns:
      true when this swing is a smash attack of a mace
      Since:
      0.1.0
    • isSweeping

      boolean isSweeping()
      Returns true when this swing also hits the entities around the target.
      Returns:
      true when this swing also hits the entities around the target
      Since:
      0.1.0
    • setSweeping

      void setSweeping(boolean sweeping)
      Keeps the swing on its target, or lets it sweep.
      Parameters:
      sweeping - false to keep the hit on the primary target only
      Since:
      0.1.0