Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/damage: Difference between revisions

From SAS Gaming Wiki
imported>Dxsarster
m Hardcoded behaviors: Mistake saying that creative mode is immune to all damage types which is very much not true
 
SyncBot (talk | contribs)
Remove broken links to missing pages
Line 11: Line 11:
{{cmd|damage}} applies damage to entities with health or an equivalent statistic. The <code><damageType></code>{{only|java|short=1}} or <code>cause: DamageType</code>{{only|bedrock|short=1}} argument is used to specify the kind of damage which will be applied to the entity.
{{cmd|damage}} applies damage to entities with health or an equivalent statistic. The <code><damageType></code>{{only|java|short=1}} or <code>cause: DamageType</code>{{only|bedrock|short=1}} argument is used to specify the kind of damage which will be applied to the entity.


When being applied to an applicable entity, {{cmd|damage}} uses the same underlying logic when applying damage as is used elsewhere in the game. As such, the damage specified by the <code><damageType></code>{{only|java|short=1}} or <code>cause: DamageType</code>{{only|bedrock|short=1}}  argument is not the exact amount of damage which will be applied to the entity. The resulting damage is affected by statistics which would otherwise modify or nullify said damage based on the damage source and type of damage (for instance players in [[Minecraft:creative mode]] are invulnerable to most types of damage, and damage types categorized as fire damage will be nullified by [[Minecraft:fire resistance]] and weakened by [[Minecraft:fire protection]]). Entities will also react to damage inflicted by {{cmd|damage}} in the same manner they would if said damage was inflicted through normal means (for instance, [[Minecraft:endermen]] will teleport away if the damage source is categorized as a projectile).
When being applied to an applicable entity, {{cmd|damage}} uses the same underlying logic when applying damage as is used elsewhere in the game. As such, the damage specified by the <code><damageType></code>{{only|java|short=1}} or <code>cause: DamageType</code>{{only|bedrock|short=1}}  argument is not the exact amount of damage which will be applied to the entity. The resulting damage is affected by statistics which would otherwise modify or nullify said damage based on the damage source and type of damage (for instance players in creative mode are invulnerable to most types of damage, and damage types categorized as fire damage will be nullified by fire resistance and weakened by fire protection). Entities will also react to damage inflicted by {{cmd|damage}} in the same manner they would if said damage was inflicted through normal means (for instance, endermen will teleport away if the damage source is categorized as a projectile).


===Undefined behavior===
===Undefined behavior===
Line 31: Line 31:
|-
|-
| {{EntityLink|End Crystal}}
| {{EntityLink|End Crystal}}
| Controlled by the [[Minecraft:Ender Dragon]]'s fight system.
| Controlled by the Ender Dragon's fight system.
|-
|-
| {{EntityLink|Enderman}}
| {{EntityLink|Enderman}}
Line 47: Line 47:


===Hardcoded behaviors===
===Hardcoded behaviors===
When {{cd|amount: int}} is 0, entities are always considered successfully damaged. If not 0, only entities (except [[Minecraft:armor stands]], [[Minecraft:NPC|NPCs]], and [[Minecraft:camera]]), [[Minecraft:boats]], [[Minecraft:paintings]], [[Minecraft:leash knot|leash knots]], [[Minecraft:falling blocks]], and [[Minecraft:minecarts]] may be recognized as successfully damaged.
When {{cd|amount: int}} is 0, entities are always considered successfully damaged. If not 0, only entities (except armor stands, [[Minecraft:NPC|NPCs]], and [[Minecraft:camera]]), boats, paintings, leash knots, falling blocks, and minecarts may be recognized as successfully damaged.


Some behaviors are data-driven (e.g. [[Minecraft:end crystal]] explosion, [[Minecraft:fireball]] rebounding). These data-driven behaviors do not affect the command's output text, result, and return value. Only hardcoded behaviors can affect them.
Some behaviors are data-driven (e.g. end crystal explosion, fireball rebounding). These data-driven behaviors do not affect the command's output text, result, and return value. Only hardcoded behaviors can affect them.


