Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. 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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.21.3, 24w46a
    • None
    • Unconfirmed
    • (Unassigned)

      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
        wood-netherite.mp4
      3. Attack it with a wooden sword, and immediately swap to a netherite sword with
        sharpness V during the attack.
        Roughly 7 damage is done
        wood-enchanted-netherite.mp4

      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.

        1. wood-enchanted-netherite.mp4
          481 kB
          [Helper] Jiingy
        2. wood-enchanted-wood.mp4
          711 kB
          [Helper] Jiingy
        3. wood-netherite.mp4
          2.23 MB
          [Helper] Jiingy

            Unassigned Unassigned
            Jingy [Helper] Jiingy
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: