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
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
Line 9: Line 9:


== Usage ==
== Usage ==
{{MC/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, {{MC/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 {{MC/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).
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).


===Undefined behavior===
===Undefined behavior===


{{MC/-}}
{{-}}
{| class="wikitable sortable" data-description="Undefined behavior"
{| class="wikitable sortable" data-description="Undefined behavior"
! Mob
! Mob
Line 24: Line 24:
Begins an invulnerable cooldown period.
Begins an invulnerable cooldown period.
|-
|-
| {{MC/Entitylink|Balloon}}{{only|education|bedrock|short=1}}
| {{EntityLink|Balloon}}{{only|education|bedrock|short=1}}
| Damaged with a source entity, the balloon swings.
| Damaged with a source entity, the balloon swings.
|-
|-
| {{MC/Entitylink|Bat}}
| {{EntityLink|Bat}}
| When damaged, a sleeping bat begins flying.
| When damaged, a sleeping bat begins flying.
|-
|-
| {{MC/Entitylink|End Crystal}}
| {{EntityLink|End Crystal}}
| Controlled by the Ender Dragon's fight system.
| Controlled by the [[Minecraft:Ender Dragon]]'s fight system.
|-
|-
| {{MC/Entitylink|Enderman}}
| {{EntityLink|Enderman}}
| Teleports away.
| Teleports away.
|-
|-
| {{MC/Entitylink|Guardian}}
| {{EntityLink|Guardian}}
| While its spikes are extended, if the damage source is a mob and the cause isn't {{MC/Cd|magic}}, {{MC/Cd|block_explosion}}, or {{MC/Cd|projectile}}, it deals thorn damage to the damage source.
| While its spikes are extended, if the damage source is a mob and the cause isn't {{cd|magic}}, {{cd|block_explosion}}, or {{cd|projectile}}, it deals thorn damage to the damage source.
|-
|-
| {{MC/Entitylink|Shulker}}
| {{EntityLink|Shulker}}
| Teleports away.
| Teleports away.
|-
|-
| {{MC/Entitylink|Squid}}
| {{EntityLink|Squid}}
| If the damage source is an entity, it spawns ink particles.
| If the damage source is an entity, it spawns ink particles.
|}
|}


===Hardcoded behaviors===
===Hardcoded behaviors===
When {{MC/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.
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.


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.
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.


{| class="wikitable sortable" data-description="Hardcoded behavior"
{| class="wikitable sortable" data-description="Hardcoded behavior"
Line 55: Line 55:
! Behavior
! Behavior
|-
|-
| {{MC/Entitylink|Player}}
| {{EntityLink|Player}}
| Players in Creative mode are invulnerable by most types of damage excluding {{MC/Code|generic_kill}} and {{MC/Code|out_of_world}} (refer to damage types)
| 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]])
|-
|-
| {{MC/Entitylink|Agent}}{{only|education|bedrock|short=1}}
| {{EntityLink|Agent}}{{only|education|bedrock|short=1}}
| {{MC/Cmd|kill}} command can always kill the agent. This has the side-effect that {{MC/Cmd|damage}} with the cause of {{MC/Cd|self_destruct}} always removes the agent, regardless of whether {{MC/Cd|amount: int}} is 0 or not.
| {{cmd|kill}} command can always kill the agent. This has the side-effect that {{cmd|damage}} with the cause of {{cd|self_destruct}} always removes the agent, regardless of whether {{cd|amount: int}} is 0 or not.
|-
|-
| {{MC/Entitylink|Armor Stand}}
| {{EntityLink|Armor Stand}}
| Applying {{MC/Cmd|damage}} command on an armor stand cannot reduce its health value (except for {{MC/Cd|fire}} and {{MC/Cd|fire_tick}} causes), and is never considered to have damaged it successfully. It also cannot be detected or controlled with 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 [[Minecraft: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 68: Line 68:
Punching an armor stand twice in Survival mode destroys it.
Punching an armor stand twice in Survival mode destroys it.


Running {{MC/Cmd|damage}} 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.
Running {{cmd|damage}} 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.
Punching an armor stand in Creative mode removes it.


Running {{MC/Cmd|damage}} on an armor stand with the damage source being a player in Creative mode removes it.
Running {{cmd|damage}} on an armor stand with the damage source being a player in Creative mode removes it.


Explosions can always destroy the armor stand. The {{MC/Cmd|kill}} command can always kill the armor stand.
Explosions can always destroy the armor stand. The {{cmd|kill}} command can always kill the armor stand.


{{MC/Cmd|damage}} commands with the cause of {{MC/Cd|suicide}}, {{MC/Cd|block_explosion}}, or {{MC/Cd|entity_explosion}} make the armor stand drop its held items and destroy itself.
{{cmd|damage}} commands with the cause of {{cd|suicide}}, {{cd|block_explosion}}, or {{cd|entity_explosion}} make the armor stand drop its held items and destroy itself.


Void damage can always kill the armor stand.
Void damage can always kill the armor stand.


{{MC/Cmd|damage}} commands with the {{MC/Cd|void}} cause always remove the armor stand.
{{cmd|damage}} commands with the {{cd|void}} cause always remove the armor stand.


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


{{MC/Cmd|damage}} commands with the {{MC/Cd|fire}} cause the armor stand to be set on fire and reduce its health value by 0.5.
{{cmd|damage}} commands with the {{cd|fire}} cause the armor stand to be set on fire and reduce its health value by 0.5.


Armor stands are damaged when on fire.
Armor stands are damaged when on fire.


If the cause is {{MC/Cd|fire}}, and the armor stand is not in a lava or fire block, {{MC/Cmd|damage}} commands reduce its health value by 1.0.
If the cause is {{cd|fire}}, and the armor stand is not in a lava or fire block, {{cmd|damage}} commands reduce its health value by 1.0.


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


Running {{MC/Cmd|damage}} commands on an armor stand with the source being an arrow causes the armor stand to be destroyed and the arrow to disappear.
Running {{cmd|damage}} 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.
If a trident hits an armor stand, the armor stand is destroyed.


Running {{MC/Cmd|damage}} commands on an armor stand with the damage source being a trident causes the armor stand to be destroyed.
Running {{cmd|damage}} 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.
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 {{MC/Cd|fall}} cause.
Broadcasts a landing sound when an armor stand is damaged with the {{cd|fall}} cause.
|-
|-
| {{MC/Entitylink|Balloon}}{{only|education|bedrock|short=1}}
| {{EntityLink|Balloon}}{{only|education|bedrock|short=1}}
| Clicking a balloon isn't considered as hurting it. This has the side-effect that running {{MC/Cmd|damage}} on a balloon cannot reduce its health value, and is never considered to have successfully damaged it.
| Clicking a balloon isn't considered as hurting it. This has the side-effect that running {{cmd|damage}} 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. {{MC/Cmd|kill}} can always kill the balloon. This has the side-effect that the damage causes {{MC/Cd|self_destruct}}, {{MC/Cd|projectile}}, {{MC/Cd|fire}}, {{MC/Cd|fire_tick}}, {{MC/Cd|lava}}, or {{MC/Cd|magma}} destroy the balloon.
Projectiles, fire, lava, and magma can always destroy the balloon. {{cmd|kill}} can always kill the balloon. This has the side-effect that the damage causes {{cd|self_destruct}}, {{cd|projectile}}, {{cd|fire}}, {{cd|fire_tick}}, {{cd|lava}}, or {{cd|magma}} destroy the balloon.
|-
|-
| {{MC/Entitylink|Boat}}
| {{EntityLink|Boat}}
| Punching a boat is always considered as hurting it.
| Punching a boat is always considered as hurting it.


Running {{MC/Cmd|damage}} on a boat is always considered to have successfully damaged it, but it cannot be detected or controlled with behavior packs.
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]].


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 {{MC/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.
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.


Punching a boat in Creative mode destroys it.
Punching a boat in Creative mode destroys it.


Running {{MC/Cmd|damage}} on a boat with the damage source being a player in Creative mode destroys the boat, regardless of whether {{MC/Cd|amount: int}} is 0 or not.
Running {{cmd|damage}} on a boat with the damage source being a player in Creative mode destroys the boat, regardless of whether {{cd|amount: int}} is 0 or not.
|-
|-
| {{MC/Entitylink|Camera}}{{only|education|bedrock|short=1}}
| {{EntityLink|Camera}}{{only|education|bedrock|short=1}}
| A camera cannot be damaged.
| A camera cannot be damaged.


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


A camera cannot be affected by an explosion.
A camera cannot be affected by an explosion.


Using {{MC/Cmd|damage}} on a camera with the source being a player removes it.
Using {{cmd|damage}} on a camera with the source being a player removes it.
|-
|-
| {{MC/Entitylink|End Crystal}}
| {{EntityLink|End Crystal}}
| Hurting an end crystal means making it explode.
| Hurting an end crystal means making it explode.


Running {{MC/Cmd|damage}} on an end crystal makes it explode, regardless of whether {{MC/Cd|amount: int}} is 0 or not, and is never{{MC/Verify}} considered to have successfully damaged it.
Running {{cmd|damage}} on an end crystal makes it explode, regardless of whether {{cd|amount: int}} is 0 or not, and is never{{verify}} considered to have successfully damaged it.
|-
|-
| {{MC/Entitylink|Ender Dragon}}
| {{EntityLink|Ender Dragon}}
| Hardcoded behavior: An ender dragon is immune to arrows when perching, and makes arrows catch fire.
| Hardcoded behavior: An ender dragon is immune to arrows when perching, and makes arrows catch fire.


{{MC/Cmd|damage}} 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.
{{cmd|damage}} 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 {{MC/Cd|suffocation}} cannot hurt an ender dragon and is always considered unsuccessful.
A damage command with {{cd|suffocation}} cannot hurt an ender dragon and is always considered unsuccessful.


Only players can hurt an ender dragon.
Only players can hurt an ender dragon.


Only a player as the source, or the {{MC/Cd|block_explosion}} as a cause, can hurt an ender dragon and can be detected or controlled with 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 [[Minecraft:behavior packs]].


{{MC/Cmd|kill}} can always kill an ender dragon.
{{cmd|kill}} can always kill an ender dragon.


A damage command with the cause of {{MC/Cd|self_destruct}} always kills an ender dragon and is considered successful, regardless of whether {{MC/Cd|amount: int}} is 0 or not.
A damage command with the cause of {{cd|self_destruct}} always kills an ender dragon and is considered successful, regardless of whether {{cd|amount: int}} is 0 or not.
|-
|-
| {{MC/Entitylink|Enderman}}
| {{EntityLink|Enderman}}
| Projectiles, except potions, cannot hurt an enderman.
| Projectiles, except [[Minecraft:potions]], cannot hurt an enderman.


If the cause is {{MC/Cd|projectile}} and the source is not a potion entity, {{MC/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.
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.
|-
|-
| {{MC/Entitylink|Experience Orb}}
| {{EntityLink|Experience Orb}}
| A player cannot damage an experience orb.
| A player cannot damage an experience orb.


Running {{MC/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.
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]].
|-
|-
| {{MC/Entitylink|Falling Block}}
| {{EntityLink|Falling Block}}
| Applying {{MC/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 is always considered to have successfully damaged it, and cannot be detected or controlled with [[Minecraft:behavior packs]].


Applying {{MC/Cmd|damage}} on a falling block with the source being {{MC/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).
|-
|-
| {{MC/Entitylink|Ghast}}
| {{EntityLink|Ghast}}
| A fireball deals 1000 damage to a ghast if the fireball was rebounded by a player.
| A [[Minecraft: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 {{MC/Cd|amount: int}} is. It cannot be detected or controlled with behavior packs.
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]].
|-
|-
| {{MC/Entitylink|Painting}} and {{MC/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 {{MC/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 {{MC/Cd|amount: int}} is 0 or not, but it cannot be detected or controlled with 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 [[Minecraft:behavior packs]].
|-
|-
| {{MC/EnvLink|Item}}
| {{EnvLink|Item}}
| A player cannot damage an item.
| A player cannot damage an item.


Applying {{MC/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.
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]].
|-
|-
| {{MC/Entitylink|Minecart}}
| {{EntityLink|Minecart}}
| Punching a minecart is always considered as damaging it.
| Punching a minecart is always considered as damaging it.


Running {{MC/Cmd|damage}} on a minecart is always considered to have successfully damaged it.
Running {{cmd|damage}} 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.
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.


{{MC/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 ender pearl can reduce a minecart's Structural Integrity, but cannot destroy it.
An [[Minecraft:ender pearl]] can reduce a minecart's Structural Integrity, but cannot destroy it.


Applying {{MC/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.
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.
|-
|-
| {{MC/Entitylink|Minecart with TNT}}
| {{EntityLink|Minecart with TNT}}
| {{MC/Cmd|damage}} with the cause being {{MC/Cd|projectile}} and the damage source being an [[Minecraft:arrow]] that is on fire or a small fireball, or with the cause being {{MC/Cd|fire}} or {{MC/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.
| {{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]].


Otherwise behaves as a regular [[Minecraft:minecart]].
Otherwise behaves as a regular [[Minecraft:minecart]].
|-
|-
| {{MC/Entitylink|NPC}}{{only|education|bedrock|short=1}}
| {{EntityLink|NPC}}{{only|education|bedrock|short=1}}
| NPCs cannot be damaged.
| NPCs cannot be damaged.


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


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


If the cause is {{MC/Cd|void}} or {{MC/Cd|self_destruct}}, or the cause is {{MC/Cd|entity_attack}} and the source is a world builder, {{MC/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.
|-
|-
| {{MC/Entitylink|Primed TNT}}
| {{EntityLink|Primed TNT}}
| Primed TNT cannot be damaged.
| Primed TNT cannot be damaged.


Using {{MC/Cmd|damage}} on primed TNT is never considered to have successfully damaged it.
Using {{cmd|damage}} on primed TNT is never considered to have successfully damaged it.


{{MC/Cmd|kill}} can always kill primed TNT.
{{cmd|kill}} can always kill primed TNT.


A damage command with the cause of {{MC/Cd|self_destruct}} always kills the primed TNT, regardless of whether {{MC/Cd|amount: int}} is 0 or not.
A damage command with the cause of {{cd|self_destruct}} always kills the primed TNT, regardless of whether {{cd|amount: int}} is 0 or not.
|-
|-
| {{MC/Entitylink|Shulker}}
| {{EntityLink|Shulker}}
| A shulker teleports if it is in lava or fire.
| A shulker teleports if it is in lava or fire.


Applying {{MC/Cmd|damage}} on a shulker with the cause being {{MC/Cd|lava}} or {{MC/Cd|fire}} cannot damage it and makes the shulker teleport away. It is considered unsuccessful and cannot be detected or controlled with 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 [[Minecraft:behavior packs]].


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


Applying {{MC/Cmd|damage}} on a closed shulker with the cause being {{MC/Cd|projectile}} cannot damage it. It is considered unsuccessful and cannot be detected or controlled with 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 [[Minecraft:behavior packs]].
|-
|-
| {{MC/Entitylink|Small fireball}}
| {{EntityLink|Small fireball}}
| A small fireball cannot be hit.
| A small fireball cannot be hit.


Using {{MC/Cmd|damage}} on a small fireball is never considered to have successfully damaged it and cannot be detected or controlled with behavior packs.
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]].
|-
|-
| {{MC/Entitylink|Trident}}
| {{EntityLink|Trident}}
| A trident cannot be damaged.
| A trident cannot be damaged.


Using {{MC/Cmd|damage}} on a trident is never considered to have successfully damaged it.
Using {{cmd|damage}} on a trident is never considered to have successfully damaged it.


A trident cannot be affected by an explosion.
A trident cannot be affected by an explosion.


Using {{MC/Cmd|damage}} on a trident with cause being {{MC/Cd|block_explosion}} or {{MC/Cd|entity_explosion}} cannot be detected or controlled with behavior packs.
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]].
|-
|-
| {{MC/Entitylink|Wither Skull}}
| {{EntityLink|Wither Skull}}
| A wither skull cannot be damaged.
| A wither skull cannot be damaged.


Using {{MC/Cmd|damage}} on a wither skull is never considered to have successfully damaged it.
Using {{cmd|damage}} on a wither skull is never considered to have successfully damaged it.


A black wither skull cannot be hit.
A black wither skull cannot be hit.


Using {{MC/Cmd|damage}} on a black wither skull is never considered to have successfully damaged it and cannot be detected or controlled with 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 [[Minecraft:behavior packs]].
|-
|-
| {{MC/Entitylink|Wither}}
| {{EntityLink|Wither}}
| Drowning and falling cannot hurt a wither.
| Drowning and falling cannot hurt a wither.


If the cause is {{MC/Cd|drowning}} or {{MC/Cd|fall}}, {{MC/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.
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]].


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


If the cause is not {{MC/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 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 a wither is in its spawning animation, the cause is {{MC/Cd|entity_attack}}, and the source is a mob, {{MC/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.


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 {{MC/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.
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]].


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


If a wither is dying, {{MC/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.
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]].


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, {{MC/Cmd|damage}} with the cause being {{MC/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.
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]].
|}
|}


== Damage types ==
== Damage types ==
Below are the types of damage that can be applied. These are used for the {{MC/Code|<damageType>}}{{only|je}} or {{MC/Code|cause:DamageCause}}{{only|be}} arguments (see Syntax below).
Below are the types of damage that can be applied. These are used for the {{code|<damageType>}}{{only|je}} or {{code|cause:DamageCause}}{{only|be}} arguments (see Syntax below).


{|class = "wikitable collapsed collapsible"
{|class = "wikitable collapsed collapsible"
Line 380: Line 380:
!Notes
!Notes
|-
|-
|{{MC/Cd|anvil}}
|{{cd|anvil}}
|Caused by a falling [[Minecraft:anvil]].
|Caused by a falling [[Minecraft:anvil]].
|Reduced damage to targets wearing a helmet.
|Reduced damage to targets wearing a helmet.
|-
|-
|{{MC/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 Blast Protection.
|Reduced damage to targets equipped with armor, with extra reduction per tier of [[Minecraft:Blast Protection]].
|-
|-
|{{MC/Cd|campfire}}
|{{cd|campfire}}
|{{MC/Info needed}}
|{{Info needed}}
|{{MC/Info needed}}
|{{Info needed}}
|-
|-
|{{MC/Cd|charging}}
|{{cd|charging}}
|{{MC/Info needed}}
|{{Info needed}}
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/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 Protection.
|Reduced damage to targets equipped with armor, with extra reduction per tier of [[Minecraft:Protection]].
|-
|-
|{{MC/Cd|drowning}}
|{{cd|drowning}}
|Caused by drowning or rain.
|Caused by drowning or rain.
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/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 Protection.
|Reduced damage to targets equipped with armor, with extra reduction per tier of [[Minecraft:Protection]].
|-
|-
|{{MC/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 Blast Protection.
|Reduced damage to targets equipped with armor, with extra reduction per tier of [[Minecraft:Blast Protection]].
|-
|-
|{{MC/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.
|{{MC/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.
|{{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.
|-
|-
|{{MC/Cd|falling_block}}
|{{cd|falling_block}}
|{{MC/More info needed}}
|{{more info needed}}
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|fire}}
|{{cd|fire}}
|Caused by standing in [[Minecraft:fire]].
|Caused by standing in [[Minecraft:fire]].
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|fire_tick}}
|{{cd|fire_tick}}
|Caused by being on fire.
|Caused by being on fire.
| 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.
| 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.
|-
|-
|{{MC/Cd|fireworks}}
|{{cd|fireworks}}
|Caused by a firework rocket.
|Caused by a [[Minecraft:firework rocket]].
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|fly_into_wall}}
|{{cd|fly_into_wall}}
|Caused by colliding with a block when flying with an [[Minecraft:elytra]].
|Caused by colliding with a block when flying with an [[Minecraft:elytra]].
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|freezing}}
|{{cd|freezing}}
|Caused by standing in powder snow.  
|Caused by standing in [[Minecraft:powder snow]].  
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|lava}}
|{{cd|lava}}
|Caused by [[Minecraft:lava]].
|Caused by [[Minecraft:lava]].
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|lightning}}
|{{cd|lightning}}
|Caused by lightning.
|Caused by [[Minecraft:lightning]].
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|mace-smash}}
|{{cd|mace-smash}}
|{{MC/Info needed}}
|{{Info needed}}
|{{MC/Info needed}}
|{{Info needed}}
|-
|-
|{{MC/Cd|magic}}
|{{cd|magic}}
|Caused by potions, dragon breath, evocation fangs or guardians.
|Caused by potions, dragon breath, evocation fangs or guardians.
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|magma}}
|{{cd|magma}}
|Caused by magma blocks.  
|Caused by [[Minecraft:magma block]]s.  
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|none}}
|{{cd|none}}
|{{MC/Info needed}}
|{{Info needed}}
|{{MC/Info needed}}
|{{Info needed}}
|-
|-
|{{MC/Cd|override}}
|{{cd|override}}
|Override this entity's health value.
|Override this entity's health value.
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|piston}}
|{{cd|piston}}
|Caused by [[Minecraft:piston]]s.
|Caused by [[Minecraft:piston]]s.
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|projectile}}
|{{cd|projectile}}
|Caused by projectiles, such as arrows.
|Caused by [[Minecraft:projectile]]s, such as arrows.
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|ram_attack}}
|{{cd|ram_attack}}
|{{MC/Info needed}}
|{{Info needed}}
|{{MC/Info needed}}
|{{Info needed}}
|-
|-
|{{MC/Cd|self_destruct}}
|{{cd|self_destruct}}
|Caused by {{MC/Cmd|kill}}.  
|Caused by {{cmd|kill}}.  
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|sonic_boom}}
|{{cd|sonic_boom}}
|{{MC/Info needed}}
|{{Info needed}}
|{{MC/Info needed}}
|{{Info needed}}
|-
|-
|{{MC/Cd|soul_campfire}}
|{{cd|soul_campfire}}
|{{MC/Info needed}}
|{{Info needed}}
|{{MC/Info needed}}
|{{Info needed}}
|-
|-
|{{MC/Cd|stalactite}}
|{{cd|stalactite}}
|Caused by stalactites.
|Caused by [[Minecraft:stalactite]]s.
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|stalagmite}}
|{{cd|stalagmite}}
|Caused by stalagmites.
|Caused by [[Minecraft:stalagmite]]s.
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|starve}}
|{{cd|starve}}
|Caused by hunger.
|Caused by [[Minecraft:hunger]].
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|suffocation}}
|{{cd|suffocation}}
|Caused by suffocation.  
|Caused by [[Minecraft:suffocation]].  
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|temperature}}
|{{cd|temperature}}
|Snow golem damaged by biome temperature.
|Snow golem damaged by biome temperature.
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|thorns}}
|{{cd|thorns}}
|Caused by thorns.
|Caused by [[Minecraft:thorns]].
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|void}}
|{{cd|void}}
|Caused by the void.
|Caused by the [[Minecraft:void]].
|{{MC/Info needed}}
|{{info needed}}
|-
|-
|{{MC/Cd|wither}}
|{{cd|wither}}
|Caused by a [[Minecraft:wither]].
|Caused by a [[Minecraft:wither]].
|{{MC/Info needed}}
|{{info needed}}
|}
|}


