mojira.dev
MC-267500

Attribute modifier on an item with the first and/or last 2 integers of the UUID being 0 are non-functional

Pretty straightforward:

/give @s stick{AttributeModifiers:[{AttributeName:"minecraft:generic.movement_speed",Name:"test",Amount:0.5d,Operation:0,UUID:[I;0,0,0,0],Slot:"mainhand"}]}
/give @s stick{AttributeModifiers:[{AttributeName:"minecraft:generic.movement_speed",Name:"test",Amount:0.5d,Operation:0,UUID:[I;0,0,0,1],Slot:"mainhand"}]}
/give @s stick{AttributeModifiers:[{AttributeName:"minecraft:generic.movement_speed",Name:"test",Amount:0.5d,Operation:0,UUID:[I;0,0,1,1],Slot:"mainhand"}]}
/give @s stick{AttributeModifiers:[{AttributeName:"minecraft:generic.movement_speed",Name:"test",Amount:0.5d,Operation:0,UUID:[I;0,1,1,1],Slot:"mainhand"}]}
/give @s stick{AttributeModifiers:[{AttributeName:"minecraft:generic.movement_speed",Name:"test",Amount:0.5d,Operation:0,UUID:[I;0,1,1,0],Slot:"mainhand"}]}
/give @s stick{AttributeModifiers:[{AttributeName:"minecraft:generic.movement_speed",Name:"test",Amount:0.5d,Operation:0,UUID:[I;0,1,0,0],Slot:"mainhand"}]}
/give @s stick{AttributeModifiers:[{AttributeName:"minecraft:generic.movement_speed",Name:"test",Amount:0.5d,Operation:0,UUID:[I;0,1,0,1],Slot:"mainhand"}]}

Observe how only a few of those items have a functional attribute modifier (note, only difference between the commands is the UUID)

Functional commands: 4, 5, 7
Non-functional commands: 1, 2, 3, 6

Comments 1

Did a code analysis, it seems like Minecraft just discards all attribute modifiers where the first two or the last two numbers of the UUID are 0:

net.minecraft.world.item.ItemStack

public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlot slot) {
    // ...
    AttributeModifier modifier = AttributeModifier.load(tag);
    if (modifier == null) {
        continue;
    }

    if (modifier.getId().getLeastSignificantBits() != 0L && modifier.getId().getMostSignificantBits() != 0L) {
        map.put(attribute, modifier);
    }
    // ...
}

user-f2760

gegy

Confirmed

Platform

Normal

Commands

1.20.4, 23w51b

24w09a

Retrieved