
Command
/attribute
Reads or changes an attribute of a living entity, such as its maximum health, movement speed, or size.
| /attribute <target> <attribute> base get [<scale>] |
| /attribute <target> <attribute> base reset |
| /attribute <target> <attribute> base set <value> |
| /attribute <target> <attribute> get [<scale>] |
| /attribute <target> <attribute> modifier add <id> <value> (add_multiplied_base|add_multiplied_total|add_value) |
| /attribute <target> <attribute> modifier remove <id> |
| /attribute <target> <attribute> modifier value get <id> [<scale>] |
| Argument | Kind of value | What to type |
|---|---|---|
| <target> | Target selector | The entity to read or change. Must be exactly one entity. One entity only. |
| <attribute> | Game id | The attribute id, for example minecraft:max_health, minecraft:movement_speed, minecraft:attack_damage, or minecraft:scale. The id of an attribute. |
| <scale> | Decimal number | A number the value is multiplied by before it is returned as the number /execute store saves. Defaults to 1. |
| <value> | Decimal number | For base set, the new base value. For modifier add, the amount the modifier applies. |
| <id> | Id | The namespaced id of the modifier, for example example:boost. You choose it when adding a modifier and use it again to read or remove it. |
| Permission level | 2: operators, worlds with cheats on, command blocks and functions |
| Works in | Singleplayer with cheats enabled and multiplayer servers. Needs permission level 2 (gamemasters): server operators, players with cheats, command blocks, and functions can all run it. |
| Result | Get commands report the value and return it multiplied by the scale, with the decimals cut off. Commands that set, reset, add, or remove report what changed and return 1. |
| get | Shows the final value of the attribute, with all modifiers applied. |
| base get | Shows the base value of the attribute, before any modifiers. |
| base set | Sets the base value of the attribute to the given number. |
| base reset | Puts the base value back to the default for that kind of entity and reports the default. |
| modifier add | Adds a permanent modifier with the given id, value, and operation. Fails if the attribute already has a modifier with that id. |
| modifier remove | Removes the modifier with the given id. Fails if the attribute has no such modifier. |
| modifier value get | Shows the value of one modifier. Fails if the attribute has no modifier with that id. |
| Operations | add_value adds the value to the base. add_multiplied_base adds the base (after all add_value modifiers) multiplied by the value. add_multiplied_total multiplies the running total by 1 plus the value. They are applied in that order. |
| Target must be alive | The target must be a single living entity such as a player or a mob. Other entities fail with "is not a valid entity for this command", and an entity that does not have the chosen attribute fails with "has no attribute". |
| Scale | The scale defaults to 1. Use a larger scale to keep decimals in the number /execute store saves, for example 100 turns 0.1 into 10. |
/attribute @s minecraft:max_health getShows your maximum health.
/attribute @s minecraft:max_health base set 40Sets your base maximum health to 40, which is 20 hearts.
/attribute @s minecraft:scale base set 2Makes you twice as large.
/attribute @s minecraft:movement_speed modifier add example:sprint_boost 0.5 add_multiplied_baseAdds a modifier that makes you move 50 percent faster.
/attribute @s minecraft:movement_speed modifier remove example:sprint_boostRemoves that speed modifier again.
/attribute @s minecraft:scale base resetReturns you to your normal size.

