mojira.dev
MC-272769

Attribute modifiers with the same ID are incorrectly removed when one of the items is unequipped

Equipping two items with an attribute modifier of the same ID and affected attribute and unequipping one of them removes the modifier even when the other item is still equipped.

How to reproduce:

  1. Execute the following command: 

    /give @s carved_pumpkin[attribute_modifiers={modifiers:[{type:"movement_speed",id:"speedy",operation:"add_value",amount:1d,slot:"any"}]}] 2
  2. Make sure the pumpkins are not selected in your hotbar, then put one of the pumpkins on your head.
    → ✔ You will have the speed effect, as intended.

  3. Now scroll past the other pumpkin in your hotbar.
    → ❌ As soon as you unselect the pumpkin in the hotbar, the speed modifier will be removed, even though the pumpkin is still on your head.

Expected result:

An attribute modifier would still be present even after unequipping one item with the modifier but keeping another.

Observed result:

An attribute modifier is removed after unequipping one item with the modifier, even if another item with the modifier is still equipped.

Linked issues

Comments 2

This issue can also occur even if the attribute modifiers don't use slot:"any", so I've made this report a bit more generic. You can see this issue apply to different values of slot by trying these steps:

  1. Execute the following commands:

    /give @s carved_pumpkin[attribute_modifiers={modifiers:[{type:"movement_speed",id:"speedy",operation:"add_value",amount:1d,slot:"head"}]}]
    /give @s carved_pumpkin[attribute_modifiers={modifiers:[{type:"movement_speed",id:"speedy",operation:"add_value",amount:1d,slot:"mainhand"}]}]
  2. Wear the first pumpkin on your head.

  3. Hold the second pumpkin in your main hand by selecting it in your hotbar.

  4. Switch to a different slot in your hotbar.
    → ❌ The modifier is removed even though you're still wearing the first pumpkin.

Note that attribute modifiers are supposed to have different IDs to prevent this: MC-274223.

Let me ask you this: if you have 2 items with attribute modifiers, of the same attribute and same ID, but different effects (eg 1 = +2 other = +5), how do you expect the game to differenciate?

42Richtofen42

(Unassigned)

Confirmed

Platform

Normal

Commands, Items

1.20.6, 1.21 Pre-Release 1, 1.21, 24w40a, 1.21.3

Retrieved