Commands/attribute

From Minecraft Wiki
Jump to: navigation, search
Information icon.svg
This feature is exclusive to Java Edition.
attribute
Restrictions

Operator

First introduced

JE 1.16.0 (20w17a)

Used to change or read attributes.

Syntax[edit]

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[edit]

<target>: entity

Must be a player name, a target selector or a UUID.  And the target selector must be of single type.
The entity that the attribute is applied to. Only players, armor stands, and mobs have attributes.

<attribute>: resource_location

Must be a namespaced ID.
Specifies the attribute.

<scale>: double

Must be a Double-precision floating-point format number.
The number the value is multiplied with before being returned.

<uuid>: uuid

Must be a UUID in the hyphenated hexadecimal format. Allowed characters include:
  • -
  • A-F
  • a-f
  • 0-9
Specifies the modifier. Modifiers with the same UUID do not stack.

Result[edit]

CommandTriggerJava Edition
anythe arguments are not specified correctly Unparseable
<targets> fails to resolve to a player, a armor stand, or a mob Failed
... modifier add ...the modifier is already present
anyOn successChanges or returns the attribute value.

Output[edit]

CommandEditionSituationSuccess Count/execute store succeess .../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 <uuid> [<scale>]On success11The modifier value (multiplied by <scale>, then cast to int)
... base set ...
... modifier add ...
... modifier remove ...
On success111

Examples[edit]

  • To set the minimum armor value of yourself to 5:
    /attribute @s minecraft:generic.armor base set 5

History[edit]

Java Edition
1.1620w17aAdded /attribute.