API reference / @jsprismarine/prismarine / entity/Damage
entity/Damage
Interfaces
Mitigation
Defined in: packages/prismarine/src/entity/Damage.ts:102
What the damage pipeline knows about the entity being hit.
Properties
bypassesArmor
bypassesArmor:
boolean
Defined in: packages/prismarine/src/entity/Damage.ts:118
Whether the cause ignores armor points.
bypassesEnchantments
bypassesEnchantments:
boolean
Defined in: packages/prismarine/src/entity/Damage.ts:120
Whether it ignores the enchantments on that armor too.
defensePoints
defensePoints:
number
Defined in: packages/prismarine/src/entity/Damage.ts:104
Armor points worn, out of twenty.
enchantmentProtection
enchantmentProtection:
number
Defined in: packages/prismarine/src/entity/Damage.ts:114
The Enchantment Protection Factor of everything worn, already summed.
The total of every minecraft:damage_protection effect component that answered this particular blow; see enchantmentProtection in src/enchantment/mitigation.ts, which is what works it out.
resistance
resistance:
number
Defined in: packages/prismarine/src/entity/Damage.ts:116
The level of the Resistance effect, or zero.
toughness
toughness:
number
Defined in: packages/prismarine/src/entity/Damage.ts:106
Armor toughness, which only diamond and netherite have.
Variables
INVULNERABILITY_TICKS
constINVULNERABILITY_TICKS:10=10
Defined in: packages/prismarine/src/entity/Damage.ts:99
Ticks of grace after a hit lands, during which a weaker one is ignored.
Half a second, as in vanilla, and it is what stops a mob standing in a cactus from dying in a fifth of a second - or two players from trading twenty hits a second. A harder blow still gets through while it runs, for the difference.
Functions
armorFactor()
armorFactor(
damage,defensePoints,toughness):number
Defined in: packages/prismarine/src/entity/Damage.ts:159
The fraction of a blow armor lets through, which depends on how hard the blow is.
Parameters
damage
number
The blow, in half-hearts.
defensePoints
number
Armor points worn; at or below zero everything gets through.
toughness
number
Armor toughness.
Returns
number
The factor, from 0.2 to 1.
armorReduced()
armorReduced(
damage,defensePoints,toughness):number
Defined in: packages/prismarine/src/entity/Damage.ts:149
What armor leaves of a blow.
Parameters
damage
number
The blow, in half-hearts.
defensePoints
number
Armor points worn.
toughness
number
Armor toughness.
Returns
number
What gets through.
Example
// A full set of iron, against a hard hit.
armorReduced(10, 15, 0); // => 4.6bypassesArmor()
bypassesArmor(
cause):boolean
Defined in: packages/prismarine/src/entity/Damage.ts:128
Whether armor points are any use against this kind of damage.
Parameters
cause
What did the damage.
Returns
boolean
true if the armor step should be skipped.
bypassesEnchantments()
bypassesEnchantments(
cause):boolean
Defined in: packages/prismarine/src/entity/Damage.ts:135
Whether the enchantments on that armor are any use either.
Parameters
cause
What did the damage.
Returns
boolean
true if the protection step should be skipped.
protectionFactor()
protectionFactor(
enchantmentProtection):number
Defined in: packages/prismarine/src/entity/Damage.ts:186
The fraction of a blow the damage_protection enchantments let through.
Parameters
enchantmentProtection
number
The summed Enchantment Protection Factor.
Returns
number
The factor, from 0.2 to 1.
protectionReduced()
protectionReduced(
damage,enchantmentProtection):number
Defined in: packages/prismarine/src/entity/Damage.ts:178
What the damage_protection enchantments leave of what armor let through.
Which enchantments contributed, and how much each one was worth, is decided by their files rather than here: this is only Java's CombatRules arithmetic over whatever total they came to.
Parameters
damage
number
What armor let through.
enchantmentProtection
number
The summed Enchantment Protection Factor.
Returns
number
What gets through.
reduceDamage()
reduceDamage(
damage,mitigation):number
Defined in: packages/prismarine/src/entity/Damage.ts:222
The whole reduction, in vanilla's order.
Parameters
damage
number
The raw blow, in half-hearts.
mitigation
What the entity is wearing and under.
Returns
number
What reaches the entity's health, never below zero.
resistanceFactor()
resistanceFactor(
level):number
Defined in: packages/prismarine/src/entity/Damage.ts:209
The fraction of a blow the Resistance effect lets through.
Parameters
level
number
The effect's level; five and above stops everything.
Returns
number
The factor, from 0 to 1.
resistanceReduced()
resistanceReduced(
damage,level):number
Defined in: packages/prismarine/src/entity/Damage.ts:197
What the Resistance effect leaves.
Parameters
damage
number
What the armor left.
level
number
The effect's level; five and above stops everything.
Returns
number
What gets through.