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

set_attributes item modifier can add the same attribute modifier twice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.21 Pre-Release 1
    • 24w21b
    • None
    • Community Consensus
    • Commands
    • Important
    • Platform

      Summary
      set_attributes item modifier can add two attribute modifiers for the same attribute with the same ID to an item stack. Although an item stack with two equal modifiers can be created using other means, the item modifier previously did not add two modifiers with the same UUID twice, and this bug is likely due to a coding error.

      Steps to Reproduce

      1. Add the attached data pack.
      2. Get a carved pumpkin.
      3. Run the following command:
        /item modify entity @s hotbar.0 test:cursed_attribute
        
      4. Check the tooltip of the item in the inventory.

      Expected Result
      Only "+2 Armor" is displayed.

      Actual Result
      "+1 Armor" and "+2 Armor" are both displayed.

      Code analysis
      In AttributeModifiersComponent.Entry, an Identifier is compared against EntityAttributeModifier, which always returns false. This makes the check inside AttributeModifiersComponent#with, which should skip duplicate additions, useless.

            gegy1000 [Mojang] Gegy
            apple502j apple502j
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: