Melee attack
A melee attack is a type of attack that mobs and players use to cause damage through very close contact with a target.
Attack scenario
Melee attacks apply mob's base melee attack damage and deal damage to the target entity in mob_attack damage type. Most mobs perform one melee attack per second, targeting a single intended target for the melee attack, without accidentally harming other targets.
Some mobs melee attack in a different way and have special effects:
- Players can perform a melee attack on a mob or another player by clicking the attack button while holding any item to deal damage. Players have a greater melee attack range than most mobs and an unlimited attack frequency, allowing them to continuously attack targets without being reached by most mobs.
- When a player uses a trident enchanted with Riptide collides with an entity, they will automatically perform a melee attack on the entities they collide with.
- Cave spiders, husks, wither skeletons, and bees deal status effects to the entities they attack during a melee attack.
- Iron golems, hoglins, and zoglins knock their targets into the air during melee attacks.
- Polar bears stand on their hind legs and swing their front paws to perform melee attacks.
- Entities holding an axe, such as vindicators and piglin brutes, as well as wardens, will disable the target's shield during a melee attack for 100 game ticks (5 seconds).
- When a wither's health falls below 50%, it performs melee attacks in the form of a dash, destroying most blocks it touches during the dash.
- Slimes and magma cubes attack all entities they push at once rather than focusing on a single target, and their melee attacks have no frequency limit, allowing them to continuously attack. The damage immunity mechanic means they can only deal damage twice per second to a single target, but in Java Edition if a shield blocks their attack, it does not trigger Damage Immunity, rapidly depleting the shield's durability.
Attack range
There's a range in melee attacks, and if the target is beyond this range, the melee attack cannot occur.
For most entities, the attack range is defined as a horizontally extended area beyond their collision box, referred to below as the attack bounding box. Similarly, the attacked entity has a range within which it can be struck, referred to as the hit bounding box. A melee attack can occur when the attack bounding box intersects with the hit bounding box.
The attack bounding box is calculated as follows:
- Get the entity's collision box. If the entity is riding another entity, use the collision bounding box of both entities, with the height range taken from the entity's collision box.
- Horizontally extend this collision box by (approximately 0.828 blocks) to define the attack bounding box.
- If the entity is a ravager, reduce the attack bounding box by 0.5 blocks horizontally.
The hit bounding box is calculated as follows:
- If the entity is not riding another entity, the hit bounding box is the entity's collision box.
- If the entity is riding another entity, the lowest point of the hit bounding box is set to the higher of the entity's collision box bottom and the riding position of the entity.
Apart from players, entities performing melee attacks must also maintain a clear line of sight to the attacked entity, preventing attacks through blocks. Since entities cannot see themselves, they cannot perform melee attacks on themselves.
For players, the attack range is the range they can physically reach. In Java Edition, this depends on the attribute entity_interaction_range, with a default value of 3 blocks, and in Creative Mode, the range increases to 5 blocks due to attribute modifiers.
Base melee attack damage
In melee attacks, if not considering the enchantments on items, extra attack damage, critical hits and attack cooldown, or other additional factors, all entities have a base melee attack damage. The base melee attack damage calculation includes the mob's base attack damage, main hand item damage, and status effects.
Java Edition
In Java Edition, base melee attack damage is the computed value of the attribute attack_damage. The damage from the main hand item and status effects are essentially Op0 attribute modifiers. Using the /attribute command to modify the base value or modifiers can change the base melee attack damage for the corresponding entity. For example, the base melee attack damage of a player holding a wooden sword with the Strength II effect would be calculated as:
1 (Player base attack value) + 3 (Wooden sword damage, Op0 modifier, value 3) + 6 (Strength II effect, Op0 modifier, value 6) = 10
The attack damage of the main hand items is shown in the table below (not including the player's 1HP base attack value, so the values are 1 less than what is displayed in-game):
| Item | Attack Damage | |||||
|---|---|---|---|---|---|---|
| Sword | ||||||
| Shovel | ||||||
| Pickaxe | ||||||
| Axe | ||||||
| Hoe | ||||||
| Trident | ||||||
| Mace | ||||||
| Other Items | 0HP | |||||
The Strength status effect increases attack damage by 3HP per level, while the Weakness effect reduces it by 4HP per level.
Bedrock Edition
In Bedrock Edition, the base melee attack damage is calculated differently for different entities:
For players, the calculation sequence for base melee attack damage is as follows:
- Get the player's base attack value.
- Add the main hand item damage.
- Calculate the Strength status effect.
- Calculate the Weakness status effect.
For example, the base melee attack damage of a player holding a wooden sword with both Strength II and Weakness I effects would be calculated as:
1 (Player base attack value) + 4 (Wooden sword damage) = 5 (5 × 1.3 + 1) × 1.3 + 1 = 10.75 (Strength II) 10.75 × 0.8 - 0.5 = 8.1 (Weakness I)
For most non-player entities, the calculation sequence for base melee attack damage is as follows:
- Get the mob's base attack value.
- Calculate the Strength status effect.
- Calculate the Weakness status effect.
- Add the main hand item damage.
For example, the base melee attack damage of a zombie holding a wooden sword with both Strength II and Weakness I effects would be calculated as:
3 (Zombie base attack value) (3 × 1.3 + 1) × 1.3 + 1 = 7.37 (Strength II) 7.37 × 0.8 - 0.5 = 5.396 (Weakness I) 5.396 + 4 (Wooden sword damage) = 9.396
The attack damage of the main hand items is shown in the table below (not including the player's 1HP base attack value, so the values are 1 less than what is displayed in-game):
| Item | Attack Damage | |||||
|---|---|---|---|---|---|---|
| Sword | ||||||
| Shovel | ||||||
| Pickaxe | ||||||
| Axe | ||||||
| Hoe | ||||||
| Trident | ||||||
| Mace | ||||||
| Other Items | 0HP | |||||
The Strength status effect can be calculated using the recursive formula or the general formula , where is the input attack damage, is the output attack damage, and is the level of the Strength status effect.
The Weakness status effect can be calculated using the recursive formula or the general formula , where is the input attack damage, is the output attack damage, and is the level of the Weakness status effect. If the result is less than 0, the output attack damage is 0.
Enchantment attack damage
The enchantments on items in the main hand will affect attack damage, referred to here as enchantment attack damage.
For different entities, enchantments have different attack damage:
- Sharpness works on all entities. In Java Edition, it is calculated as , where is the level of the Sharpness enchantment; In Bedrock Edition, each level generates 1.25HP × 0.625 attack damage.
- Smite only works on undead mobs, generating 2.5HP × 1.25 attack damage per level.
- Bane of Arthropods only works on arthropods, generating 2.5HP × 1.25 attack damage per level.
- Impaling only works on aquatic mobs or mobs in water or touched by rain, generating 2.5HP × 1.25 attack damage per level.
The total of all enchantment attack damage is the current enchantment attack damage. In Bedrock Edition, enchantment attack damage is rounded down after summing, so if Sharpness I and Smite I are both active, the enchantment attack damage would be 3HP instead of 3.75HP × 1.875.
Bonus attack damage
After calculating the base melee attack damage and enchantment attack damage, the game also determines whether to add a bonus attack damage based on the nature of the current main hand item and the state of the attacked entity. Currently, only mace has bonus attack damage.
The bonus attack damage of the mace only takes effect when the entity falls from a height greater than 1.5 blocks and not gliding, with the bonus attack damage adjusted according to the fall height:
- If the fall height f is greater than 1.5 blocks but not more than 3 blocks, the bonus attack damage is .
- If the fall height f is greater than 3 blocks but not more than 8 blocks, the bonus attack damage is .
- If the fall height f is greater than 8 blocks, the bonus attack damage is .
- If the mace has the density enchantment and the enchantment level is I, an additional bonus attack damage is added according to the fall height f.
Critical hit

Critical hits are melee attacks that deal extra damage compared to normal attacks, and they can be performed by players with any item (including bare hands).
To perform a critical hit, the following conditions must be met:
- The player must be falling, meaning the fall height must be greater than 0. This also means the player cannot have the Slow Falling or Levitation effects.
- The player must not be touching the ground, meaning they must not be standing on any surface with block collision boxes.
- The player must not be inside climbable blocks (like ladders, vines, cobwebs, or trapdoors that are open on the same side as a ladder).
- The player must not be in water.
- The player must not be riding any entity.
- The player must not have the Blindness effect.
- In Java Edition, the player must be attacking a mob, another player or armor stand. This prevents critical hits on the ender dragon, as attacks on the ender dragon target its parts, which are not considered as mobs, thus making critical hits impossible.
- In Java Edition, the player's attack cooldown must be at 84.8% or above.
- Ordinarily, players cannot perform critical hits while sprinting, because a sprint-knockback attack is performed instead. However, by continuing to hold down the sprint key after performing a sprint-knockback attack, all successive hits can be critical hits, and sprint-knockback attacks become impossible until the sprint key is released. In Bedrock Edition and the Java Edition Combat Tests, players can perform critical hits and sprint-knockback attacks simultaneously.
- If the player started sprinting before leaving the ground and no conditions to stop sprinting are met in midair, it will be considered a sprinting state and a critical hit cannot be performed.
- If the player was not sprinting before leaving the ground or canceled the sprinting state in midair (e.g., by attacking another entity and generating sufficient knockback, or releasing the forward key), a critical hit can be performed.
- It is possible to re-enter sprinting in midair, but due to a desynchronization between the client and server, the server might not recognize the player is sprinting, allowing for a critical hit even though the client indicates the player is sprinting. The client must cancel sprinting and then attempt to sprint again to synchronize properly.
In Java Edition, critical hits increase base melee attack damage and bonus attack damage by 50%, without affecting enchantment attack damage[1]. In Bedrock Edition, critical hits increase overall melee attack damage by 50%.
For example, consider a player holding a stick with Smite IV and landing a critical hit on a skeleton:
Base melee attack damage: 1 (player base attack value) Enchantment attack damage: 2.5 × 4 = 10 (Smite IV) Java Edition critical hit: 1 × 1.5 + 10 = 11.5 Bedrock Edition critical hit: (1 + 10) × 1.5 = 16.5
For example, consider a player with Strength II using a netherite sword with Sharpness V and landing a critical hit on a mob:
1 (player base attack damage) + 7 (Netherite Sword attack damage) = 8 8 + 3 × 2 = 14 (Strength II) 14 × 1.5 = 21 (Critical Hit) 21 + 0.5 × 5 + 0.5 = 24 (Sharpness V)
1 (player base attack damage) + 8 (Netherite Sword attack damage) = 9 (9 × 1.3 + 1) × 1.3 + 1 = 17.51 (Strength II) 17.51 + floor(1.25 × 5) = 23.51 (Sharpness V) 23.51 × 1.5 = 35.625 (Critical Hit)
When a critical hit is successfully performed, small star-shaped particles will burst out of the hit entity. In Java Edition, a loud sound is also generated, distinguishing it from normal attacks.
Sprint-knockback attack
Attacking while sprinting causes a sprint-knockback attack to be performed, causing extra knockback and playing a unique sound. Sprint-knockback attacks require an attack cooldown charge of at least 84.8% in Java Edition, and performing a sprint-knockback attack cancels a sprint.
Sweep attack
When a player attacks with a sword, they can perform a sweep attack that damages nearby entities and generates "sword sweep" particles.
A sweep attack occurs only if all of the following conditions are met:
- The attack cooldown is at 84.8% or above.
- The player is not performing a critical hit.
- The player is not sprinting.
- The player is on the ground, meaning they must be standing on any solid surface.
- The player's main-hand weapon is a sword.
- The player's melee attack is successful.
- The difference in movement distance between the current game tick and the previous tick does not exceed the
movement_speedattribute value (default: 0.1 blocks per tick, or 2 blocks per second).
The range of a sweep attack is determined by both the attacked entity and the player's position. Based on the attacked entity's collision box, the range extends 1 block horizontally in all directions and 0.25 blocks vertically both up and down. All entities within 3 blocks of the player (excluding the attacking player themselves, the primary attacked entity, and armor stands with the [Boolean] Marker tag set to true) will be affected by the sweep attack.
By default, a sweep attack deals 1HP damage. However, this damage can be increased using the Sweeping Damage Ratio attribute. If the calculated value of sweeping_damage_ratio is r, and the sum of base melee attack damage and additional attack damage is d, the sweep attack damage is calculated as .
The Sweeping Edge enchantment increases the Sweeping Damage Ratio attribute, thereby increasing sweep attack damage. If the level of Sweeping Edge is n, then the Sweeping Damage Ratio increases by . By default, Sweeping Edge I, II, and III increase sweep attack damage by 50%, 67%, and 75% of the base melee attack damage plus additional attack damage, respectively.
Similar to melee attacks, sweep attacks also apply knockback. However, knockback from sweep attacks is not affected by the knockback enchantment or sprinting. If the affected entity has 0 knockback resistance, the sweep attack applies a knockback speed of 0.4 blocks per tick.
Attack cooldown
Reason: The attack cooldown necessary for doing critical hits, sprint-knockback attacks, and sweep attacks is 84.8% or above, not 90%. The table should be updated to have values based on that, instead.


The indicator below the crosshair is partially transparent, as well as inverting the color behind it.
Players are affected by attack cooldown, which reduces damage when attacking too quickly in melee. This forces players to control their attack frequency rather than repeatedly pressing the attack button at an extremely high rate.
The time from one melee attack, breaking a block, or switching the main-hand item to the next melee attack that can deal full damage is called the attack cooldown time. The ratio of the time elapsed since the above actions to the total attack cooldown time is the attack cooldown completion. The number of full-damage melee attacks a player can perform per 20 game ticks (1 second) is the attack speed.
Attack speed is controlled by the attack_speed attribute. The default value is 4, meaning that 4 full-damage melee attacks can be performed per 20 game ticks (1 second), however damage immunity allows only 2 of these attacks to connect. The item in the main hand can affect the current attack speed.
Haste increases attack speed by 10% per level, while
Mining Fatigue decreases attack speed by 10% per level.
Attack cooldown time can be calculated from attack speed. If the attack speed is , the attack cooldown time is game ticks. Since game ticks do not have decimal values, the actual attack cooldown time is rounded: if the decimal part is greater than 0.5, it is rounded up; otherwise, it is rounded down.
Attack cooldown completion can also be calculated from these values. If the time since the last melee attack, block break, or main-hand item switch is game ticks, then the attack cooldown completion is . The visual component related to attack cooldown completion is the attack indicator, which has a slight difference in rendering percentage compared to the actual attack cooldown completion: , meaning the displayed value lags by half a game tick.
| Item | Attack speed / 84.8% cooldown time / attack cooldown time (calculated and rounded) | |||||
|---|---|---|---|---|---|---|
| Sword | ||||||
| Shovel | ||||||
| Pickaxe | ||||||
| Axe | ||||||
| Hoe | ||||||
| Trident | ||||||
| Mace | ||||||
| Other items | 4 / 5 / 5 | |||||
Attack cooldown affects base melee attack damage, enchanted attack damage, and additional attack damage differently. Given attack cooldown completion , the base melee attack damage is modified by , the enchanted attack damage by , while additional attack damage remains unaffected. The effect on base melee attack damage can stack with critical hits.
For example, a player with Strength II holding a Sharpness V wooden axe lands a critical hit on the 23rd game tick after a melee attack:
Base melee attack damage
1 (player base attack damage)
+ 6 (wooden axe attack damage, modifier Op0, value 6)
+ 6 (Strength II effect, modifier Op0, value 6)
= 13
Enchanted attack damage
0.5 × 5 + 0.5 (Sharpness V)
= 3
Attack cooldown completion
(23 + 0.5) / (20 / 0.8)
= 94%
Adjusted base melee attack damage
× (0.2 + 0.8 × 0.94 × 0.94) (attack cooldown)
× 1.5 (critical hit)
= 17.68416
Adjusted enchanted attack damage
× 0.94 (attack cooldown)
= 2.82
Final attack damage: 17.68416 + 2.82 = 20.50416
Damage calculator
Attack resolution and attack failure
When performing a melee attack, the game first calculates the attack damage the attacker can deal, then applies damage to the attacked entity and attempts to disable the shield. After damage is dealt, it calculates knockback, sweep attack, and Fire Aspect, processes the Thorns enchantment's reflected damage, applies Slowness effect by the Bane of Arthropods to arthropods, and may generate critical hit particles. Finally, the player's exhaustion increases by 0.1 per successful melee attack.
Melee attacks can fail, and failed melee attacks do not deal damage.
- If an entity's base melee attack damage is 0HP and enchanted attack damage is 0HP, the melee attack always fails, making no sound and triggering no damage event. This also prevents players from damaging end crystals and armor stands with melee attacks in such cases.
- If an entity can deal more than 0HP damage but the attacked entity is immune to this damage or is in a dying state, the melee attack fails, producing a special sound different from a successful melee attack.
- If an entity's attack damage is not greater than the last damage of the attacked entity's damage immunity, the melee attack fails, producing a distinct sound.
- In all other cases, a melee attack is considered successful, even if the damage is completely negated by the target's defense or damage immunity.
A failed melee attack does not consume item durability, does not apply knockback, sweep attack, fire aspect, or shield disabling, and does not generate critical hit particles or increase the player's exhaustion.
Knockback
When melee attack damage is dealt, the attacked entity will be pushed backward; this is knockback. The horizontal direction of knockback aligns with the attacker's viewpoint.
The magnitude of knockback depends on whether the attacker is sprinting and the item in their main hand. This is described using knockback strength. Knockback strength is 0 by default. If the main-hand item has the knockback enchantment, the knockback strength increases by the enchantment's level.
In Java Edition, only players can knock back non-living entities. Knockback strength determines the knockback speed, which is half of the knockback strength. If the target of the knockback is a non-living entity, it receives a vertical motion of 0.1 blocks per tick (2 blocks per second) and a horizontal knockback speed. If the target is a living entity, the knockback speed is reduced based on its knockback resistance (attribute knockback_resistance). If the knockback resistance is 1, knockback does not occur. Next, the entity's horizontal movement speed is halved, and knockback speed is applied. If the entity is touching the ground, its vertical speed is also halved, and upward knockback speed is applied. However, the final vertical speed does not exceed 0.4 blocks per tick (8 blocks per second). After knockback occurs, the attacking entity immediately stops sprinting, and their horizontal speed is reduced to 60% of its original value.
Sounds
| Sounds | ||||||||
|---|---|---|---|---|---|---|---|---|
| Sound | Subtitles | Source | Description | Resource location | Translation key | Volume | Pitch | Attenuation distance |
| Strong attack | Players | When a player deals an attack that does not trigger any other attack sounds | entity | subtitles | varies [sound 1] | 1.0 | 16 | |
| Critical attack | Players | When a player deals a critical hit | entity | subtitles | 0.7 | 1.0 | 16 | |
| Knockback attack | Players | When a player deals a sprinting attack | entity | subtitles | 0.7 | 1.0 | 16 | |
| Sweeping attack | Players | When a player deals a sweep attack | entity | subtitles | 0.7 | 1.0 | 16 | |
| Weak attack | Players | When a player deals an attack with no damage | entity | subtitles | 0.7 | 1.0 | 16 | |
| Weak attack | Players | When a player attempts to attack without sufficient cooldown | entity | subtitles | 0.7 | 1.0 | 16 | |
- ↑ 0.6 for
strong1throughstrong4, and 0.7 forstrong5andstrong6
| Sounds | |||||
|---|---|---|---|---|---|
| Sound | Source | Description | Resource location | Volume | Pitch |
| Players | When a player dies | entity | 0.5 | 0.9-1.0 | |
| Players | When a player is damaged from a generic source | entity | varies [sound 1] | 0.8-1.2 | |
- ↑ Can be 0.5, 1.0, or 1.5
History
| Java Edition Beta | |||||||
|---|---|---|---|---|---|---|---|
| 1.5 | The player's base attack damage increased from 1HP to 2HP. | ||||||
| 1.8 | ? | The player's base attack damage decreased from 2HP to 1HP. | |||||
| Java Edition | |||||||
| ? | Melee attacks now fail if the attack damage does not exceed the target's last damage immunity threshold. | ||||||
| 1.9 | 15w34b | Added the "Attack Speed" attribute. | |||||
| 1.9 | 15w34c | Added the sweep attack mechanic for swords, only dealing knockback effect. | |||||
| 1.9 | 15w49a | Sweep attack now deals 1HP damage to entities. | |||||
| 1.15.2 | Pre-Release 1 | Removed an extra pixel from the bottom right corner of the critical hit particle texture. | |||||
| 1.20.2 | 23w33a | Changed the way melee attack reach is calculated for entities. | |||||
| 1.21 | 24w18a | Sweep attack damage is now calculated based on base melee damage and additional damage rather than total melee attack damage. | |||||
| Bedrock Edition | |||||||
| 1.18.30 | beta 1.18.30.20 | Reduced unarmed damage from 2HP to 1HP to match Java Edition. | |||||
| 1.20.50 | Preview 1.20.50.22 | Changed the way melee attack reach is calculated for entities. | |||||
References
| General mechanics | |
|---|---|
| Survival |
|
| Combat | |
| Environment |
More |
| Movement | |
| User interface | |
| Visuals | |
| Outdated | |