/attribute

This feature is exclusive to Java Edition.
 
/attribute
Permission level
required

2

Restrictions

None

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> base reset
Resets the base value of the specified attribute to its default value.
attribute <target> <attribute> modifier add <id> <value> (add_value|add_multiplied_base|add_multiplied_total)
Adds an attribute modifier with the specified properties if no modifier with the same ID already existed.
attribute <target> <attribute> modifier remove <id>
Removes the attribute modifier with the specified ID.
attribute <target> <attribute> modifier value get <id> [<scale>]
Returns the value of the modifier with the specified ID.

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]Double-precision floating-point number (from -(2-2-52)×21023 (≈-1.8×10308) to (2-2-52)×21023 (≈1.8×10308) ).

<id>: resource_location

Specifies the id of a modifier.
Must be a resource location for an unregistered content.

<value>: double

Specifies the value to use.
Must be a [Double]Double-precision floating-point number (from -(2-2-52)×21023 (≈-1.8×10308) to (2-2-52)×21023 (≈1.8×10308) ).

Result

CommandTriggerJava Edition
AnyThe command is incomplete, or any argument is not specified correctly. Unparseable
<targets> fails to resolve to a player, an armor stand, or a mob. Failed
The attribute doesn't exist for the entity (for example, a player entity has no minecraft:flying_speed).
/... modifier add ...A modifier with the specified ID is already present.
/... modifier remove ...
/... modifier value get ...
The modifier with the specified ID doesn't exist.
AnyOtherwiseSuccessful

Output

CommandEditionSituationSuccess Count/execute store success .../execute store result ...
AnyJava EditionOn fail000
/... get [<scale>]On success11The attribute value (multiplied by <scale>, then cast to int)
/... base get [<scale>]On success11The attribute base value (multiplied by <scale>, then cast to int)
/... modifier value get <id> [<scale>]On success11The modifier value (multiplied by <scale>, then cast to int)
/... base set ...
/... modifier add ...
/... modifier remove ...
On success111

Examples

  • To set the minimum armor value of the current entity to 5:
    /attribute @s minecraft:armor base set 5

History

Java Edition
1.1620w17aAdded /attribute.
1.18.21.18.2-pre3Changed from resource_location to resource argument type for the attribute argument.
1.20.524w09aModifier operations have been renamed: addadd_value, multiply_baseadd_multiplied_base, multiplyadd_multiplied_total.
1.2124w21bThe uuid and name arguments have been replaced with a singular id argument.
1.21.424w44aAdded /attribute <target> <attribute> base reset.
Suggestions will now be shown for attribute modifier IDs existing on the target.

Navigation