Damage (v0.2.0)#


This library is deprecated as of Minecraft 1.20 with the introduction of the /damage command.

This library implements complex damage calculation math in order to emulate applying damage to both players and entities

Library Function



Applies damage from the score @s smithed.damage directly to the hp of the entity of @s


Does the same as entity/apply except respects armor values


Does the same as entity/apply/armor except respects Blast Protection enchantments


Does the same as entity/apply/armor except respects Projectil Protection enchantments


Note, the interface for all of the functions above are the same

Input Name

Input Type

Input Source

Input Objective/Path

'Amount of damage'




This function applies the specified amount of damage in half-hearts to the executing entity.

scoreboard players set @s smithed.damage 3    # Does 1.5 damage (3 half-hearts)
function #smithed.damage:entity/apply         # Apply the damage

To apply damage that respects armor, use their specific commands:

  • function #smithed.damage:entity/apply/armor: Respects armor, protection, and resistance

  • function #smithed.damage:entity/apply/explosion: Respects the same as armor, but blast protection as well

  • function #smithed.damage:entity/apply/projectile: Respects the same as armor, but projectile protection as well

Custom Death Messages Events#

Damage Events#

Player damage events happen when a player is damaged. You can add damage events by adding your function to the tag #smithed.damage:event/player/on_damage.
This library tracks the type of damage dealt to the player and stores it as a string in data storage smithed.damage:main io.damage.type. The following damage types are as follows:

  • 'generic'

  • 'bypass_armor'

  • 'bypasses_invulnerability'

  • 'bypasses_magic'

  • 'is_explosion'

  • 'is_fire'

  • 'is_lightning'

  • 'is_magic'

Example Implementation#

function: example:damage_event

# give players with the fireproof tag fire resistance if they took damage by fire
  if entity @s[tag=fireproof]
  if data storage smithed.damage:main {io.damage.type: 'is_fire'}
  run effect give @s fire_resistance 10 0 true

tag: #smithed.damage:event/player/on_damage

  "values": [