87 lines
4.1 KiB
Text
87 lines
4.1 KiB
Text
{{exclusive|java}}
|
|
{{Infobox command
|
|
|name=attribute
|
|
|oplevel=2
|
|
}}
|
|
|
|
Used to change or read [[attribute]]s.
|
|
|
|
== Syntax ==
|
|
:<code>attribute <target> <attribute> get [<scale>]</code>
|
|
::Returns the total value of the specified attribute.
|
|
:<code>attribute <target> <attribute> base get [<scale>]</code>
|
|
::Returns the base value of the specified attribute.
|
|
:<code>attribute <target> <attribute> base set <value></code>
|
|
::Overwrites the base value of the specified attribute with the given value.
|
|
:<code>attribute <target> <attribute> base reset</code>
|
|
::Resets the base value of the specified attribute to its default value.
|
|
:<code>attribute <target> <attribute> modifier add <id> <value> (add_value|add_multiplied_base|add_multiplied_total)</code>
|
|
::Adds an attribute modifier with the specified properties if no modifier with the same ID already existed.
|
|
:<code>attribute <target> <attribute> modifier remove <id></code>
|
|
::Removes the attribute modifier with the specified ID.
|
|
:<code>attribute <target> <attribute> modifier value get <id> [<scale>]</code>
|
|
::Returns the value of the modifier with the specified ID.
|
|
|
|
== Arguments ==
|
|
{{argument|target|entity}}
|
|
: The [[entity]] that the [[attribute]] is applied to. Only [[player]]s, [[armor stand]]s, and [[mob]]s have attributes.
|
|
: {{arg desc|je=entity|type=entities|amount=single}}
|
|
|
|
{{argument|attribute|resource}}
|
|
: Specifies the [[Attribute#Attributes|attribute]].
|
|
: {{arg desc|je=resource|registry=minecraft:attribute}}
|
|
|
|
{{argument|scale|double}}
|
|
: The number the value is multiplied with before being stored with {{cmd|execute}} command.
|
|
: {{arg desc|je=double}}
|
|
|
|
{{argument|id|resource_location}}
|
|
: Specifies the id of a [[Attribute#Modifiers|modifier]].
|
|
: {{arg desc|je=resource_location}}
|
|
|
|
{{argument|value|double}}
|
|
: Specifies the value to use.
|
|
: {{arg desc|je=double}}
|
|
|
|
== Result ==
|
|
{{Result table|onlyje=1}}
|
|
{{Result table|The command is incomplete, or any argument is not specified correctly.|unparseable}}
|
|
{{Result table|<code><targets></code> fails to resolve to a player, an armor stand, or a mob.|fail}}
|
|
{{Result table|The attribute doesn't exist for the entity (for example, a player entity has no <code>minecraft:horse.jump_strength</code>).}}
|
|
{{Result table|cmd=/... modifier add ...|A modifier with the specified ID is already present.}}
|
|
{{Result table|cmd=/... modifier remove ...<br>/... modifier value get ...|The modifier with the specified ID doesn't exist.}}
|
|
{{Result table|cmd=|succeed}}
|
|
{{Result table}}
|
|
|
|
== Output ==
|
|
{{Output table}}
|
|
{{Output table|edition=je|On fail|0|0|0}}
|
|
{{Output table|cmd=/... get [<scale>]|On success|1|1|The attribute value (multiplied by {{cd|<scale>}}, then cast to int)}}
|
|
{{Output table|cmd=/... base get [<scale>]|On success|1|1|The attribute base value (multiplied by {{cd|<scale>}}, then cast to int)}}
|
|
{{Output table|cmd=/... modifier value get <id> [<scale>]|On success|1|1|The modifier value (multiplied by {{cd|<scale>}}, then cast to int)}}
|
|
{{Output table|cmd=/... base set ...<br>/... modifier add ...<br>/... modifier remove ...|On success|1|1|1}}
|
|
{{Output table}}
|
|
|
|
== Examples ==
|
|
* To set the minimum armor value of the current entity to 5:
|
|
*: <code>/attribute @s minecraft:generic.armor base set 5</code>
|
|
|
|
== History ==
|
|
{{HistoryTable
|
|
|{{HistoryLine|java}}
|
|
|{{HistoryLine||1.16|dev=20w17a|Added {{cmd|attribute|link=none}}.}}
|
|
|{{HistoryLine||1.18.2|dev=1.18.2-pre3|Changed from {{cd|resource_location}} to {{cd|resource}} [[argument type]] for the attribute argument.}}
|
|
|{{HistoryLine||1.20.5|dev=24w09a|Modifier operations have been renamed: <code>add</code> -> <code>add_value</code>, <code>multiply_base</code> -> <code>add_multiplied_base</code>, <code>multiply</code> -> <code>add_multiplied_total</code>.}}
|
|
|{{HistoryLine||1.21|The <code>uuid</code> and <code>name</code> arguments have been replaced with a singular <code>id</code> argument.|dev=24w21b}}
|
|
|{{HistoryLine||1.21.4|dev=24w44a|Added {{cmd|attribute <target> <attribute> base reset|link=none}}.
|
|
|Suggestions will now be shown for attribute modifier IDs existing on the target.}}
|
|
}}
|
|
|
|
== Navigation ==
|
|
{{Navbox commands}}
|
|
|
|
[[de:Befehl/attribute]]
|
|
[[es:Comandos/attribute]]
|
|
[[ja:コマンド/attribute]]
|
|
[[pt:Comandos/attribute]]
|
|
[[zh:命令/attribute]]
|