public abstract class AbstractDamageEntityEvent extends AbstractModifierEvent<DamageFunction,DamageModifier> implements DamageEntityEvent
| Modifier and Type | Field and Description |
|---|---|
protected double |
baseDamage |
protected double |
originalDamage |
protected List<DamageFunction> |
originalFunctions |
modifierFunctions, modifiers, originalFinalAmount, originalModifierMap, originalModifierscurrentOrder| Constructor and Description |
|---|
AbstractDamageEntityEvent() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDamageModifierBefore(DamageModifier damageModifier,
DoubleUnaryOperator function,
Set<DamageModifierType> before)
Adds the provided
DamageModifier and DoubleUnaryOperator to the
list of modifiers, such that the Set containing
DamageModifierTypes provided in before will appear
after the provided damage modifier. |
void |
addModifierAfter(DamageModifier damageModifier,
DoubleUnaryOperator function,
Set<DamageModifierType> after)
Adds the provided
DamageModifier and DoubleUnaryOperator to the list
of modifiers, such that the modifier will appear in order after any
current modifiers whose type are included in the provided Set of
DamageModifierTypes. |
protected DamageFunction |
convertTuple(DamageModifier obj,
DoubleUnaryOperator function) |
double |
getBaseDamage()
Gets the "base" damage to deal to the targeted
Entity. |
double |
getDamage(DamageModifier damageModifier)
Gets the damage for the provided
DamageModifier. |
double |
getFinalDamage()
Gets the final damage that will be passed into the proceeding
DamageEntityEvent. |
List<DamageFunction> |
getModifiers()
Gets the modifiers affecting this event.
|
Map<DamageModifier,Double> |
getOriginalDamages()
Gets an
ImmutableMap of all original DamageModifiers
and their associated "modified" damage. |
double |
getOriginalFinalDamage()
Gets the original "final" amount of damage after all original
DamageModifiers are applied to DamageEntityEvent.getOriginalDamage(). |
double |
getOriginalModifierDamage(DamageModifier damageModifier)
Gets the original damage for the provided
DamageModifier. |
protected void |
init()
Called once all fields have been set by the generated
constructor in a subclass.
|
boolean |
isModifierApplicable(DamageModifier damageModifier)
Checks whether the provided
DamageModifier is applicable to the
current available DamageModifiers. |
void |
setBaseDamage(double baseDamage)
Sets the "base" damage to deal to the targeted
Entity. |
void |
setDamage(DamageModifier damageModifier,
DoubleUnaryOperator function)
Sets the provided
DamageFunction to be used for the given
DamageModifier. |
boolean |
willCauseDeath()
Returns whether or not this event will cause the entity to die if the
event is not cancelled.
|
getFinalAmount, init, recalculateDamagesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetOriginalDamage, getOriginalFunctionsgetTargetEntitygetCause, getContext, getSourceisCancelled, setCancelledprotected double originalDamage
protected List<DamageFunction> originalFunctions
protected double baseDamage
protected final void init()
AbstractEventThis method should be used to initialize any fields that depend on parameters passed to the constructor.
init in class AbstractEventpublic final double getOriginalModifierDamage(DamageModifier damageModifier)
DamageEntityEventDamageModifier. If
the provided DamageModifier was not included in
DamageEntityEvent.getOriginalDamages(), an IllegalArgumentException is
thrown.getOriginalModifierDamage in interface DamageEntityEventdamageModifier - The original damage modifierpublic final double getOriginalFinalDamage()
DamageEntityEventDamageModifiers are applied to DamageEntityEvent.getOriginalDamage().
The "final" damage is considered the amount of health being lost by
the Entity, if health is tracked.getOriginalFinalDamage in interface DamageEntityEventpublic final Map<DamageModifier,Double> getOriginalDamages()
DamageEntityEventImmutableMap of all original DamageModifiers
and their associated "modified" damage. Note that ordering is not
retained.getOriginalDamages in interface DamageEntityEventpublic final double getFinalDamage()
DamageEntityEventDamageEntityEvent. The final damage is the end result of the
DamageEntityEvent.getBaseDamage() being applied in DoubleUnaryOperator.applyAsDouble(double)
available from all the Tuples of DamageModifier to
DamageFunction in DamageEntityEvent.getOriginalFunctions().getFinalDamage in interface DamageEntityEventpublic final boolean isModifierApplicable(DamageModifier damageModifier)
DamageEntityEventDamageModifier is applicable to the
current available DamageModifiers.isModifierApplicable in interface DamageEntityEventdamageModifier - The damage modifier to checkpublic final double getDamage(DamageModifier damageModifier)
DamageEntityEventDamageModifier. Providing that
DamageEntityEvent.isModifierApplicable(DamageModifier) returns true,
the cached "damage" for the DamageModifier is returned.getDamage in interface DamageEntityEventdamageModifier - The damage modifier to get the damage forpublic final void setDamage(DamageModifier damageModifier, DoubleUnaryOperator function)
DamageEntityEventDamageFunction to be used for the given
DamageModifier. If the DamageModifier is already
included in DamageEntityEvent.getModifiers(), the DoubleUnaryOperator replaces
the existing function. If there is no Tuple for the
DamageModifier, a new one is created and added to the end
of the list of DoubleUnaryOperators to be applied to the
DamageEntityEvent.getBaseDamage().
If needing to create a custom DamageModifier is required,
usage of the DamageModifier.Builder is recommended.
setDamage in interface DamageEntityEventdamageModifier - The damage modifierfunction - The function to map to the modifierpublic void addDamageModifierBefore(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> before)
DamageEntityEventDamageModifier and DoubleUnaryOperator to the
list of modifiers, such that the Set containing
DamageModifierTypes provided in before will appear
after the provided damage modifier.addDamageModifierBefore in interface DamageEntityEventdamageModifier - The damage modifier to addfunction - The associated functionbefore - The set containing the modifier types to come after
the provided modifierpublic void addModifierAfter(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> after)
DamageEntityEventDamageModifier and DoubleUnaryOperator to the list
of modifiers, such that the modifier will appear in order after any
current modifiers whose type are included in the provided Set of
DamageModifierTypes.addModifierAfter in interface DamageEntityEventdamageModifier - The damage modifier to addfunction - The associated functionafter - The set of modifier types to come before the new modifierprotected DamageFunction convertTuple(DamageModifier obj, DoubleUnaryOperator function)
convertTuple in class AbstractModifierEvent<DamageFunction,DamageModifier>public List<DamageFunction> getModifiers()
AbstractModifierEventgetModifiers in interface DamageEntityEventgetModifiers in class AbstractModifierEvent<DamageFunction,DamageModifier>public double getBaseDamage()
DamageEntityEventEntity. The
"base" damage is the original value before passing along the chain of
DamageFunctions for all known DamageModifiers.getBaseDamage in interface DamageEntityEventpublic final void setBaseDamage(double baseDamage)
DamageEntityEventEntity. The
"base" damage is the original value before passing along the chain of
DamageFunctions for all known DamageModifiers.setBaseDamage in interface DamageEntityEventbaseDamage - The base damagepublic boolean willCauseDeath()
DamageEntityEventTargetEntityEvent.getTargetEntity() is not a living entity.willCauseDeath in interface DamageEntityEvent