Line 537: Line 537:
==Arguments==
==Arguments==


{{MC/Argument|target|entity|target: target|CommandSelector<Actor>}}
{{argument|target|entity|target: target|CommandSelector<Actor>}}
: Specifies the entity{{only|java}} or entities{{only|be}} to damage.
: Specifies the entity{{only|java}} or entities{{only|be}} to damage.
: {{MC/Arg desc|je=entity|amount=single|type=entities|be=actor}}
: {{arg desc|je=entity|amount=single|type=entities|be=actor}}


{{MC/El|je|short=1}}: {{MC/Argument|amount|float}}
{{el|je|short=1}}: {{argument|amount|float}}
: Specifies the amount of damage to inflict.
: Specifies the amount of damage to inflict.
: {{MC/Arg desc|je=float|min=0.0}}
: {{arg desc|je=float|min=0.0}}


{{MC/El|be|short=1}}: {{MC/Argument|amount: int|int|be=1}}
{{el|be|short=1}}: {{argument|amount: int|int|be=1}}
: Specifies the amount of damage to inflict.
: Specifies the amount of damage to inflict.
: {{MC/Arg desc|be=int}} Should be between 0 and 2147483647 (both inclusive).
: {{arg desc|be=int}} Should be between 0 and 2147483647 (both inclusive).


