Class AbstractDamageEntityEvent
- java.lang.Object
- 
- org.spongepowered.api.event.impl.AbstractEvent
- 
- org.spongepowered.api.event.impl.entity.AbstractModifierEvent<DamageFunction,DamageModifier>
- 
- org.spongepowered.api.event.impl.entity.AbstractDamageEntityEvent
 
 
 
- 
- All Implemented Interfaces:
- Cancellable,- DamageEntityEvent,- Event
 
 public abstract class AbstractDamageEntityEvent extends AbstractModifierEvent<DamageFunction,DamageModifier> implements DamageEntityEvent 
- 
- 
Field SummaryFields Modifier and Type Field Description protected doublebaseDamageprotected doubleoriginalDamageprotected List<DamageFunction>originalFunctions- 
Fields inherited from class org.spongepowered.api.event.impl.entity.AbstractModifierEventmodifierFunctions, modifiers, originalFinalAmount, originalModifierMap, originalModifiers
 - 
Fields inherited from class org.spongepowered.api.event.impl.AbstractEventcurrentOrder
 
- 
 - 
Constructor SummaryConstructors Constructor Description AbstractDamageEntityEvent()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDamageModifierBefore(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> before)Adds the providedDamageModifierandDoubleUnaryOperatorto the list of modifiers, such that theSetcontainingDamageModifierTypes provided inbeforewill appear after the provided damage modifier.voidaddModifierAfter(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> after)Adds the providedDamageModifierandDoubleUnaryOperatorto the list of modifiers, such that the modifier will appear in order after any current modifiers whose type are included in the providedSetofDamageModifierTypes.doublebaseDamage()Gets the "base" damage to deal to the targetedEntity.protected DamageFunctionconvertTuple(DamageModifier obj, DoubleUnaryOperator function)doubledamage(DamageModifier damageModifier)Gets the damage for the providedDamageModifier.doublefinalDamage()Gets the final damage that will be passed into the proceedingDamageEntityEvent.protected voidinit()Called once all fields have been set by the generated constructor in a subclass.booleanisModifierApplicable(DamageModifier damageModifier)Checks whether the providedDamageModifieris applicable to the current availableDamageModifiers.List<DamageFunction>modifiers()Gets the modifiers affecting this event.Map<DamageModifier,Double>originalDamages()Gets anImmutableMapof all originalDamageModifiers and their associated "modified" damage.doubleoriginalFinalDamage()Gets the original "final" amount of damage after all originalDamageModifiers are applied toDamageEntityEvent.originalDamage().doubleoriginalModifierDamage(DamageModifier damageModifier)Gets the original damage for the providedDamageModifier.voidsetBaseDamage(double baseDamage)Sets the "base" damage to deal to the targetedEntity.voidsetDamage(DamageModifier damageModifier, DoubleUnaryOperator function)Sets the providedDamageFunctionto be used for the givenDamageModifier.booleanwillCauseDeath()Returns whether or not this event will cause the entity to die if the event is not cancelled.- 
Methods inherited from class org.spongepowered.api.event.impl.entity.AbstractModifierEventfinalAmount, init, recalculateDamages
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.spongepowered.api.event.CancellableisCancelled, setCancelled
 - 
Methods inherited from interface org.spongepowered.api.event.entity.DamageEntityEvententity, originalDamage, originalFunctions
 
- 
 
- 
- 
- 
Field Detail- 
originalDamageprotected double originalDamage 
 - 
originalFunctionsprotected List<DamageFunction> originalFunctions 
 - 
baseDamageprotected double baseDamage 
 
- 
 - 
Method Detail- 
initprotected 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 class- AbstractEvent
 
 - 
originalModifierDamagepublic final double originalModifierDamage(DamageModifier damageModifier) Description copied from interface:DamageEntityEventGets the original damage for the providedDamageModifier. If the providedDamageModifierwas not included inDamageEntityEvent.originalDamages(), anIllegalArgumentExceptionis thrown.- Specified by:
- originalModifierDamagein interface- DamageEntityEvent
- Parameters:
- damageModifier- The original damage modifier
- Returns:
- The original damage change
 
 - 
originalFinalDamagepublic final double originalFinalDamage() Description copied from interface:DamageEntityEventGets the original "final" amount of damage after all originalDamageModifiers are applied toDamageEntityEvent.originalDamage(). The "final" damage is considered the amount of health being lost by theEntity, if health is tracked.- Specified by:
- originalFinalDamagein interface- DamageEntityEvent
- Returns:
- The final amount of damage to originally deal
 
 - 
originalDamagespublic final Map<DamageModifier,Double> originalDamages() Description copied from interface:DamageEntityEventGets anImmutableMapof all originalDamageModifiers and their associated "modified" damage. Note that ordering is not retained.- Specified by:
- originalDamagesin interface- DamageEntityEvent
- Returns:
- An immutable map of the original modified damages
 
 - 
