Class AbstractAttackEntityEvent
java.lang.Object
org.spongepowered.api.event.impl.AbstractEvent
org.spongepowered.api.event.impl.entity.AbstractModifierEvent<DamageFunction,DamageModifier>
org.spongepowered.api.event.impl.entity.AbstractAttackEntityEvent
- All Implemented Interfaces:
Cancellable,AttackEntityEvent,Event
public abstract class AbstractAttackEntityEvent
extends AbstractModifierEvent<DamageFunction,DamageModifier>
implements AttackEntityEvent
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleprotected doubleprotected List<DamageFunction> Fields inherited from class org.spongepowered.api.event.impl.entity.AbstractModifierEvent
modifierFunctions, modifiers, originalFinalAmount, originalModifierMap, originalModifiersFields inherited from class org.spongepowered.api.event.impl.AbstractEvent
currentOrderFields inherited from interface org.spongepowered.api.event.entity.AttackEntityEvent
ABSORPTION, BOOTS, CHESTPLATE, CREATOR, GENERAL_ARMOR, HARD_HAT_ARMOR, HELMET, LEGGINGS, NOTIFIER, RESISTANCE, SHIELD, SOURCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDamageModifierAfter(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> after) Adds the providedDamageModifierandFunctionto the list of modifiers, such that the modifier will appear in order after any current modifiers whose type are included in the providedSetofDamageModifierTypes.voidaddDamageModifierBefore(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> before) Adds the providedDamageModifierandFunctionto the list of modifiers, such that theSetcontainingDamageModifierTypes provided inbeforewill appear after the provided damage modifier.doubleGets the "base" damage to deal to the targetedEntity.protected DamageFunctionconvertTuple(DamageModifier obj, DoubleUnaryOperator function) final doubleGets the final damage that will be passed into the proceedingAttackEntityEvent.protected final voidinit()Called once all fields have been set by the generated constructor in a subclass.final booleanisModifierApplicable(DamageModifier damageModifier) Checks whether the providedDamageModifieris applicable to the current availableDamageModifiers.Gets the modifiers affecting this event.final Map<DamageModifier, Tuple<Double, Double>> Gets an immutableMapof all originalDamageModifiers and their associated "modified" damage.final doubleGets the original "final" amount of damage after all originalDamageModifiers are applied toAttackEntityEvent.originalDamage().originalModifierDamage(DamageModifier damageModifier) Gets the original damage for the providedDamageModifier.outputDamage(DamageModifier damageModifier) Gets the damage for the providedDamageModifier.final voidsetBaseOutputDamage(double baseDamage) Sets the "base" damage to deal to the targetedEntity.final voidsetOutputDamage(DamageModifier damageModifier, DoubleUnaryOperator function) Sets the providedFunctionto be used for the givenDamageModifier.Methods inherited from class org.spongepowered.api.event.impl.entity.AbstractModifierEvent
finalAmount, finalAmounts, init, recalculateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.spongepowered.api.event.entity.AttackEntityEvent
entity, knockbackModifier, originalDamage, originalFunctions, setKnockbackModifierMethods inherited from interface org.spongepowered.api.event.Cancellable
isCancelled, setCancelled
-
Field Details
-
originalDamage
protected double originalDamage -
originalFunctions
-
baseDamage
protected double baseDamage
-
-
Constructor Details
-
AbstractAttackEntityEvent
public AbstractAttackEntityEvent()
-
-
Method Details
-
init
protected final void init()Description copied from class:AbstractEventCalled once all fields have been set by the generated constructor in a subclass.This method should be used to initialize any fields that depend on parameters passed to the constructor.
- Overrides:
initin classAbstractEvent
-
originalModifierDamage
Description copied from interface:AttackEntityEventGets the original damage for the providedDamageModifier. If the providedDamageModifierwas not included inAttackEntityEvent.originalDamages(), anIllegalArgumentExceptionis thrown.- Specified by:
originalModifierDamagein interfaceAttackEntityEvent- Parameters:
damageModifier- The original damage modifier- Returns:
- The original damage change
-
originalFinalDamage
public final double originalFinalDamage()Description copied from interface:AttackEntityEventGets the original "final" amount of damage after all originalDamageModifiers are applied toAttackEntityEvent.originalDamage(). The "final" damage is considered the amount of health being lost by theEntity, if health is tracked.- Specified by:
originalFinalDamagein interfaceAttackEntityEvent- Returns:
- The final amount of damage to originally deal
-
originalDamages
Description copied from interface:AttackEntityEventGets an immutableMapof all originalDamageModifiers and their associated "modified" damage. Note that ordering is not retained.- Specified by:
originalDamagesin interfaceAttackEntityEvent- Returns:
- An immutable map of the original modified damages
-
finalOutputDamage
public final double finalOutputDamage()Description copied from interface:AttackEntityEventGets the final damage that will be passed into the proceedingAttackEntityEvent. The final damage is the end result of theAttackEntityEvent.baseOutputDamage()being applied inFunction.apply(Object)available from all theTuples ofDamageModifiertoFunctioninAttackEntityEvent.originalFunctions().- Specified by:
finalOutputDamagein interfaceAttackEntityEvent- Returns:
- The final damage to deal
-
isModifierApplicable
Description copied from interface:AttackEntityEventChecks whether the providedDamageModifieris applicable to the current availableDamageModifiers.- Specified by:
isModifierApplicablein interfaceAttackEntityEvent- Parameters:
damageModifier- The damage modifier to check- Returns:
- True if the damage modifier is relevant to this event
-
outputDamage
Description copied from interface:AttackEntityEventGets the damage for the providedDamageModifier. Providing thatAttackEntityEvent.isModifierApplicable(DamageModifier)returnstrue, the cached "damage" for theDamageModifieris returned.- Specified by:
outputDamagein interfaceAttackEntityEvent- Parameters:
damageModifier- The damage modifier to get the damage for- Returns:
- The modifier
-
setOutputDamage
Description copied from interface:AttackEntityEventSets the providedFunctionto be used for the givenDamageModifier. If theDamageModifieris already included inAttackEntityEvent.modifiers(), theFunctionreplaces the existing function. If there is noTuplefor theDamageModifier, a new one is created and added to the end of the list ofFunctions to be applied to theAttackEntityEvent.baseOutputDamage().If needing to create a custom
DamageModifieris required, usage of theDamageModifier.Builderis recommended.- Specified by:
setOutputDamagein interfaceAttackEntityEvent- Parameters:
damageModifier- The damage modifierfunction- The function to map to the modifier
-
addDamageModifierBefore
public void addDamageModifierBefore(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> before) Description copied from interface:AttackEntityEventAdds the providedDamageModifierandFunctionto the list of modifiers, such that theSetcontainingDamageModifierTypes provided inbeforewill appear after the provided damage modifier.- Specified by:
addDamageModifierBeforein interfaceAttackEntityEvent- Parameters:
damageModifier- The damage modifier to addfunction- The associated functionbefore- The set containing the modifier types to come after the provided modifier
-
addDamageModifierAfter
public void addDamageModifierAfter(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> after) Description copied from interface:AttackEntityEventAdds the providedDamageModifierandFunctionto the list of modifiers, such that the modifier will appear in order after any current modifiers whose type are included in the providedSetofDamageModifierTypes.- Specified by:
addDamageModifierAfterin interfaceAttackEntityEvent- Parameters:
damageModifier- The damage modifier to addfunction- The associated functionafter- The set of modifier types to come before the new modifier
-
baseOutputDamage
public double baseOutputDamage()Description copied from interface:AttackEntityEventGets the "base" damage to deal to the targetedEntity. The "base" damage is the original value before passing along the chain ofFunctions for all knownDamageModifiers.- Specified by:
baseOutputDamagein interfaceAttackEntityEvent- Returns:
- The base damage
-
setBaseOutputDamage
public final void setBaseOutputDamage(double baseDamage) Description copied from interface:AttackEntityEventSets the "base" damage to deal to the targetedEntity. The "base" damage is the original value before passing along the chain ofFunctions for all knownDamageModifiers.- Specified by:
setBaseOutputDamagein interfaceAttackEntityEvent- Parameters:
baseDamage- The base damage
-
convertTuple
- Specified by:
convertTuplein classAbstractModifierEvent<DamageFunction,DamageModifier>
-
modifiers
Description copied from class:AbstractModifierEventGets the modifiers affecting this event.- Specified by:
modifiersin interfaceAttackEntityEvent- Overrides:
modifiersin classAbstractModifierEvent<DamageFunction,DamageModifier> - Returns:
- The list of modifiers
-