{{MC/Argument|damageType|resource|cause: DamageCause|enum}}
{{argument|damageType|resource|cause: DamageCause|enum}}
: Specifies the damage type{{only|java}} or type of damage{{only|be}}. Affects death messages and difficulty scaling, among other things.
: Specifies the [[Minecraft:damage type]]{{only|java}} or type of damage{{only|be}}. Affects death messages and difficulty scaling, among other things.
: {{MC/In|je}}, if not specified, defaults to <code>minecraft:generic</code>.
: {{IN|je}}, if not specified, defaults to <code>minecraft:generic</code>.
: {{MC/Arg desc|je=resource|registry=minecraft:damage_type}}
: {{arg desc|je=resource|registry=minecraft:damage_type}}
: For [[Minecraft:Bedrock Edition]], all possible arguments are listed [https://learn.microsoft.com/en-us/minecraft/creator/commands/commands/damage?view=minecraft-bedrock-stable on the official add-on documentation].
: For [[Minecraft:Bedrock Edition]], all possible arguments are listed [https://learn.microsoft.com/en-us/minecraft/creator/commands/commands/damage?view=minecraft-bedrock-stable on the official add-on documentation].


{{MC/El|je|short=1}}: {{MC/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 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 [[Minecraft:Nether]]).
: {{MC/Arg desc|je=vec3}}
: {{arg desc|je=vec3}}


{{MC/Argument|entity|entity|damager: target|CommandSelector<Actor>}}
{{argument|entity|entity|damager: target|CommandSelector<Actor>}}
: Specifies the entity who dealt the damage.
: Specifies the entity who dealt the damage.
: {{MC/Arg desc|je=entity|amount=single|type=entities|be=actor}}
: {{arg desc|je=entity|amount=single|type=entities|be=actor}}


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


==Results==
==Results==
{{Result table}}
{{Result table}}
{{Result table|The arguments are not specified correctly.|unparseable|unparseable}}
{{Result table|The arguments are not specified correctly.|unparseable|unparseable}}
{{Result table|{{MC/Cd|amount}} or {{MC/Cd|amount: int}} is lower than or equal to 0.|fail|fail}}
{{Result table|{{cd|amount}} or {{cd|amount: int}} is lower than or equal to 0.|fail|fail}}
{{Result table|{{MC/Cd|amount}} or {{MC/Cd|amount: int}} is greater than 0 and the damage is considered not having successfully damaged the entity.||}}
{{Result table|{{cd|amount}} or {{cd|amount: int}} is greater than 0 and the damage is considered not having successfully damaged the entity.||}}
{{Result table|{{MC/Cd|amount: int}} is greater than 0 and the entity is not a vanilla entity or has no hardcoded damage behavior.{{MC/Verify}}{{only|bedrock|short=1}}||}}
{{Result table|{{cd|amount: int}} is greater than 0 and the entity is not a vanilla entity or has no hardcoded damage behavior.{{verify}}{{only|bedrock|short=1}}||}}
{{Result table|cmd=/damage ... by ...{{only|java|short=1}} /damage ... entity ...{{only|bedrock|short=1}}|{{MC/Cd|source}} or {{MC/Cd|damager: target}} targets multiple entities.||}}
{{Result table|cmd=/damage ... by ...{{only|java|short=1}} /damage ... entity ...{{only|bedrock|short=1}}|{{cd|source}} or {{cd|damager: target}} targets multiple entities.||}}
{{Result table|cmd=|succeed}}
{{Result table|cmd=|succeed}}
{{Result table}}
{{Result table}}


==Output==
==Output==
{{MC/Output table}}
{{Output table}}
{{MC/Output table|edition=je|On fail|0|0|0}}
{{Output table|edition=je|On fail|0|0|0}}
{{MC/Output table|On success|1|1|1}}
{{Output table|On success|1|1|1}}
{{MC/Output table|edition=be|On fail|0}}
{{Output table|edition=be|On fail|0}}
{{MC/Output table|On success|The number of entities who are considered to have successfully took the damage.}}
{{Output table|On success|The number of entities who are considered to have successfully took the damage.}}
{{MC/Output table}}
{{Output table}}


== Example ==
== Example ==
Line 593: Line 593:
=== ''Java Edition'' ===
=== ''Java Edition'' ===
{{HistoryTable
{{HistoryTable
|{{MC/HistoryLine|java}}
|{{HistoryLine|java}}
|{{HistoryLine||1.19.4|dev=23w06a|Added {{MC/Cmd|damage|link=none}}.}}
|{{HistoryLine||1.19.4|dev=23w06a|Added {{cmd|damage|link=none}}.}}
|{{MC/HistoryLine|||dev=Pre-release 2|Striders and blazes now have a weakness to freezing damage.}}
|{{HistoryLine|||dev=Pre-release 2|[[Minecraft:Strider]]s and [[Minecraft:blaze]]s now have a weakness to freezing damage.}}
}}
}}


=== ''Bedrock Edition'' ===
=== ''Bedrock Edition'' ===
{{HistoryTable
{{HistoryTable
|{{MC/HistoryLine|bedrock}}
|{{HistoryLine|bedrock}}
|{{HistoryLine||1.18.10|dev=beta 1.18.10.26|Added {{MC/Cmd|damage|link=none}}.}}
|{{HistoryLine||1.18.10|dev=beta 1.18.10.26|Added {{cmd|damage|link=none}}.}}
|{{MC/HistoryLine||1.20.70|dev=Preview 1.20.70.21|Renamed the <code>suicide</code> damage type to <code>self_destruct</code>.}}
|{{HistoryLine||1.20.70|dev=Preview 1.20.70.21|Renamed the <code>suicide</code> damage type to <code>self_destruct</code>.}}
}}
}}


Line 610: Line 610:


== Navigation ==
== Navigation ==
{{MC/Navbox commands}}
{{Navbox commands}}


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

Latest revision as of 11:04, 9 May 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 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 Template:Cmd 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).

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 Minecraft: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 Minecraft:armor stands, NPCs, and Minecraft:camera), Minecraft:boats, Minecraft:paintings, leash knots, Minecraft:falling blocks, and Minecraft: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.

Mob Behavior
Template:EntityLink Players in Creative mode are invulnerable by most types of damage excluding Template:Code and Template:Code (refer to Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Template:Cd is. It cannot be detected or controlled with Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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 Minecraft: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

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