mojira.dev
MC-278392

Swapping to an enchanted item during an attack preserves the damage of the first item but can apply the second item's enchantments

When you attack an entity or a player with an item right as you swap to a different item that is enchanted, the damage of the first item will be preserved, but the enchantments of the second item will be applied.

Steps to Reproduce:

Spawn a fresh husk for each attack step, so that the base health is always 20:

/summon husk ~ ~ ~ {NoAI:1b}
  1. In a repeating command block, display the husk's health for ease of viewing:

    execute as @n[type=minecraft:husk] run title @a actionbar {"entity":"@s","nbt":"Health"}
  2. Attack it with a wooden sword, and immediately swap to a netherite sword during the attack.
    → ✔ Roughly 4 damage is done

[media]
  1. Attack it with a wooden sword, and immediately swap to a netherite sword with
    sharpness V during the attack.
    → ❌ Roughly 7 damage is done

[media]

Expected Result:

Swapping to an enchanted item from a regular item would not apply enchantment modifiers to the first item. If damage of the first item is preserved, so should enchantments.

Observed Behavior:

When the player attacks with a wooden sword and swaps to a netherite sword, the damage of the wooden sword is preserved as expected. When the second attack is done though (swapping to an enchanted netherite sword) the damage of the wooden sword is kept, but the enchantment of the netherite sword (sharpness V) is applied to the wooden sword.

Linked issues

Attachments

Comments 3

Can confirm.

Duplicate of MC-28289.

[Mod] ManosSef

After a lot of testing, I have determined this to be a duplicate of MC-28289, as Dhranios pointed out. From my testing, following the outlined steps to reproduce with a wooden sword with no enchantments and a netherite sword with Fire Aspect deals roughly 4 damage and applies the fire effect, and following the same steps but replacing the wooden sword with an empty main hand deals roughly 1 damage and applies the fire effect. Therefore, the only inaccuracy is the damage applied, which is controlled by the attack_damage attribute, making this a duplicate of MC-28289.

[Mod] Jingy

(Unassigned)

Unconfirmed

(Unassigned)

1.21.3, 24w46a

Retrieved