Interface PlayerAttackEntityEvent
- All Superinterfaces:
Cancellable, Event, PlayerEvent
Fired when a player swings at an entity, before any damage is applied.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionfloatReturns the attack cooldown charge of this swing, between0and1.floatdamage()Returns the damage about to be dealt, in half-hearts, cooldown, critical hit, smash attack and enchantments already applied.booleanReturnstruewhen this swing landed as a critical hit.booleanisSmash()Returnstruewhen this swing is a smash attack of a mace.booleanReturnstruewhen this swing also hits the entities around the target.doubleReturns the extra knockback strength the swing adds to the push every hit gives.voidsetDamage(float damage) Changes the damage about to be dealt.voidsetKnockback(double knockback) Changes the extra knockback of the swing.voidsetSweeping(boolean sweeping) Keeps the swing on its target, or lets it sweep.target()Returns the entity being hit.weapon()Returns the item the player swings,ItemStack.EMPTYfor a bare hand.Methods inherited from interface Cancellable
isCancelled, setCancelledMethods inherited from interface PlayerEvent
player
-
Method Details
-
target
-
weapon
ItemStack weapon()Returns the item the player swings,ItemStack.EMPTYfor a bare hand.- Returns:
- the item the player swings,
ItemStack.EMPTYfor 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;<= 0makes 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;0keeps only the push every hit gives- Since:
- 0.1.0
-
attackStrength
float attackStrength()Returns the attack cooldown charge of this swing, between0and1.- Returns:
- the attack cooldown charge of this swing, between
0and1 - Since:
- 0.1.0
-
isCritical
boolean isCritical()Returnstruewhen this swing landed as a critical hit.- Returns:
truewhen this swing landed as a critical hit- Since:
- 0.1.0
-
isSmash
boolean isSmash()Returnstruewhen this swing is a smash attack of a mace.- Returns:
truewhen this swing is a smash attack of a mace- Since:
- 0.1.0
-
isSweeping
boolean isSweeping()Returnstruewhen this swing also hits the entities around the target.- Returns:
truewhen 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-falseto keep the hit on the primary target only- Since:
- 0.1.0
-