Minecraft:Commands/damage
More actions
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).
| Damage type | Notes |
|---|---|
| arrow | |
| bad_respawn_point | |
| cactus | |
| campfire | |
| cramming | bypasses: • armor • shields • wolf armor |
| dragon_breath | bypasses: • armor • shields |
| drown | bypasses: • armor • shields • wolf armor |
| dry_out | |
| explosion | |
| fall | bypasses: • armor • shields |
| falling_anvil | bypasses: • shields |
| falling_block | |
| falling_stalactite | bypasses: • shields |
| fireball | |
| fly_into_wall | bypasses: • armor • shields |
| freeze | bypasses: • armor • shields • wolf armor |
| generic | bypasses: • armor • shields |
| generic_kill | bypasses: • invulnerability • armor • resistance effect • shields • wolf armor |
| hot_floor | |
| in_fire | |
| in_wall | bypasses: • armor • shields • wolf armor |
| indirect_magic | bypasses: • armor • shields • wolf armor |
| lava | |
| lightning_bolt | |
| magic | bypasses: • armor • shields • wolf armor |
| mob_attack | |
| mob_attack_no_aggro | |
| mob_projectile | |
| on_fire | bypasses: • armor • shields |
| out_of_world | bypasses: • invulnerability • armor • resistance effect • shields • wolf armor |
| outside_border | bypasses: • armor • shields • wolf armor |
| player_attack | |
| player_explosion | |
| sonic_boom | bypasses: • armor • enchantments • shields |
| spit | |
| stalagmite | bypasses: • armor • shields |
| starve | bypasses: • armor • effects (including resistance) • shields • wolf armor |
| sting | |
| sweet_berry_bush | |
| thorns | bypasses: • wolf armor |
| thrown | |
| trident | |
| unattributed_fireball | |
| wind_charge | |
| wither | bypasses: • armor • shields • wolf armor |
| wither_skull |
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
- 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).
- 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
- 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
- Make a villager named
villager_1deal Template:Hp damage to the nearest iron golem:
History
Java Edition
Bedrock Edition
External links
Minecraft:de:Befehl/damage Minecraft:es:Comandos/damage Minecraft:ja:コマンド/damage Minecraft:ko:명령어/damage Minecraft:pt:Comandos/damage Minecraft:ru:Команды консоли/damage Minecraft:zh:命令/damage