finalDamagepublic final double finalDamage() Description copied from interface:DamageEntityEventGets the final damage that will be passed into the proceedingDamageEntityEvent. The final damage is the end result of theDamageEntityEvent.baseDamage()being applied inDoubleUnaryOperator.applyAsDouble(double)available from all theTuples ofDamageModifiertoDamageFunctioninDamageEntityEvent.originalFunctions().- Specified by:
- finalDamagein interface- DamageEntityEvent
- Returns:
- The final damage to deal
 
 - 
isModifierApplicablepublic final boolean isModifierApplicable(DamageModifier damageModifier) Description copied from interface:DamageEntityEventChecks whether the providedDamageModifieris applicable to the current availableDamageModifiers.- Specified by:
- isModifierApplicablein interface- DamageEntityEvent
- Parameters:
- damageModifier- The damage modifier to check
- Returns:
- True if the damage modifier is relevant to this event
 
 - 
damagepublic final double damage(DamageModifier damageModifier) Description copied from interface:DamageEntityEventGets the damage for the providedDamageModifier. Providing thatDamageEntityEvent.isModifierApplicable(DamageModifier)returnstrue, the cached "damage" for theDamageModifieris returned.- Specified by:
- damagein interface- DamageEntityEvent
- Parameters:
- damageModifier- The damage modifier to get the damage for
- Returns:
- The modifier
 
 - 
setDamagepublic final void setDamage(DamageModifier damageModifier, DoubleUnaryOperator function) Description copied from interface:DamageEntityEventSets the providedDamageFunctionto be used for the givenDamageModifier. If theDamageModifieris already included inDamageEntityEvent.modifiers(), theDoubleUnaryOperatorreplaces the existing function. If there is noTuplefor theDamageModifier, a new one is created and added to the end of the list ofDoubleUnaryOperators to be applied to theDamageEntityEvent.baseDamage().If needing to create a custom DamageModifieris required, usage of theDamageModifier.Builderis recommended.- Specified by:
- setDamagein interface- DamageEntityEvent
- Parameters:
- damageModifier- The damage modifier
- function- The function to map to the modifier
 
 - 
addDamageModifierBeforepublic void addDamageModifierBefore(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> before) Description copied from interface:DamageEntityEventAdds the providedDamageModifierandDoubleUnaryOperatorto the list of modifiers, such that theSetcontainingDamageModifierTypes provided inbeforewill appear after the provided damage modifier.- Specified by:
- addDamageModifierBeforein interface- DamageEntityEvent
- Parameters:
- damageModifier- The damage modifier to add
- function- The associated function
- before- The set containing the modifier types to come after the provided modifier
 
 - 
addModifierAfterpublic void addModifierAfter(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> after) Description copied from interface:DamageEntityEventAdds the providedDamageModifierandDoubleUnaryOperatorto 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:
- addModifierAfterin interface- DamageEntityEvent
- Parameters:
- damageModifier- The damage modifier to add
- function- The associated function
- after- The set of modifier types to come before the new modifier
 
 - 
convertTupleprotected DamageFunction convertTuple(DamageModifier obj, DoubleUnaryOperator function) - Specified by:
- convertTuplein class- AbstractModifierEvent<DamageFunction,DamageModifier>
 
 - 
modifierspublic List<DamageFunction> modifiers() Description copied from class:AbstractModifierEventGets the modifiers affecting this event.- Specified by:
- modifiersin interface- DamageEntityEvent
- Overrides:
- modifiersin class- AbstractModifierEvent<DamageFunction,DamageModifier>
- Returns:
- The list of modifiers
 
 - 
baseDamagepublic double baseDamage() Description copied from interface:DamageEntityEventGets the "base" damage to deal to the targetedEntity. The "base" damage is the original value before passing along the chain ofDamageFunctions for all knownDamageModifiers.- Specified by:
- baseDamagein interface- DamageEntityEvent
- Returns:
- The base damage
 
 - 
setBaseDamagepublic final void setBaseDamage(double baseDamage) Description copied from interface:DamageEntityEventSets the "base" damage to deal to the targetedEntity. The "base" damage is the original value before passing along the chain ofDamageFunctions for all knownDamageModifiers.- Specified by:
- setBaseDamagein interface- DamageEntityEvent
- Parameters:
- baseDamage- The base damage
 
 - 
willCauseDeathpublic boolean willCauseDeath() Description copied from interface:DamageEntityEventReturns whether or not this event will cause the entity to die if the event is not cancelled. Only supported for living entities, returns false ifDamageEntityEvent.entity()is not a living entity.- Specified by:
- willCauseDeathin interface- DamageEntityEvent
- Returns:
- Whether the entity will die
 
 
- 
 
-