Damage (v0.2.0)#
Caution
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 |
Description |
---|---|
|
Applies damage from the score |
|
Does the same as |
|
Does the same as |
|
Does the same as |
#smithed.damage:entity/apply*
#
Note, the interface for all of the functions above are the same
Input Name |
Input Type |
Input Source |
Input Objective/Path |
---|---|---|---|
'Amount of damage' |
score |
@s |
smithed.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 resistancefunction #smithed.damage:entity/apply/explosion
: Respects the same asarmor
, but blast protection as wellfunction #smithed.damage:entity/apply/projectile
: Respects the same asarmor
, 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
execute
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": [
"example:damage_event"
]
}