Applies a set amount of damage to the specified entities.
Usage[]
This command does not simply change a entity health value. Instead, it directly calls the underlying logic in the game to simulate the situation of causing damage to the entity. So this command has many undefined behaviors.
The output text, result, and return value of the damage command are not related to whether the health value is changed. In fact, they are undefined.
The amount: int
is not the final amount of reduced health value. The reduced health value is usually less than or greater than the amount: int
due to world difficulty, armors, status effects, or the target entity itself, etc.
When damaged, the entity may react accordingly, such as being knocked back, becoming angry, etc. The damager entity may also react in certain ways, such as the arrow's disappearing.
Undefined behaviors may be changed at any time without warning. When this happens, your addons or maps may cease to work. Use these undefined behaviors at your own risk.
Hardcoded reaction
- Mobs
- Knocked back.
- Get into invulnerable cooldown period.
- etc.
- Balloon
- Damaged with an source entity, the balloon swings.
- Bat
- When damaged, sleeping bat begins flying.
- Ender crystal
- Controlled by dragon fight system.
- Enderman
- Teleports away.
- Guardian
- While its spikes are extended, if the damager is a mob and the cause isn't
magic
,block_explosion
, orprojectile
, it deals thorn damage on the damager. - Horse
- Opens mouth.
- Shulker
- Teleport somewhere.
- Squid
- If source is entity, spawns ink particles.
Hardcoded behaviors
When amount: int
is 0, entities are always considered successfully damaged. If not 0, only entities (except armor stand, npc, camera), boats, painting, leash knot, falling block and minecarts may be recognized as successfully damaged.
Some behaviors are data driven (e.g. ender crystal's explosion, fireball's rebounding). These data driven behaviors have no effect on damage command's output text, result, and return value. Only hardcoded behaviors can affect them.
- Player
- Players in creative mode can only be damaged with the "falling out of the world" damage type.
- Agent
- Hardcoded behavior:
/kill
command can always kill the agent.- Side effect: Damage command with the cause of
suicide
always removes the agent, regardless of whetheramount: int
is 0 or not.
- Side effect: Damage command with the cause of
- Armor Stand
- Clicking the armor stand is not considered as hurting it.
- Applying
/damage
command on an armor stand cannot reduce its health value (except forfire
andfire_tick
causes), and is never considered to have damaged it successfully. It also cannot be detected or controlled with behavior packs.
- Applying
- Double-punching an armor stand in Survival mode destroys it.
- Running
/damage
twice within 5 gameticks on an armor stand with the damager being a player in survival mode makes the armor stand drop its held items and destroy itself.
- Running
- Punching an armor stand in creative mode removes it.
- Running
/damage
on an armor stand with the damager being a player in creative mode removes it.
- Running
- Explosions can always destroy the armor stand. The
/kill
command can always kill the armor stand./damage
commands with the cause ofsuicide
,block_explosion
, orentity_explosion
makes the armor stand drop its held items and destroy itself.
- Void damage can always kill the armor stand.
/damage
commands with thevoid
cause always remove the armor stand.
- Armor stands are set on fire when in lava or fire.
/damage
commands with thefire
cause sets the armor stand on fire and reduces its health value by 0.5.
- Armor stands are damaged when on fire.
- If cause is
fire
, and the armor stand is not in a lava or fire block,/damage
commands reduce its health value by 1.0.
- If cause is
- If an arrow hit an armor stand, the armor stand will be destroyed and the arrow will also disappear.
- Running
/damage
commands on an armor stand with the source being an arrow causes the armor stand to be destroyed and the arrow disappeared.
- Running
- If an trident hit an armor stand, the armor stand will be destroyed.
- Running
/damage
commands on an armor stand with the source being a trident causes the armor stand to be destroyed.
- Running
- When a armor stand falls onto the ground, a landing sound is played.
- Broadcasts landing sound when a armor stand is damaged with the
fall
cause.
- Broadcasts landing sound when a armor stand is damaged with the
- Balloon
- Hardcoded behavior: Clicking balloon isn't considered as hurting it.
- Side effect: Running damage command on a balloon cannot reduce its health value, and is never considered to have successfully damaged it.
- Hardcoded behavior: Projectile, fire, lava and magma can always destroy the balloon. kill command can always kill the balloon.
- Side effect: Damage command with the cause of
suicide
,projectile
,fire
,fire_tick
,lava
, ormagma
destroys the balloon.
- Side effect: Damage command with the cause of
- Boat
- Hardcoded behavior: Clicking boat is always considered as hurting it.
- Side effect: Running damage command on a boat is always considered to have successfully damaged it. But it cannot be detected or controlled with behavior packs.
- Hardcoded behavior: Boat uses Structural Integrity to control whether it should break or not, instead of health points. A boat has 40 points of Structural Integrity.
- Damage command changes its Structural Integrity value, instead of its health value.
- Hardcoded behavior: Unknown
- Side effect: Applying damage command on a boat with the damager being an enderpearl, the boat's Structural Integrity is reduced, but isn't destroyed even if Structural Integrity becomes less than 0.
- Hardcoded behavior: Clicking a boat in creative mode means removing it.
- Side effect: Running damage command on a boat with the damager being a player in creative mode can remove the boat, regardless of whether
amount: int
is 0 or not.
- Side effect: Running damage command on a boat with the damager being a player in creative mode can remove the boat, regardless of whether
- End Crystal
- Hardcoded behavior: Hurting an end crystal means make it exploding.
- Side effect: Running damage command on an end crystal makes it exploding, regardless of whether
amount: int
is 0 or not, and is never[verify] considered to have successfully damaged it.
- Side effect: Running damage command on an end crystal makes it exploding, regardless of whether
- Ender Dragon
- Hardcoded behavior: Ender dragon is immune to arrows when perching, and makes arrows on fire.
- Side effect: Damage command with source being an arrow cannot hurt a perching dragon, but makes the arrow on fire. And isn't considered successfull.
- Hardcoded behavior: Damage command with
suffocation
can't hurt an ender dragon and is considered unsuccessfull. - Hardcoded behavior: Only players can hurt ender dragon.
- Side effect: Only with source being player, or cause being
block_explosion
can hurt it and can be detected or controlled with behavior packs.
- Side effect: Only with source being player, or cause being
- Hardcoded behavior:
/kill
command can always kill the ender dragon.- Side effect: Damage command with the cause of
suicide
always kills the ender dragon and is considered successful, regardless of whetheramount: int
is 0 or not.
- Side effect: Damage command with the cause of
- Enderman
- Hardcoded behavior: Projectiles except potions cannot hurt enderman.
- Side effect: If cause is
projectile
and source is not a potion entity, damage command makes the enderman teleport away without hurt, and it cannot be detected or controlled with behavior packs. Only if the enderman has successfully teleported away, is it considered to have successfully damaged it.
- Side effect: If cause is
- Experience orb
- Hardcoded behavior: Player can't hurt it.
- Side effect: Running damage command on an exp orb can reduce its health value, but is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.
- Falling block
- Hardcoded behavior: Unknown
- Undefined behavior: Applying damage command on a falling block that is falling is always considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.
- Undefined behavior: Applying damage command on a falling block with the source being
piston
always destroys it, and drops item of the block that the falling block is in (instead of what block the falling block is).
- Ghast
- Hardcoded behavior: A fireball deals 1000 damage to a ghast if the fireball was rebounded by a player.
- Side effect: Running damage command on a ghast with the damager is a fireball that has been hit by player, deals 1000 damage, regardless of what
amount: int
is. And it cannot be detected or controlled with behavior packs.
- Side effect: Running damage command on a ghast with the damager is a fireball that has been hit by player, deals 1000 damage, regardless of what
- Painting and leash knot
- Hardcoded behavior: Hitting them can destroy them.
- Side effect: Painting and lead knot are always destroyed when applying damage command on them, and drop item if the damager is not a player in creative mode. It is always considered to have successfully damaged it, regardless of whether
amount: int
is 0 or not. But it cannot be detected or controlled with behavior packs.
- Side effect: Painting and lead knot are always destroyed when applying damage command on them, and drop item if the damager is not a player in creative mode. It is always considered to have successfully damaged it, regardless of whether
- Item
- Hardcoded behavior: Player can't hurt it.
- Side effect: Applying damage command on an item can reduce its health value, but is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.
- Minecart
- Hardcoded behavior: Clicking minecart is always considered as hurting it.
- Side effect: Running damage command on a minecart is always considered to have successfully damaged it.
- Hardcoded behavior: Minecart uses Structural Integrity to control whether it should break or not, instead health value. A minecart has 5 Structural Integrity.
- Damage command changes its Structural Integrity value, instead of its health value.
- Enderpearl can reduce minecart's Structural Integrity, but cannot make it destroyed.
- Hardcoded behavior: Unknown
- Side effect: Applying damage command on a minecart with the damager being an enderpearl, the minecart's Structural Integrity is reduced, but isn't destroyed even if Structural Integrity becomes less than 0.
- TNT minecart
- Damage command with cause being
projectile
and source being an arrow that is on fire, or a small fire ball, or cause beingfire
orlava
, primes the tnt minecart and is considered successfull. But it is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs. - Otherwise, it behaviors as minecart.
- NPC
- Hardcoded behavior: NPC cannot be hurt.
- Side effect: Using damage command on an NPC is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.
- Hardcoded behavior: only void, kill command, or world builder can remove it.
- Side effect: If the cause being
void
orsuicide
, or the cause beingentity_attack
and the source being a world builder, damage command removes the NPC, otherwise does nothing.
- Side effect: If the cause being
- Primed TNT
- Hardcoded behavior: Tnt cannot be hurt.
- Side effect: Using damage command on a TNT is never considered to have successfully damaged it.
- Hardcoded behavior:
/kill
command can always kill the tnt.- Side effect: Damage command with the cause of
suicide
always kills the tnt, regardless of whetheramount: int
is 0 or not.
- Side effect: Damage command with the cause of
- Skulker
- Hardcoded behavior: Shulker teleports if in lava or fire.
- Side effect: Applying damage command on a shulker with cause being
lava
orfire
can't damage it and makes the shulker teleport away. It is considered unsuccessfull, and cannot be detected or controlled with behavior packs.
- Side effect: Applying damage command on a shulker with cause being
- Hardcoded behavior: Projectile cannot hurt it when it is closed.
- Side effect: Applying damage command on a closed shulker with cause being
projectile
can't damage it. It is considered unsuccessfull, and cannot be detected or controlled with behavior packs.
- Side effect: Applying damage command on a closed shulker with cause being
- Small fireball
- Hardcoded behavior: Small fireball cannot be hit.
- Side effect: Using damage command on a small fireball is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.
- Trident
- Hardcoded behavior: Trident cannot be hurt.
- Side effect: Using damage command on a trident is never considered to have successfully damaged it.
- Defined behavior: Trident cannot be affected by explosion.
- Side effect: Using damage command on a trident with cause being
block_explosion
orentity_explosion
cannot be detected or controlled with behavior packs.
- Side effect: Using damage command on a trident with cause being
- Camera
- Hardcoded behavior: Camera cannot be hurt.
- Side effect: Using damage command on a camera is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.
- Hardcoded behavior: Trident cannot be affected by explosion.
- Side effect: Using damage command on a camera with source being a player removes it.
- Wither skull
- Hardcoded behavior: Wither skull cannot be hurt.
- Side effect: Using damage command on a wither skull is never considered to have successfully damaged it.
- Hardcoded behavior: Black wither skull cannot be hit.
- Side effect: Using damage command on a black wither skull is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.
- Wither
- Hardcoded behavior: Drowning and fall cannot hurt the wither.
- Side effect: If cause is
drowning
orfall
, damage command does nothing on the wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.
- Side effect: If cause is
- Hardcoded behavior: Wither cannot damage another wither.
- Side effect: If cause is not
suicide
and source is a wither, damage command does nothing on the wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.
- Side effect: If cause is not
- Hardcoded behavior:
- Side effect: If the wither is in spawning antimation, cause is
entity_attack
, and source is a mob, damage command makes the source mob knockbacked.
- Side effect: If the wither is in spawning antimation, cause is
- Hardcoded behavior: When spawning, the wither can't be hurt by anything, except void.
- Side effect: If the wither is spawing and source is not
void
, damage command does nothing on the wither. And it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.
- Side effect: If the wither is spawing and source is not
- Hardcoded behavior: When dying, the wither can't be hurt.
- Side effect: If the wither is dying, damage command does nothing on the wither. And it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.
- Hardcoded behavior: When having "wither armor", wither is immune to arrows.
- Side effect: If the wither is in "wither armor" state, damage command with the cause being
projectile
and the source being an arrow does nothing on the wither. And it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.
- Side effect: If the wither is in "wither armor" state, damage command with the cause being
Syntax[]
- Java Edition
damage <target> <amount> [<damageType>] [at <location>]
damage <target> <amount> [<damageType>] [by <entity>] [from <cause>]
- Bedrock Edition
damage <target: target> <amount: int> <cause: DamageCause> entity <damager: target>
damage <target: target> <amount: int> [cause: DamageCause]
Arguments[]
JE: <target>
: entity
BE: target: target
: CommandSelector<Actor>
- Specifies the entity[Java Edition only] or entities[Bedrock Edition only] to damage.
- Must be a player name, a target selector or a UUID[Java Edition only]. In Java Edition, the target selector must be in single type.
<amount>
: float
- Specifies the amount of damage to inflict.
- Must be a Single-precision floating-point format number. And it must be greater than or equal to 0.0.
amount: int
: int
- Specifies the amount of damage to inflict.
- Must be a 32-bit integer number. And it must be between 0.0 and 2147483647 (inclusive).
JE: <damageType>
: resource
BE: cause: DamageCause
: enum
- Specifies the damage type[Java Edition only] or type of damage[Bedrock Edition only]. Affects death messages and difficulty scaling, among other things.
- Must be an existing registered resource location in correct registry.
- For Bedrock Edition, all possible arguments are listed on the official add-on documentation.
Name | Description | Notes |
---|---|---|
all
|
Any damage | [more information needed] |
anvil
|
Caused by a falling anvil. Reduced damage to targets wearing a helmet. | [more information needed] |
block-explosion
|
Caused the explosion of a block | Reduced damage to targets equipped with armor, with extra reduction per tier of Blast Protection. |
charging
|
[more information needed] | [more information needed] |
contact
|
Caused by contact with a damage-inflicting block (e.g. cactus and sweet berry bushes). | Reduced damage to targets equipped with armor, with extra reduction per tier of Protection. |
drowning
|
Caused by drowning or rain. | [more information needed] |
entity-attack
|
Caused by melee attack from a mob. | Reduced damage to targets equipped with armor, with extra reduction per tier of Protection. |
entity-explosion
|
Caused by the explosion of a mob. | Reduced damage to targets equipped with armor, with extra reduction per tier of Blast Protection. |
fall
|
Caused by falling from higher ground, or teleporting by ender pearl. | Main article: Damage § Fall_damage Reduced damage to targets equipped with Feather Falling or Protection armor. Some mobs are immune to or take less damage from fall damage.
|
falling_block
|
[more information needed] | [more information needed] |
fire
|
Caused by standing in fire or lit campfire. | [more information needed] |
fire_tick
|
Caused by being on fire | Reduced damage to targets equipped with Fire Protection of Protection. Blazes, ghasts, magma cubes, withers, wither skeletons and zombified piglins are immune to burning. |
fireworks
|
Caused by a firework rocket. | [more information needed] |
fire
|
Caused by standing in fire or lit campfire. | [more information needed] |
fly_into_wall
|
Caused by collide with block when flying with an elytra. | [more information needed] |
freezing
|
Caused by standing in powder snow. | [more information needed] |
lava
|
Caused by lava. | [more information needed] |
lightning
|
Caused by lightning. | [more information needed] |
magic
|
Caused by potions, dragon breath, evocation fangs or guardians. | [more information needed] |
magma
|
Caused by magma block. | [more information needed] |
override
|
Override this entity's health value. | [more information needed] |
piston
|
Caused by piston. | [more information needed] |
projectile
|
Caused by projectile, such as arrows. | [more information needed] |
stalactite
|
Caused by stalactite. | [more information needed] |
stalagmite
|
Caused by stalagmite. | [more information needed] |
starve
|
Caused by hunger. | [more information needed] |
suffocation
|
Caused by suffocation. | [more information needed] |
suicide
|
Caused by /kill .
|
[more information needed] |
temperature
|
Snow golem damaged by biome temperature. | [more information needed] |
thorns
|
Caused by thorns. | [more information needed] |
void
|
Caused by void. | [more information needed] |
wither
|
Caused by wither. | [more information needed] |
- Specifies the location the damage originated at if the cause of the damage is not an entity (e.g., the position of the bed that exploded in the Nether).
- Must be a three-dimensional coordinates with floating-point number elements. Accepts tilde and caret notations.
JE: <entity>
: entity
BE: damager: target
: CommandSelector<Actor>
- Specifies the entity who dealt the damage.
- Must be a player name, a target selector or a UUID[Java Edition only]. In Java Edition, the target selector must be in single type.
- Specifies the cause of the damage (for example, the skeleton that shot the arrow).
- Must be a player name, a target selector or a UUID. And the target selector must be in single type.
Results[]
Command | Trigger | Bedrock Edition |
---|---|---|
any | the arguments are not specified correctly | Unparseable |
amount: int is lower than 0 | Failed | |
All the selected targets meet one or more of the following conditions:
| ||
/... entity ... | if damager: target targeting multiple targets | |
any | Otherwise | Successful |
Output[]
Command | Edition | Situation | Success Count |
---|---|---|---|
any | Bedrock Edition | On fail | 0 |
On success | the number of entities who are considered to have successfully took the damage. |
Example[]
- Make a villager named
villager_1
deal 1 damage to a nearby iron golem:/damage @e[type=iron_golem, limit=1] 1 generic by @e[type=villager, limit=1, name="villager_1"]
[Java Edition only]/damage @e[type=iron_golem, c=1] 1 entity_attack entity @e[type=villager, c=1, name="villager_1"]
[Bedrock Edition only]
History[]
Java Edition | |||||
---|---|---|---|---|---|
1.19.4 | 23w06a | Added /damage . | |||
Pre-release 2 | Striders and blazes now have a weakness to freezing damage. | ||||
Bedrock Edition | |||||
1.18.10 | beta 1.18.10.26 | Added /damage . |