{| class="wikitable sortable" data-description="Hardcoded behavior"
{| class="wikitable sortable" data-description="Hardcoded behavior"
Line 56: Line 56:
|-
|-
| {{EntityLink|Player}}
| {{EntityLink|Player}}
| Players in Creative mode are invulnerable by most types of damage excluding {{Code|generic_kill}} and {{Code|out_of_world}} (refer to [[Minecraft:damage types]])
| Players in Creative mode are invulnerable by most types of damage excluding {{Code|generic_kill}} and {{Code|out_of_world}} (refer to damage types)
|-
|-
| {{EntityLink|Agent}}{{only|education|bedrock|short=1}}
| {{EntityLink|Agent}}{{only|education|bedrock|short=1}}
Line 62: Line 62:
|-
|-
| {{EntityLink|Armor Stand}}
| {{EntityLink|Armor Stand}}
| Applying {{cmd|damage}} command on an armor stand cannot reduce its health value (except for {{cd|fire}} and {{cd|fire_tick}} causes), and is never considered to have damaged it successfully. It also cannot be detected or controlled with [[Minecraft:behavior packs]].
| Applying {{cmd|damage}} command on an armor stand cannot reduce its health value (except for {{cd|fire}} and {{cd|fire_tick}} causes), and is never considered to have damaged it successfully. It also cannot be detected or controlled with behavior packs.


Punching an armor stand is not considered as having damaged it.
Punching an armor stand is not considered as having damaged it.
Line 110: Line 110:
| Punching a boat is always considered as hurting it.
| Punching a boat is always considered as hurting it.


Running {{cmd|damage}} on a boat is always considered to have successfully damaged it, but it cannot be detected or controlled with [[Minecraft:behavior packs]].
Running {{cmd|damage}} on a boat is always considered to have successfully damaged it, but it cannot be detected or controlled with behavior packs.


Boat uses Structural Integrity instead of health points to control whether it should break or not. A boat has 40 points of Structural Integrity.
Boat uses Structural Integrity instead of health points to control whether it should break or not. A boat has 40 points of Structural Integrity.
Line 116: Line 116:
Damage command changes its Structural Integrity value instead of its health value.
Damage command changes its Structural Integrity value instead of its health value.


When applying {{cmd|damage}} on a boat with the damage source being an [[Minecraft:ender pearl]], the boat's Structural Integrity is reduced, but isn't destroyed even if Structural Integrity becomes less than 0.
When applying {{cmd|damage}} on a boat with the damage source being an ender pearl, the boat's Structural Integrity is reduced, but isn't destroyed even if Structural Integrity becomes less than 0.


Punching a boat in Creative mode destroys it.
Punching a boat in Creative mode destroys it.
Line 125: Line 125:
| A camera cannot be damaged.
| A camera cannot be damaged.


Using {{cmd|damage}} on a camera is never considered to have successfully damaged it and cannot be detected or controlled with [[Minecraft:behavior packs]].
Using {{cmd|damage}} on a camera is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.


A camera cannot be affected by an explosion.
A camera cannot be affected by an explosion.
Line 145: Line 145:
Only players can hurt an ender dragon.
Only players can hurt an ender dragon.


Only a player as the source, or the {{cd|block_explosion}} as a cause, can hurt an ender dragon and can be detected or controlled with [[Minecraft:behavior packs]].
Only a player as the source, or the {{cd|block_explosion}} as a cause, can hurt an ender dragon and can be detected or controlled with behavior packs.


{{cmd|kill}} can always kill an ender dragon.
{{cmd|kill}} can always kill an ender dragon.
Line 152: Line 152:
|-
|-
| {{EntityLink|Enderman}}
| {{EntityLink|Enderman}}
| Projectiles, except [[Minecraft:potions]], cannot hurt an enderman.
| Projectiles, except potions, cannot hurt an enderman.


If the cause is {{cd|projectile}} and the source is not a potion entity, {{cmd|damage}} makes an enderman teleport away without being hurt, and it cannot be detected or controlled with [[Minecraft:behavior packs]]. If the enderman has successfully teleported away, the command is considered to have successfully damaged the entity.
If the cause is {{cd|projectile}} and the source is not a potion entity, {{cmd|damage}} makes an enderman teleport away without being hurt, and it cannot be detected or controlled with behavior packs. If the enderman has successfully teleported away, the command is considered to have successfully damaged the entity.
|-
|-
| {{EntityLink|Experience Orb}}
| {{EntityLink|Experience Orb}}
| A player cannot damage an experience orb.
| A player cannot damage an experience orb.


Running {{cmd|damage}} on an experience orb can reduce its health value, but is never considered to have successfully damaged it, and cannot be detected or controlled with [[Minecraft:behavior packs]].
Running {{cmd|damage}} on an experience orb can reduce its health value, but is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.
|-
|-
| {{EntityLink|Falling Block}}
| {{EntityLink|Falling Block}}
| Applying {{cmd|damage}} on a falling block is always considered to have successfully damaged it, and cannot be detected or controlled with [[Minecraft:behavior packs]].
| Applying {{cmd|damage}} on a falling block is always considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.


Applying {{cmd|damage}} on a falling block with the source being {{cd|piston}} always destroys it, and drops an item of the block that the falling block is in (instead of the item form of the falling block).
Applying {{cmd|damage}} on a falling block with the source being {{cd|piston}} always destroys it, and drops an item of the block that the falling block is in (instead of the item form of the falling block).
|-
|-
| {{EntityLink|Ghast}}
| {{EntityLink|Ghast}}
| A [[Minecraft:fireball]] deals 1000 damage to a ghast if the fireball was rebounded by a player.
| A fireball deals 1000 damage to a ghast if the fireball was rebounded by a player.


Running a damage command on a ghast with a [[Minecraft:fireball]] that has been hit by the player as the damage source deals 1000 damage, regardless of what {{cd|amount: int}} is. It cannot be detected or controlled with [[Minecraft:behavior packs]].
Running a damage command on a ghast with a fireball that has been hit by the player as the damage source deals 1000 damage, regardless of what {{cd|amount: int}} is. It cannot be detected or controlled with behavior packs.
|-
|-
| {{EntityLink|Painting}} and {{EntityLink|Leash Knot}}
| {{EntityLink|Painting}} and {{EntityLink|Leash Knot}}
| Pushing a painting or a leash knot destroys the entity.
| Pushing a painting or a leash knot destroys the entity.


Paintings and lead knots are always destroyed when applying {{cmd|damage}} on them, and drop items if the damage source is not a player in Creative mode. It is always considered to have successfully damaged it, regardless of whether {{cd|amount: int}} is 0 or not, but it cannot be detected or controlled with [[Minecraft:behavior packs]].
Paintings and lead knots are always destroyed when applying {{cmd|damage}} on them, and drop items if the damage source is not a player in Creative mode. It is always considered to have successfully damaged it, regardless of whether {{cd|amount: int}} is 0 or not, but it cannot be detected or controlled with behavior packs.
|-
|-
| {{EnvLink|Item}}
| {{EnvLink|Item}}
| A player cannot damage an item.
| A player cannot damage an item.


Applying {{cmd|damage}} on an item can reduce its health value, but is never considered to have successfully damaged it, and cannot be detected or controlled with [[Minecraft:behavior packs]].
Applying {{cmd|damage}} 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.
|-
|-
| {{EntityLink|Minecart}}
| {{EntityLink|Minecart}}
Line 190: Line 190:
{{cmd|damage}} changes a minecart's Structural Integrity value instead of its health value.
{{cmd|damage}} changes a minecart's Structural Integrity value instead of its health value.


An [[Minecraft:ender pearl]] can reduce a minecart's Structural Integrity, but cannot destroy it.
An ender pearl can reduce a minecart's Structural Integrity, but cannot destroy it.


Applying {{cmd|damage}} on a minecart with the damage source being an [[Minecraft:ender pearl]] reduces Structural Integrity, but doesn't destroy it even if its Structural Integrity becomes less than 0.
Applying {{cmd|damage}} on a minecart with the damage source being an ender pearl reduces Structural Integrity, but doesn't destroy it even if its Structural Integrity becomes less than 0.
|-
|-
| {{EntityLink|Minecart with TNT}}
| {{EntityLink|Minecart with TNT}}
| {{cmd|damage}} with the cause being {{cd|projectile}} and the damage source being an [[Minecraft:arrow]] that is on fire or a small [[Minecraft:fireball]], or with the cause being {{cd|fire}} or {{cd|lava}}, primes the minecart and is considered successful. It is never considered to have successfully damaged it, and cannot be detected or controlled with [[Minecraft:behavior packs]].
| {{cmd|damage}} with the cause being {{cd|projectile}} and the damage source being an [[Minecraft:arrow]] that is on fire or a small fireball, or with the cause being {{cd|fire}} or {{cd|lava}}, primes the minecart and is considered successful. It is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.


Otherwise behaves as a regular [[Minecraft:minecart]].
Otherwise behaves as a regular [[Minecraft:minecart]].
Line 202: Line 202:
| NPCs cannot be damaged.
| NPCs cannot be damaged.


Using {{cmd|damage}} on an NPC is never considered to have successfully damaged it, and cannot be detected or controlled with [[Minecraft:behavior packs]].
Using {{cmd|damage}} on an NPC is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.


Only [[Minecraft:void|the void]], {{cmd|kill}}, or world builder can remove it.
Only the void, {{cmd|kill}}, or world builder can remove it.


If the cause is {{cd|void}} or {{cd|self_destruct}}, or the cause is {{cd|entity_attack}} and the source is a world builder, {{cmd|damage}} removes the NPC. Otherwise, it does nothing.
If the cause is {{cd|void}} or {{cd|self_destruct}}, or the cause is {{cd|entity_attack}} and the source is a world builder, {{cmd|damage}} removes the NPC. Otherwise, it does nothing.
Line 220: Line 220:
| A shulker teleports if it is in lava or fire.
| A shulker teleports if it is in lava or fire.


Applying {{cmd|damage}} on a shulker with the cause being {{cd|lava}} or {{cd|fire}} cannot damage it and makes the shulker teleport away. It is considered unsuccessful and cannot be detected or controlled with [[Minecraft:behavior packs]].
Applying {{cmd|damage}} on a shulker with the cause being {{cd|lava}} or {{cd|fire}} cannot damage it and makes the shulker teleport away. It is considered unsuccessful and cannot be detected or controlled with behavior packs.


Projectiles cannot hurt a shulker when it is closed.
Projectiles cannot hurt a shulker when it is closed.


Applying {{cmd|damage}} on a closed shulker with the cause being {{cd|projectile}} cannot damage it. It is considered unsuccessful and cannot be detected or controlled with [[Minecraft:behavior packs]].
Applying {{cmd|damage}} on a closed shulker with the cause being {{cd|projectile}} cannot damage it. It is considered unsuccessful and cannot be detected or controlled with behavior packs.
|-
|-
| {{EntityLink|Small fireball}}
| {{EntityLink|Small fireball}}
| A small fireball cannot be hit.
| A small fireball cannot be hit.


Using {{cmd|damage}} on a small fireball is never considered to have successfully damaged it and cannot be detected or controlled with [[Minecraft:behavior packs]].
Using {{cmd|damage}} on a small fireball is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.
|-
|-
| {{EntityLink|Trident}}
| {{EntityLink|Trident}}
Line 238: Line 238:
A trident cannot be affected by an explosion.
A trident cannot be affected by an explosion.


Using {{cmd|damage}} on a trident with cause being {{cd|block_explosion}} or {{cd|entity_explosion}} cannot be detected or controlled with [[Minecraft:behavior packs]].
Using {{cmd|damage}} on a trident with cause being {{cd|block_explosion}} or {{cd|entity_explosion}} cannot be detected or controlled with behavior packs.
|-
|-
| {{EntityLink|Wither Skull}}
| {{EntityLink|Wither Skull}}
Line 247: Line 247:
A black wither skull cannot be hit.
A black wither skull cannot be hit.


Using {{cmd|damage}} on a black wither skull is never considered to have successfully damaged it and cannot be detected or controlled with [[Minecraft:behavior packs]].
Using {{cmd|damage}} on a black wither skull is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.
|-
|-
| {{EntityLink|Wither}}
| {{EntityLink|Wither}}
| Drowning and falling cannot hurt a wither.
| Drowning and falling cannot hurt a wither.


If the cause is {{cd|drowning}} or {{cd|fall}}, {{cmd|damage}} does nothing on a wither and it is not considered to have successfully damaged it. It cannot be detected or controlled with [[Minecraft:behavior packs]].
If the cause is {{cd|drowning}} or {{cd|fall}}, {{cmd|damage}} does nothing on a wither and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.


A wither cannot damage another wither.
A wither cannot damage another wither.


If the cause is not {{cd|self_destruct}} and the source is another wither, a damage command does nothing on a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with [[Minecraft:behavior packs]].
If the cause is not {{cd|self_destruct}} and the source is another wither, a damage command does nothing on a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.


If a wither is in its spawning animation, the cause is {{cd|entity_attack}}, and the source is a mob, {{cmd|damage}} makes the source mob suffer knockback.
If a wither is in its spawning animation, the cause is {{cd|entity_attack}}, and the source is a mob, {{cmd|damage}} makes the source mob suffer knockback.
Line 262: Line 262:
When spawning, a wither cannot be damaged by anything except for the void.
When spawning, a wither cannot be damaged by anything except for the void.


If a wither is spawning, and the source is not the {{cd|void}}, a damage command does nothing on the wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with [[Minecraft:behavior packs]].
If a wither is spawning, and the source is not the {{cd|void}}, a 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.


When dying, a wither cannot be damaged.
When dying, a wither cannot be damaged.


If a wither is dying, {{cmd|damage}} does nothing on a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with [[Minecraft:behavior packs]].
If a wither is dying, {{cmd|damage}} does nothing on a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.


In its armored state, a wither is immune to arrows.
In its armored state, a wither is immune to arrows.


If the wither is in its armored state, {{cmd|damage}} with the cause being {{cd|projectile}} and the damage source being an arrow does nothing to a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with [[Minecraft:behavior packs]].
If the wither is in its armored state, {{cmd|damage}} with the cause being {{cd|projectile}} and the damage source being an arrow does nothing to a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.
|}
|}


