mojira.dev
MC-274538

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

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

[media]
  1. 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.

Linked issues

Attachments

Comments 3

Please add steps to reproduce the issue.

Confirmed. @unknown, that screenshot doesn't really show the issue. I've attached

[media]

instead (I've modified the data pack slightly to also play a sound when hitting an entity).

SilentPaltos

(Unassigned)

Confirmed

Platform

Normal

Data Packs, Enchantments

1.21, 1.21.1, 24w34a

Retrieved