This feature is exclusive to Java Edition.
Used to change or read attributes.
Syntax[]
attribute <target> <attribute> get [<scale>]
- Returns the total value of the specified attribute.
attribute <target> <attribute> base get [<scale>]
- Returns the base value of the specified attribute.
attribute <target> <attribute> base set <value>
- Overwrites the base value of the specified attribute with the given value.
attribute <target> <attribute> modifier add <uuid> <name> <value> (add|multiply|multiply_base)
- Adds an attribute modifier with the specified properties if no modifier with the same UUID already existed.
attribute <target> <attribute> modifier remove <uuid>
- Removes the attribute modifier with the specified UUID.
attribute <target> <attribute> modifier value get <uuid> [<scale>]
- Returns the value of the modifier with the specified UUID.
Arguments[]
<target>
: entity
- The entity that the attribute is applied to. Only players, armor stands, and mobs have attributes.
- Must be a player name, a target selector or a UUID. And the target selector must be in single type.
<attribute>
: resource
- Specifies the attribute.
- Must be an existing registered resource location in
minecraft:attribute
registry.
<scale>
: double
- The number the value is multiplied with before being stored with
/execute
command. - Must be a Double-precision floating-point format number.
<uuid>
: uuid
- Specifies the uuid of a modifier.
- Must be a UUID in the hyphenated hexadecimal format. Allowed characters include:
-
A
-F
a
-f
0
-9
<name>
: string
- Specifies the name of a modifier.
- Must be a string. And it must be a quotable phrase, which is either a single word (allowed characters:
-
,+
,.
,_
,A
-Z
,a
-z
, and0
-9
) or a double-quoted string.
<value>
: double
- Specifies the value to use.
- Must be a Double-precision floating-point format number.
Result[]
Command | Trigger | Java Edition |
---|---|---|
any | the arguments are not specified correctly | Unparseable |
<targets> fails to resolve to a player, an armor stand, or a mob | Failed | |
the attribute doesn't exist (for example,a player entity has no minecraft:horse.jump_strength ) | ||
... modifier add ... | a modifier with the specified uuid is already present | |
... modifier remove ... | the modifier with the specified uuid doesn't exist | |
any | Otherwise | Successful |
Output[]
Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
---|---|---|---|---|---|
any | Java Edition | On fail | 0 | 0 | 0 |
... get [<scale>] | On success | 1 | 1 | The attribute value (multiplied by <scale> , then cast to int) | |
... base get [<scale>] | On success | 1 | 1 | The attribute base value (multiplied by <scale> , then cast to int) | |
... modifier value get <uuid> [<scale>] | On success | 1 | 1 | The modifier value (multiplied by <scale> , then cast to int) | |
... base set ... | On success | 1 | 1 | 1 |
Examples[]
- To set the minimum armor value of the current entity to 5:
/attribute @s minecraft:generic.armor base set 5
History[]
Java Edition | |||||
---|---|---|---|---|---|
1.16 | 20w17a | Added /attribute . | |||
1.18.2 | 1.18.2-pre3 | Changed from resource_location to resource argument type for the attribute argument. |