Line 386: Line 386:
|{{cd|block-explosion}}
|{{cd|block-explosion}}
|Caused by the explosion of a block.
|Caused by the explosion of a block.
|Reduced damage to targets equipped with armor, with extra reduction per tier of [[Minecraft:Blast Protection]].
|Reduced damage to targets equipped with armor, with extra reduction per tier of Blast Protection.
|-
|-
|{{cd|campfire}}
|{{cd|campfire}}
Line 398: Line 398:
|{{cd|contact}}
|{{cd|contact}}
|Caused by contact with a damage-inflicting block (e.g. cactus and sweet berry bushes).
|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 [[Minecraft:Protection]].
|Reduced damage to targets equipped with armor, with extra reduction per tier of Protection.
|-
|-
|{{cd|drowning}}
|{{cd|drowning}}
Line 406: Line 406:
|{{cd|entity-attack}}
|{{cd|entity-attack}}
|Caused by a melee attack from a mob.
|Caused by a melee attack from a mob.
|Reduced damage to targets equipped with armor, with extra reduction per tier of [[Minecraft:Protection]].
|Reduced damage to targets equipped with armor, with extra reduction per tier of Protection.
|-
|-
|{{cd|entity-explosion}}
|{{cd|entity-explosion}}
|Caused by the explosion of a mob.
|Caused by the explosion of a mob.
|Reduced damage to targets equipped with armor, with extra reduction per tier of [[Minecraft:Blast Protection]].
|Reduced damage to targets equipped with armor, with extra reduction per tier of Blast Protection.
|-
|-
|{{cd|fall}}
|{{cd|fall}}
|Caused by falling from a higher ground, or teleporting with an ender pearl.
|Caused by falling from a higher ground, or teleporting with an ender pearl.
|{{main|Damage#Fall_damage}}Reduced damage to targets equipped with [[Minecraft:Feather Falling]] or [[Minecraft:Protection]] armor. Some mobs are immune to or take less fall damage.
|{{main|Damage#Fall_damage}}Reduced damage to targets equipped with Feather Falling or Protection armor. Some mobs are immune to or take less fall damage.
|-
|-
|{{cd|falling_block}}
|{{cd|falling_block}}
Line 426: Line 426:
|{{cd|fire_tick}}
|{{cd|fire_tick}}
|Caused by being on fire.
|Caused by being on fire.
| Reduced damage to targets equipped with [[Minecraft:Fire Protection]] or [[Minecraft:Protection]]. [[Minecraft:Blaze]]s, [[Minecraft:ghast]]s, [[Minecraft:magma cube]]s, [[Minecraft:wither]]s, [[Minecraft:wither skeleton]]s and [[Minecraft:zombified piglin]]s are immune to burning.
| Reduced damage to targets equipped with Fire Protection or Protection. Blazes, ghasts, magma cubes, [[Minecraft:wither]]s, wither skeletons and zombified piglins are immune to burning.
|-
|-
|{{cd|fireworks}}
|{{cd|fireworks}}
|Caused by a [[Minecraft:firework rocket]].
|Caused by a firework rocket.
|{{info needed}}
|{{info needed}}
|-
|-
Line 437: Line 437:
|-
|-
|{{cd|freezing}}
|{{cd|freezing}}
|Caused by standing in [[Minecraft:powder snow]].  
|Caused by standing in powder snow.  
|{{info needed}}
|{{info needed}}
|-
|-
Line 445: Line 445:
|-
|-
|{{cd|lightning}}
|{{cd|lightning}}
|Caused by [[Minecraft:lightning]].
|Caused by lightning.
|{{info needed}}
|{{info needed}}
|-
|-
Line 457: Line 457:
|-
|-
|{{cd|magma}}
|{{cd|magma}}
|Caused by [[Minecraft:magma block]]s.  
|Caused by magma blocks.  
|{{info needed}}
|{{info needed}}
|-
|-
Line 473: Line 473:
|-
|-
|{{cd|projectile}}
|{{cd|projectile}}
|Caused by [[Minecraft:projectile]]s, such as arrows.
|Caused by projectiles, such as arrows.
|{{info needed}}
|{{info needed}}
|-
|-
Line 493: Line 493:
|-
|-
|{{cd|stalactite}}
|{{cd|stalactite}}
|Caused by [[Minecraft:stalactite]]s.
|Caused by stalactites.
|{{info needed}}
|{{info needed}}
|-
|-
|{{cd|stalagmite}}
|{{cd|stalagmite}}
|Caused by [[Minecraft:stalagmite]]s.
|Caused by stalagmites.
|{{info needed}}
|{{info needed}}
|-
|-
|{{cd|starve}}
|{{cd|starve}}
|Caused by [[Minecraft:hunger]].
|Caused by hunger.
|{{info needed}}
|{{info needed}}
|-
|-
|{{cd|suffocation}}
|{{cd|suffocation}}
|Caused by [[Minecraft:suffocation]].  
|Caused by suffocation.  
|{{info needed}}
|{{info needed}}
|-
|-
Line 513: Line 513:
|-
|-
|{{cd|thorns}}
|{{cd|thorns}}
|Caused by [[Minecraft:thorns]].
|Caused by thorns.
|{{info needed}}
|{{info needed}}
|-
|-
|{{cd|void}}
|{{cd|void}}
|Caused by the [[Minecraft:void]].
|Caused by the void.
|{{info needed}}
|{{info needed}}
|-
|-
Line 550: Line 550:


{{argument|damageType|resource|cause: DamageCause|enum}}
{{argument|damageType|resource|cause: DamageCause|enum}}
: Specifies the [[Minecraft:damage type]]{{only|java}} or type of damage{{only|be}}. Affects death messages and difficulty scaling, among other things.
: Specifies the damage type{{only|java}} or type of damage{{only|be}}. Affects death messages and difficulty scaling, among other things.
: {{IN|je}}, if not specified, defaults to <code>minecraft:generic</code>.
: {{IN|je}}, if not specified, defaults to <code>minecraft:generic</code>.
: {{arg desc|je=resource|registry=minecraft:damage_type}}
: {{arg desc|je=resource|registry=minecraft:damage_type}}
Line 556: Line 556:


{{el|je|short=1}}: {{argument|location|vec3}}
{{el|je|short=1}}: {{argument|location|vec3}}
: Specifies the location the damage originated at if the cause of the damage is not an entity (e.g., the position of the [[Minecraft:bed]] that exploded in the [[Minecraft:Nether]]).
: Specifies the location the damage originated at if the cause of the damage is not an entity (e.g., the position of the [[Minecraft:bed]] that exploded in the Nether).
: {{arg desc|je=vec3}}
: {{arg desc|je=vec3}}


Line 564: Line 564:


{{el|je|short=1}}: {{argument|cause|entity}}
{{el|je|short=1}}: {{argument|cause|entity}}
: Specifies the cause of the damage (for example, the [[Minecraft:skeleton]] that shot the [[Minecraft:arrow]]).
: Specifies the cause of the damage (for example, the skeleton that shot the [[Minecraft:arrow]]).
: {{arg desc|je=entity|amount=single|type=entities}}
: {{arg desc|je=entity|amount=single|type=entities}}


Line 595: Line 595:
|{{HistoryLine|java}}
|{{HistoryLine|java}}
|{{HistoryLine||1.19.4|dev=23w06a|Added {{cmd|damage|link=none}}.}}
|{{HistoryLine||1.19.4|dev=23w06a|Added {{cmd|damage|link=none}}.}}
|{{HistoryLine|||dev=Pre-release 2|[[Minecraft:Strider]]s and [[Minecraft:blaze]]s now have a weakness to freezing damage.}}
|{{HistoryLine|||dev=Pre-release 2|Striders and blazes now have a weakness to freezing damage.}}
}}
}}


