Guides / Commands & Data

/attribute: base value versus modifiers, and why yours keeps resetting

Setting a base value is permanent and setting a modifier is not — unless you pick the wrong operation. The three operations, the stacking order, and the slot trap.

/attribute looks like one command with three subcommands. It is really two different systems that happen to share a name, and mixing them up is why values keep snapping back.

base versus modifier

/attribute @s minecraft:max_health base set 40
/attribute @s minecraft:max_health modifier add my_buff 20 add_value
  • base set rewrites the entity's own value. It persists through reloads and is

not removed by anything except another base set.

  • modifier add layers a temporary adjustment on top. It has an id, and it can be

removed by that id.

If your change disappears on relog, you used a modifier and something cleared it. If your change will not go away, you used base set and need base reset.

The three operations, and the order they apply

OperationDoesApplied
add_valuevalue + nfirst
add_multiplied_basevalue + (base × n)second
add_multiplied_totalrunning total × (1 + n)last

The order is fixed and it matters. Starting from base 20, then add_value 10 and add_multiplied_total 0.5:

20 → 30 → 45          not  20 → 30 → 30 + 10 = 40

add_multiplied_base always multiplies the original base, not the running total — which is why two of them stack additively rather than compounding.

Modifier ids are namespaced now

Older versions used a UUID. Modern versions use a namespaced id:

/attribute @s minecraft:attack_damage modifier add my_pack:rage 5 add_value

Adding a second modifier with the same id replaces the first rather than stacking. That is the intended way to refresh a buff — you do not need to remove it first.

Equipment modifiers live on the item, not the entity

An enchanted sword's damage bonus is an attribute_modifiers item component, and it only applies while the item is in the right slot:

/give @s diamond_sword[attribute_modifiers=[{type:"attack_damage",amount:5,
  operation:"add_value",slot:"mainhand",id:"my:bonus"}]]

slot is required and is the usual mistake. Omit it and the modifier applies in every slot, so a sword in your inventory buffs you while it sits there.

Valid slots: mainhand, offhand, head, chest, legs, feet, armor, body, any.

Reading a value back

/attribute @s minecraft:max_health get

returns the base, not the effective total. To get the total including modifiers, use execute store result on a scoreboard and read that.

Build any of these — including the item-component form with the slot set — in the Entity & Combat Command Builder.

Open the Entity & Combat Command Builder →

More guides

Browse all →

Looking for more Minecraft tools?

A suite of client-side generators, viewers and converters — all free, all in your browser.