public abstract class AbstractAttackEntityEvent extends AbstractEvent implements InteractEntityEvent.Attack
InteractEntityEvent.Attack, InteractEntityEvent.Use
Modifier and Type | Field and Description |
---|---|
protected double |
baseDamage |
protected double |
finalDamage |
protected LinkedHashMap<DamageModifier,Function<? super Double,Double>> |
modifierFunctions |
protected LinkedHashMap<DamageModifier,Double> |
modifiers |
protected double |
originalDamage |
protected Map<DamageModifier,Double> |
originalDamages |
protected double |
originalFinalDamage |
protected List<Tuple<DamageModifier,Function<? super Double,Double>>> |
originalFunctions |
protected Map<DamageModifier,Double> |
originalModifiers |
callbacks
Constructor and Description |
---|
AbstractAttackEntityEvent() |
Modifier and Type | Method and Description |
---|---|
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<Tuple<DamageModifier,Function<? super Double,Double>>> |
getModifiers()
|
double |
getOriginalDamage()
Gets the original "raw" amount of damage to deal to the targeted
Entity . |
Map<DamageModifier,Double> |
getOriginalDamages()
Gets an immutable
Map 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 InteractEntityEvent.Attack.getOriginalDamage() . |
List<Tuple<DamageModifier,Function<? super Double,Double>>> |
getOriginalFunctions()
|
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 DamageModifier s. |
void |
setBaseDamage(double baseDamage)
Sets the "base" damage to deal to the targeted
Entity . |
void |
setDamage(DamageModifier damageModifier,
Function<? super Double,Double> function)
Sets the provided
Function to be used for the given
DamageModifier . |
getCallbacks
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInteractionPoint
isCancelled, setCancelled
getCause
getTargetEntity
getCallbacks
protected double originalDamage
protected List<Tuple<DamageModifier,Function<? super Double,Double>>> originalFunctions
protected double originalFinalDamage
protected Map<DamageModifier,Double> originalModifiers
protected final LinkedHashMap<DamageModifier,Double> modifiers
protected final LinkedHashMap<DamageModifier,Function<? super Double,Double>> modifierFunctions
protected double baseDamage
protected double finalDamage
protected Map<DamageModifier,Double> originalDamages
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 getOriginalDamage()
InteractEntityEvent.Attack
Entity
.getOriginalDamage
in interface InteractEntityEvent.Attack
public final double getOriginalModifierDamage(DamageModifier damageModifier)
InteractEntityEvent.Attack
DamageModifier
. If
the provided DamageModifier
was not included in
InteractEntityEvent.Attack.getOriginalDamages()
, an IllegalArgumentException
is thrown.getOriginalModifierDamage
in interface InteractEntityEvent.Attack
damageModifier
- The original damage modifierpublic final Map<DamageModifier,Double> getOriginalDamages()
InteractEntityEvent.Attack
Map
of all original
DamageModifier
s and their associated "modified" damage. Note
that ordering is not retained.getOriginalDamages
in interface InteractEntityEvent.Attack
public final List<Tuple<DamageModifier,Function<? super Double,Double>>> getOriginalFunctions()
InteractEntityEvent.Attack
getOriginalFunctions
in interface InteractEntityEvent.Attack
public final double getOriginalFinalDamage()
InteractEntityEvent.Attack
DamageModifier
s are applied to InteractEntityEvent.Attack.getOriginalDamage()
.
The "final" damage is considered the amount of health being lost by
the Entity
, if health is tracked.getOriginalFinalDamage
in interface InteractEntityEvent.Attack
public final double getBaseDamage()
InteractEntityEvent.Attack
Entity
. The
"base" damage is the original value before passing along the chain
of Function
s for all known DamageModifier
s.getBaseDamage
in interface InteractEntityEvent.Attack
public final void setBaseDamage(double baseDamage)
InteractEntityEvent.Attack
Entity
. The
"base" damage is the original value before passing along the chain
of Function
s for all known DamageModifier
s.setBaseDamage
in interface InteractEntityEvent.Attack
baseDamage
- The base damagepublic final double getFinalDamage()
InteractEntityEvent.Attack
DamageEntityEvent
. The final damage is the end result of the
InteractEntityEvent.Attack.getBaseDamage()
being applied in
Function.apply(Object)
available from all the Tuple
s
of DamageModifier
to Function
in
InteractEntityEvent.Attack.getOriginalFunctions()
.getFinalDamage
in interface InteractEntityEvent.Attack
public final boolean isModifierApplicable(DamageModifier damageModifier)
InteractEntityEvent.Attack
DamageModifier
is applicable to
the current available DamageModifier
s.isModifierApplicable
in interface InteractEntityEvent.Attack
damageModifier
- The damage modifier to checkpublic final double getDamage(DamageModifier damageModifier)
InteractEntityEvent.Attack
DamageModifier
. Providing
that InteractEntityEvent.Attack.isModifierApplicable(DamageModifier)
returns
true
, the cached "damage" for the
DamageModifier
is returned.getDamage
in interface InteractEntityEvent.Attack
damageModifier
- The damage modifier to get the damage forpublic final void setDamage(DamageModifier damageModifier, Function<? super Double,Double> function)
InteractEntityEvent.Attack
Function
to be used for the given
DamageModifier
. If the DamageModifier
is already
included in InteractEntityEvent.Attack.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
InteractEntityEvent.Attack.getBaseDamage()
.
If needing to create a custom DamageModifier
is required,
usage of the DamageModifierBuilder
is recommended.
setDamage
in interface InteractEntityEvent.Attack
damageModifier
- The damage modifierfunction
- The function to map to the modifierpublic final List<Tuple<DamageModifier,Function<? super Double,Double>>> getModifiers()
InteractEntityEvent.Attack
Tuple
s of DamageModifier
keyed
to their representative Function
s. All
DamageModifier
s are applicable to the entity based on the
DamageSource
and any possible invulnerabilities due to the
DamageSource
.getModifiers
in interface InteractEntityEvent.Attack