Line 612: Line 612:
{{Navbox commands}}
{{Navbox commands}}


[[Minecraft:de:Befehl/damage]]
de:Befehl/damage
[[Minecraft:es:Comandos/damage]]
es:Comandos/damage
[[Minecraft:ja:コマンド/damage]]
ja:コマンド/damage
[[Minecraft:ko:명령어/damage]]
ko:명령어/damage
[[Minecraft:pt:Comandos/damage]]
pt:Comandos/damage
[[Minecraft:ru:Команды консоли/damage]]
ru:Команды консоли/damage
[[Minecraft:zh:命令/damage]]
zh:命令/damage

Revision as of 15:43, 9 April 2026

Template:Infobox command Applies a set amount of damage to the specified entities.

Usage

Template:Cmd applies damage to entities with health or an equivalent statistic. The <damageType>Template:Only or cause: DamageTypeTemplate:Only argument is used to specify the kind of damage which will be applied to the entity.

When being applied to an applicable entity, Template:Cmd uses the same underlying logic when applying damage as is used elsewhere in the game. As such, the damage specified by the <damageType>Template:Only or cause: DamageTypeTemplate:Only argument is not the exact amount of damage which will be applied to the entity. The resulting damage is affected by statistics which would otherwise modify or nullify said damage based on the damage source and type of damage (for instance players in creative mode are invulnerable to most types of damage, and damage types categorized as fire damage will be nullified by fire resistance and weakened by fire protection). Entities will also react to damage inflicted by Template:Cmd in the same manner they would if said damage was inflicted through normal means (for instance, endermen will teleport away if the damage source is categorized as a projectile).

