public abstract class AbstractAttackEntityEvent extends AbstractModifierEvent<DamageFunction,DamageModifier> implements AttackEntityEvent
Modifier and Type | Field and Description |
---|---|
protected double |
baseDamage |
protected double |
originalDamage |
protected List<DamageFunction> |
originalFunctions |
modifierFunctions, modifiers, originalFinalAmount, originalModifierMap, originalModifiers
currentOrder
ABSORPTION, BOOTS, CHESTPLATE, CREATOR, GENERAL_ARMOR, HARD_HAT_ARMOR, HELMET, LEGGINGS, NOTIFIER, RESISTANCE, SHIELD, SOURCE
Constructor and Description |
---|
AbstractAttackEntityEvent() |
Modifier and Type | Method and Description |
---|---|
void |
addDamageModifierAfter(DamageModifier damageModifier,
DoubleUnaryOperator function,
Set<DamageModifierType> after)
Adds the provided
DamageModifier and Function 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 DamageModifierType s. |
void |
addDamageModifierBefore(DamageModifier damageModifier,
DoubleUnaryOperator function,
Set<DamageModifierType> before)
Adds the provided
DamageModifier and Function to the
list of modifiers, such that the Set containing
DamageModifierType s provided in before will appear
after the provided damage modifier. |
protected DamageFunction |
convertTuple(DamageModifier obj,
DoubleUnaryOperator function) |
double |
getBaseOutputDamage()
Gets the "base" damage to deal to the targeted
Entity . |
double |
getFinalOutputDamage()
Gets the final damage that will be passed into the proceeding
AttackEntityEvent . |
List<DamageFunction> |
getModifiers()
Gets the modifiers affecting this event.
|
Map<DamageModifier,Double> |
getOriginalDamages()
Gets an
ImmutableMap of all original DamageModifier s
and their associated "modified" damage. |
double |
getOriginalFinalDamage()
Gets the original "final" amount of damage after all original
DamageModifier s are applied to AttackEntityEvent.getOriginalDamage() . |
double |
getOriginalModifierDamage(DamageModifier damageModifier)
Gets the original damage for the provided
DamageModifier . |
double |
getOutputDamage(DamageModifier damageModifier)
Gets the 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 DamageModifier s. |
void |
setBaseOutputDamage(double baseDamage)
Sets the "base" damage to deal to the targeted
Entity . |
void |
setOutputDamage(DamageModifier damageModifier,
DoubleUnaryOperator function)
Sets the provided
Function to be used for the given
DamageModifier . |
getFinalAmount, init, recalculateDamages
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getKnockbackModifier, getOriginalDamage, getOriginalFunctions, setKnockbackModifier
getTargetEntity
getCause, getContext, getSource
isCancelled, setCancelled
protected double originalDamage
protected List<DamageFunction> originalFunctions
protected double baseDamage
protected final void init()
AbstractEvent
This method should be used to initialize any fields that depend on parameters passed to the constructor.
init
in class AbstractEvent
public final double getOriginalModifierDamage(DamageModifier damageModifier)
AttackEntityEvent
DamageModifier
. If
the provided DamageModifier
was not included in
AttackEntityEvent.getOriginalDamages()
, an IllegalArgumentException
is
thrown.getOriginalModifierDamage
in interface AttackEntityEvent
damageModifier
- The original damage modifierpublic final double getOriginalFinalDamage()
AttackEntityEvent
DamageModifier
s are applied to AttackEntityEvent.getOriginalDamage()
.
The "final" damage is considered the amount of health being lost by
the Entity
, if health is tracked.getOriginalFinalDamage
in interface AttackEntityEvent
public final Map<DamageModifier,Double> getOriginalDamages()
AttackEntityEvent
ImmutableMap
of all original DamageModifier
s
and their associated "modified" damage. Note that ordering is not
retained.getOriginalDamages
in interface AttackEntityEvent
public final double getFinalOutputDamage()
AttackEntityEvent
AttackEntityEvent
. The final damage is the end result of the
AttackEntityEvent.getBaseOutputDamage()
being applied in Function.apply(Object)
available from all the Tuple
s of DamageModifier
to
Function
in AttackEntityEvent.getOriginalFunctions()
.getFinalOutputDamage
in interface AttackEntityEvent
public final boolean isModifierApplicable(DamageModifier damageModifier)
AttackEntityEvent
DamageModifier
is applicable to the
current available DamageModifier
s.isModifierApplicable
in interface AttackEntityEvent
damageModifier
- The damage modifier to checkpublic final double getOutputDamage(DamageModifier damageModifier)
AttackEntityEvent
DamageModifier
. Providing that
AttackEntityEvent.isModifierApplicable(DamageModifier)
returns true
,
the cached "damage" for the DamageModifier
is returned.getOutputDamage
in interface AttackEntityEvent
damageModifier
- The damage modifier to get the damage forpublic final void setOutputDamage(DamageModifier damageModifier, DoubleUnaryOperator function)
AttackEntityEvent
Function
to be used for the given
DamageModifier
. If the DamageModifier
is already
included in AttackEntityEvent.getModifiers()
, the Function
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 Function
s to be applied to the
AttackEntityEvent.getBaseOutputDamage()
.
If needing to create a custom DamageModifier
is required,
usage of the
DamageModifier.Builder
is recommended.
setOutputDamage
in interface AttackEntityEvent
damageModifier
- The damage modifierfunction
- The function to map to the modifierpublic void addDamageModifierBefore(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> before)
AttackEntityEvent
DamageModifier
and Function
to the
list of modifiers, such that the Set
containing
DamageModifierType
s provided in before
will appear
after the provided damage modifier.addDamageModifierBefore
in interface AttackEntityEvent
damageModifier
- The damage modifier to addfunction
- The associated functionbefore
- The set containing the modifier types to come after
the provided modifierpublic void addDamageModifierAfter(DamageModifier damageModifier, DoubleUnaryOperator function, Set<DamageModifierType> after)
AttackEntityEvent
DamageModifier
and Function
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 DamageModifierType
s.addDamageModifierAfter
in interface AttackEntityEvent
damageModifier
- The damage modifier to addfunction
- The associated functionafter
- The set of modifier types to come before the new modifierpublic double getBaseOutputDamage()
AttackEntityEvent
Entity
. The
"base" damage is the original value before passing along the chain of
Function
s for all known DamageModifier
s.getBaseOutputDamage
in interface AttackEntityEvent
public final void setBaseOutputDamage(double baseDamage)
AttackEntityEvent
Entity
. The
"base" damage is the original value before passing along the chain of
Function
s for all known DamageModifier
s.setBaseOutputDamage
in interface AttackEntityEvent
baseDamage
- The base damageprotected DamageFunction convertTuple(DamageModifier obj, DoubleUnaryOperator function)
convertTuple
in class AbstractModifierEvent<DamageFunction,DamageModifier>
public List<DamageFunction> getModifiers()
AbstractModifierEvent
getModifiers
in interface AttackEntityEvent
getModifiers
in class AbstractModifierEvent<DamageFunction,DamageModifier>