Class VanillaDamageBridge
java.lang.Object
studio.magemonkey.divinity.manager.damage.VanillaDamageBridge
The one place that reads and writes the vanilla
EntityDamageEvent.DamageModifiers of an EntityDamageEvent.
This class only wraps the access with named methods. It makes no decisions: when to call which method, with which value, and under which condition is up to the caller. The order of calls matters and is kept exactly as it was before the bridge existed.
The EntityDamageEvent.DamageModifier API is deprecated by Bukkit. Keeping every use in this class is what
makes it replaceable later.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSets the vanilla armor modifier to zero, if the event has one.doubleReads the vanilla blocking modifier.doubleReads the invulnerability reduction modifier.voidoverrideBlocking(double value) Overwrites the vanilla blocking modifier with the given value, if the event has one.voidsetBaseDamage(double damage) Writes the BASE modifier.voidsettleFinalDamage(org.bukkit.entity.LivingEntity victim) Makes the vanilla event's final damage follow Divinity's value in BASE, after the calculation.
-
Constructor Details
-
VanillaDamageBridge
public VanillaDamageBridge(@NotNull org.bukkit.event.entity.EntityDamageEvent event)
-
-
Method Details
-
disableVanillaArmor
public void disableVanillaArmor()Sets the vanilla armor modifier to zero, if the event has one. -
getBlockingDamage
public double getBlockingDamage()Reads the vanilla blocking modifier. It is negative when vanilla let a shield block the hit. -
overrideBlocking
public void overrideBlocking(double value) Overwrites the vanilla blocking modifier with the given value, if the event has one. -
getInvulnerabilityReduction
public double getInvulnerabilityReduction()Reads the invulnerability reduction modifier. Returns 0 where the modifier does not exist (it is missing on some versions) or is not applicable to this event. -
setBaseDamage
public void setBaseDamage(double damage) Writes the BASE modifier. -
settleFinalDamage
public void settleFinalDamage(@NotNull org.bukkit.entity.LivingEntity victim) Makes the vanilla event's final damage follow Divinity's value in BASE, after the calculation.Does nothing when the final damage already equals BASE. Otherwise every applicable modifier is rewritten: BASE keeps its value, ABSORPTION is set to what the victim's absorption hearts can take, INVULNERABILITY_REDUCTION and RESISTANCE are left alone, and all others are zeroed.
- Parameters:
victim- the victim, whose absorption amount is read once the final damage is known to differ.
-