Undefined behavior


Mob Behavior
All mobs Knocked back.

Begins an invulnerable cooldown period.

Template:EntityLinkTemplate:Only Damaged with a source entity, the balloon swings.
Template:EntityLink When damaged, a sleeping bat begins flying.
Template:EntityLink Controlled by the Ender Dragon's fight system.
Template:EntityLink Teleports away.
Template:EntityLink While its spikes are extended, if the damage source is a mob and the cause isn't Template:Cd, Template:Cd, or Template:Cd, it deals thorn damage to the damage source.
Template:EntityLink Teleports away.
Template:EntityLink If the damage source is an entity, it spawns ink particles.

Hardcoded behaviors

When Template:Cd is 0, entities are always considered successfully damaged. If not 0, only entities (except armor stands, NPCs, and Minecraft:camera), boats, paintings, leash knots, falling blocks, and minecarts may be recognized as successfully damaged.

Some behaviors are data-driven (e.g. end crystal explosion, fireball rebounding). These data-driven behaviors do not affect the command's output text, result, and return value. Only hardcoded behaviors can affect them.

Mob Behavior
Template:EntityLink Players in Creative mode are invulnerable by most types of damage excluding Template:Code and Template:Code (refer to damage types)
Template:EntityLinkTemplate:Only Template:Cmd command can always kill the agent. This has the side-effect that Template:Cmd with the cause of Template:Cd always removes the agent, regardless of whether Template:Cd is 0 or not.
Template:EntityLink Applying Template:Cmd command on an armor stand cannot reduce its health value (except for Template:Cd and Template:Cd causes), and is never considered to have damaged it successfully. It also cannot be detected or controlled with behavior packs.

