Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-274538

"post_attack" does not trigger if "enchanted": "attacker" unless the enchanted item is used to attack

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.21, 1.21.1, 24w34a
    • None
    • Confirmed
    • Data Packs, Enchantments
    • Normal
    • Platform

      In a custom enchantment, when using the post_attack enchantment component for the attacking entity, the effect does not apply unless the attacking entity uses the enchanted item to attack.

      Steps to reproduce

      1. Download the attached datapack SayMyName_datapack.zip and apply it to the world
      2. Enchant a helmet with /enchant @s saymyname:say_my_name
      3. Hit any mob using the enchanted helmet
        → A message by the attacked entity will appear in chat
      4. Place the helmet in your head slot and hit any entity using an item that is not enchanted with this enchantment

      Expected results

      Because the enchanted helmet is equipped, it should still apply the enchantment and a message should show up, since the enchantment is defined for both mainhand and head slots.

      Observed results

      When the helmet is in the head slot, there is no message in chat.

      Note

      The enchantment works if the post_attack effect is executed by the victim:

      "enchanted": "victim",
      "affected": "attacker"
      

      (i.e. what the Thorns enchantment does). However, this means the message is from the attacked entity, not the attacker.

        1. 2024-07-19 18-08-56.mp4
          1.99 MB
          [Mod] violine1101
        2. image-2024-07-19-17-41-00-137.png
          1.37 MB
          BugTracker

            Unassigned Unassigned
            SilentPaltos SilentPaltos
            Votes:
            9 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              CHK: