Commands/damage

Applies a set amount of damage to the specified entities.
== Usage ==
This command does not simply change a entity health value. Instead, it directly calls the underlying logic in the game to simulate the situation of causing damage to the entity. So this command has many undefined behaviors.
The output text, result, and return value of the damage command are not related to whether the health value is changed. In fact, they are undefined.
The amount: int is not the final amount of reduced health value. The reduced health value is usually less than or greater than the amount: int due to world difficulty, armors, status effects, or the target entity itself, etc.
When damaged, the entity may react accordingly, such as being knocked back, becoming angry, etc. The damager entity may also react in certain ways, such as the arrow's disappearing.
Undefined behaviors may be changed at any time without warning. When this happens, your addons or maps may cease to work. Use these undefined behaviors at your own risk.
==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 entity or entities to damage.
: 
: Specifies the amount of damage to inflict.
: 
: Specifies the amount of damage to inflict.
: And it must be between 0.0 and 2147483647 (inclusive).
: Specifies the damage type or type of damage. Affects death messages and difficulty scaling, among other things.
: 
: For Bedrock Edition, all possible arguments are listed on the official add-on documentation.
Name	Description 	Notes
 	Any damage 	
 	Caused by a falling anvil. Reduced damage to targets wearing a helmet. 	
 	Caused the explosion of a block 	Reduced damage to targets equipped with armor, with extra reduction per tier of Blast Protection.
 	 	
 	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.
 	Caused by drowning or rain. 	
 	Caused by melee attack from a mob. 	Reduced damage to targets equipped with armor, with extra reduction per tier of Protection.
 	Caused by the explosion of a mob. 	Reduced damage to targets equipped with armor, with extra reduction per tier of Blast Protection.
 	Caused by falling from higher ground, or teleporting by ender pearl. 	Reduced damage to targets equipped with Feather Falling or Protection armor. Some mobs are immune to or take less damage from fall damage.
 	 	
 	Caused by standing in fire or lit campfire. 	
 	Caused by being on fire 	Reduced damage to targets equipped with Fire Protection of Protection. Blazes, ghasts, magma cubes, withers, wither skeletons and zombified piglins are immune to burning.
 	Caused by a firework rocket. 	
 	Caused by standing in fire or lit campfire. 	
 	Caused by collide with block when flying with an elytra. 	
 	Caused by standing in powder snow. 	
 	Caused by lava. 	
 	Caused by lightning. 	
 	Caused by potions, dragon breath, evocation fangs or guardians. 	
 	Caused by magma block. 	
 	Override this entity's health value. 	
 	Caused by piston. 	
 	Caused by projectile, such as arrows. 	
 	Caused by stalactite. 	
 	Caused by stalagmite. 	
 	Caused by hunger. 	
 	Caused by suffocation. 	
 	Caused by . 	
 	Snow golem damaged by biome temperature. 	
 	Caused by thorns. 	
 	Caused by void. 	
 	Caused by wither. 	
: 
: Specifies the location the damage originated at if the cause of the damage is not an entity (e.g., the position of the bed that exploded in the Nether).
: 
: Specifies the entity who dealt the damage.
: 
: 
: Specifies the cause of the damage (for example, the skeleton that shot the arrow).
: 
==Results==
==Output==
== Example ==
* Make a villager named villager_1 deal damage to a nearby iron golem: 
** 
** 
==History==
de:Befehl/damage
ja:コマンド/damage
pt:Comandos/damage
zh:命令/damage