Punching an armor stand is not considered as having damaged it.

Punching an armor stand twice in Survival mode destroys it.

Running Template:Cmd twice within 5 game ticks on an armor stand with the damage source being a player in Survival mode makes the armor stand drop its held items and destroy itself.

Punching an armor stand in Creative mode removes it.

Running Template:Cmd on an armor stand with the damage source being a player in Creative mode removes it.

Explosions can always destroy the armor stand. The Template:Cmd command can always kill the armor stand.

Template:Cmd commands with the cause of Template:Cd, Template:Cd, or Template:Cd make the armor stand drop its held items and destroy itself.

Void damage can always kill the armor stand.

Template:Cmd commands with the Template:Cd cause always remove the armor stand.

Armor stands are set on fire when in lava or fire.

Template:Cmd commands with the Template:Cd cause the armor stand to be set on fire and reduce its health value by 0.5.

Armor stands are damaged when on fire.

If the cause is Template:Cd, and the armor stand is not in a lava or fire block, Template:Cmd commands reduce its health value by 1.0.

If an arrow hits an armor stand, the armor stand is destroyed, and the arrow disappears.

Running Template:Cmd commands on an armor stand with the source being an arrow causes the armor stand to be destroyed and the arrow to disappear.

If a trident hits an armor stand, the armor stand is destroyed.

Running Template:Cmd commands on an armor stand with the damage source being a trident causes the armor stand to be destroyed.

When an armor stand falls onto the ground, a landing sound is played.

Broadcasts a landing sound when an armor stand is damaged with the Template:Cd cause.

Template:EntityLinkTemplate:Only Clicking a balloon isn't considered as hurting it. This has the side-effect that running Template:Cmd on a balloon cannot reduce its health value, and is never considered to have successfully damaged it.

Projectiles, fire, lava, and magma can always destroy the balloon. Template:Cmd can always kill the balloon. This has the side-effect that the damage causes Template:Cd, Template:Cd, Template:Cd, Template:Cd, Template:Cd, or Template:Cd destroy the balloon.

Template:EntityLink Punching a boat is always considered as hurting it.

Running Template:Cmd on a boat is always considered to have successfully damaged it, but it cannot be detected or controlled with behavior packs.

Boat uses Structural Integrity instead of health points to control whether it should break or not. A boat has 40 points of Structural Integrity.

Damage command changes its Structural Integrity value instead of its health value.

When applying Template:Cmd on a boat with the damage source being an ender pearl, the boat's Structural Integrity is reduced, but isn't destroyed even if Structural Integrity becomes less than 0.

Punching a boat in Creative mode destroys it.

Running Template:Cmd on a boat with the damage source being a player in Creative mode destroys the boat, regardless of whether Template:Cd is 0 or not.

Template:EntityLinkTemplate:Only A camera cannot be damaged.

Using Template:Cmd on a camera is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.

A camera cannot be affected by an explosion.

Using Template:Cmd on a camera with the source being a player removes it.

Template:EntityLink Hurting an end crystal means making it explode.

Running Template:Cmd on an end crystal makes it explode, regardless of whether Template:Cd is 0 or not, and is neverTemplate:Verify considered to have successfully damaged it.

Template:EntityLink Hardcoded behavior: An ender dragon is immune to arrows when perching, and makes arrows catch fire.

Template:Cmd with the damage source being an Minecraft:arrow cannot hurt a perching dragon, but the arrow is still set on fire despite the command not being successful.

A damage command with Template:Cd cannot hurt an ender dragon and is always considered unsuccessful.

Only players can hurt an ender dragon.

Only a player as the source, or the Template:Cd as a cause, can hurt an ender dragon and can be detected or controlled with behavior packs.

Template:Cmd can always kill an ender dragon.

A damage command with the cause of Template:Cd always kills an ender dragon and is considered successful, regardless of whether Template:Cd is 0 or not.

Template:EntityLink Projectiles, except potions, cannot hurt an enderman.

If the cause is Template:Cd and the source is not a potion entity, Template:Cmd makes an enderman teleport away without being hurt, and it cannot be detected or controlled with behavior packs. If the enderman has successfully teleported away, the command is considered to have successfully damaged the entity.

Template:EntityLink A player cannot damage an experience orb.

Running Template:Cmd on an experience orb can reduce its health value, but is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.

Template:EntityLink Applying Template:Cmd on a falling block is always considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.

Applying Template:Cmd on a falling block with the source being Template:Cd always destroys it, and drops an item of the block that the falling block is in (instead of the item form of the falling block).

Template:EntityLink A fireball deals 1000 damage to a ghast if the fireball was rebounded by a player.

Running a damage command on a ghast with a fireball that has been hit by the player as the damage source deals 1000 damage, regardless of what Template:Cd is. It cannot be detected or controlled with behavior packs.

Template:EntityLink and Template:EntityLink Pushing a painting or a leash knot destroys the entity.

Paintings and lead knots are always destroyed when applying Template:Cmd on them, and drop items if the damage source is not a player in Creative mode. It is always considered to have successfully damaged it, regardless of whether Template:Cd is 0 or not, but it cannot be detected or controlled with behavior packs.

Template:EnvLink A player cannot damage an item.

Applying Template:Cmd 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.

Template:EntityLink Punching a minecart is always considered as damaging it.

