mojira.dev
MC-298861

Armor bar display doesnt seem to work with custom armor values

I am currently working on a datapack in which i have made some custom armor sets, while working on these i noticed that the armor bar display seems a bit off.

when equipping only one item it works fine(see image 1)here i have an otherwise unmodified potato that i made equipable and gave it +2 armor.
If i now equip another piece of vegetable(a beet, see image 2) the armor bar now displays 4 armor, but hold up! The potato gives +2 and the beet gives +4, and +2 + +4 = +6, !! but thats not what is displayed. It seems it displays the armor value of the most recently equiped vegetable instead of my current armor

For this next exhibit, i have equiped a tougher beet, this time giving +10 armor whiole the potato remains unchanged, i equiped the potato last so the armor bar displays 2 armor.
I then disable natural regen, heal up, and apply 10 damage from player_attack to myself and i take 4.5 hearts of damage (see image 4)

When i repeat the experiment but equip the tough beet last, my armor bar now displays 10 armor and i take only 4 hearts of damage(see image 5)

Another variant we can do is to equip beet, then equip potato such that the armor bar displays +2, if we then unequip the potato, naturally we lose 2 armor so we are left with 0 despite having a real tough beet on our feet. (image 6)
Now if we take 10 damage from a player attack we take full damage(5 hearts) and receive no damage reduction :( (image 7)

I have scouered the internet for people sharing my sadness but i have found none so i am open to the possibility of this being my fault(barely) as i have limited experience working with datapacks.

I am also aware of potential workarounds such as making a score that stores armor values and changes as you equip something, then changing players' armor attributes with the /attribute command but this seems like work and i’d rather not.

If you need anything more from me i would beet( : D ) more than glad to help :)

Would be most lovely to hear from you soon :D

Potato:

/give @p potato[attribute_modifiers=[{id:"armor",type:"armor",amount:2,operation:"add_value",slot:"head"}],equippable={slot:"head"}] 1

Normie beet:

/give @p beetroot[attribute_modifiers=[{id:"armor",type:"armor",amount:4,operation:"add_value",slot:"feet"}],equippable={slot:"feet"}] 1

Tough beet:

/give @p beetroot[attribute_modifiers=[{id:"armor",type:"armor",amount:10,operation:"add_value",slot:"feet"}],equippable={slot:"feet"}] 1

Attachments

Comments 1

Hi! This issue is caused by multiple items having the same attribute modifier ID. If different modifier IDs are used instead, then the provided commands give armor items that work fine when used together. As per https://www.minecraft.net/en-us/article/minecraft-snapshot-24w21a “Using the same ID for different modifiers is allowed as long as the modifiers are for different attributes”. Hence we do not support the usage of the same modifier IDs on different items.

NIkolai :O

(Unassigned)

Confirmed

Platform

Normal

Commands, Data Packs, Items

1.21.6

Retrieved