Running Template:Cmd on a minecart is always considered to have successfully damaged it.

A minecart uses Structural Integrity to control whether it should break or not, instead of its health value. A minecart has a Structural Integrity of 5.

Template:Cmd changes a minecart's Structural Integrity value instead of its health value.

An ender pearl can reduce a minecart's Structural Integrity, but cannot destroy it.

Applying Template:Cmd on a minecart with the damage source being an ender pearl reduces Structural Integrity, but doesn't destroy it even if its Structural Integrity becomes less than 0.

Template:EntityLink Template:Cmd with the cause being Template:Cd and the damage source being an Minecraft:arrow that is on fire or a small fireball, or with the cause being Template:Cd or Template:Cd, primes the minecart and is considered successful. It is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.

Otherwise behaves as a regular Minecraft:minecart.

Template:EntityLinkTemplate:Only NPCs cannot be damaged.

Using Template:Cmd on an NPC is never considered to have successfully damaged it, and cannot be detected or controlled with behavior packs.

Only the void, Template:Cmd, or world builder can remove it.

If the cause is Template:Cd or Template:Cd, or the cause is Template:Cd and the source is a world builder, Template:Cmd removes the NPC. Otherwise, it does nothing.

Template:EntityLink Primed TNT cannot be damaged.

Using Template:Cmd on primed TNT is never considered to have successfully damaged it.

Template:Cmd can always kill primed TNT.

A damage command with the cause of Template:Cd always kills the primed TNT, regardless of whether Template:Cd is 0 or not.

Template:EntityLink A shulker teleports if it is in lava or fire.

Applying Template:Cmd on a shulker with the cause being Template:Cd or Template:Cd cannot damage it and makes the shulker teleport away. It is considered unsuccessful and cannot be detected or controlled with behavior packs.

Projectiles cannot hurt a shulker when it is closed.

Applying Template:Cmd on a closed shulker with the cause being Template:Cd cannot damage it. It is considered unsuccessful and cannot be detected or controlled with behavior packs.

Template:EntityLink A small fireball cannot be hit.

Using Template:Cmd on a small fireball is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.

Template:EntityLink A trident cannot be damaged.

Using Template:Cmd on a trident is never considered to have successfully damaged it.

A trident cannot be affected by an explosion.

Using Template:Cmd on a trident with cause being Template:Cd or Template:Cd cannot be detected or controlled with behavior packs.

Template:EntityLink A wither skull cannot be damaged.

Using Template:Cmd on a wither skull is never considered to have successfully damaged it.

A black wither skull cannot be hit.

Using Template:Cmd on a black wither skull is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.

Template:EntityLink Drowning and falling cannot hurt a wither.

If the cause is Template:Cd or Template:Cd, Template:Cmd does nothing on a wither and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.

A wither cannot damage another wither.

If the cause is not Template:Cd and the source is another wither, a damage command does nothing on a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.

If a wither is in its spawning animation, the cause is Template:Cd, and the source is a mob, Template:Cmd makes the source mob suffer knockback.

When spawning, a wither cannot be damaged by anything except for the void.

If a wither is spawning, and the source is not the Template:Cd, a 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.

When dying, a wither cannot be damaged.

If a wither is dying, Template:Cmd does nothing on a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.

In its armored state, a wither is immune to arrows.

If the wither is in its armored state, Template:Cmd with the cause being Template:Cd and the damage source being an arrow does nothing to a wither, and it is not considered to have successfully damaged it. It cannot be detected or controlled with behavior packs.

Damage types

Below are the types of damage that can be applied. These are used for the Template:CodeTemplate:Only or Template:CodeTemplate:Only arguments (see Syntax below).


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

Template:Argument

Specifies the entityTemplate:Only or entitiesTemplate:Only to damage.
Template:Arg desc

Template:El: Template:Argument

Specifies the amount of damage to inflict.
Template:Arg desc

Template:El: Template:Argument

Specifies the amount of damage to inflict.
Template:Arg desc Should be between 0 and 2147483647 (both inclusive).

Template:Argument

Specifies the damage typeTemplate:Only or type of damageTemplate:Only. Affects death messages and difficulty scaling, among other things.
Template:IN, if not specified, defaults to minecraft:generic.
Template:Arg desc
For Minecraft:Bedrock Edition, all possible arguments are listed on the official add-on documentation.

Template:El: Template:Argument

Specifies the location the damage originated at if the cause of the damage is not an entity (e.g., the position of the Minecraft:bed that exploded in the Nether).
Template:Arg desc

Template:Argument

Specifies the entity who dealt the damage.
Template:Arg desc

Template:El: Template:Argument

Specifies the cause of the damage (for example, the skeleton that shot the Minecraft:arrow).
Template:Arg desc

Results

Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table

Output

Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table

Example

History

Java Edition

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

External links

Navigation

Template:Navbox commands

de:Befehl/damage es:Comandos/damage ja:コマンド/damage ko:명령어/damage pt:Comandos/damage ru:Команды консоли/damage zh:命令/damage