Minecraft:Commands/attribute: Difference between revisions
More actions
→Examples: added another example |
Fix template calls: add MC/ prefix |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{MC/Exclusive|java}} | ||
{{Infobox command | {{Infobox command | ||
|name=attribute | |name=attribute | ||
| Line 24: | Line 24: | ||
== Arguments == | == Arguments == | ||
{{ | {{MC/Argument|target|entity}} | ||
: The | : The entity that the [[Minecraft:attribute]] is applied to. Only players, armor stands, and [[Minecraft:mob]]s have attributes. | ||
: {{ | : {{MC/Arg desc|je=entity|type=entities|amount=single}} | ||
{{ | {{MC/Argument|attribute|resource}} | ||
: Specifies the [[Minecraft:Attribute#Attributes|attribute]]. | : Specifies the [[Minecraft:Attribute#Attributes|attribute]]. | ||
: {{ | : {{MC/Arg desc|je=resource|registry=minecraft:attribute}} | ||
{{ | {{MC/Argument|scale|double}} | ||
: The number the value is multiplied with before being stored with {{ | : The number the value is multiplied with before being stored with {{MC/Cmd|execute}} command. | ||
: {{ | : {{MC/Arg desc|je=double}} | ||
{{ | {{MC/Argument|id|resource_location}} | ||
: Specifies the id of a [[Minecraft:Attribute#Modifiers|modifier]]. | : Specifies the id of a [[Minecraft:Attribute#Modifiers|modifier]]. | ||
: {{ | : {{MC/Arg desc|je=resource_location}} | ||
{{ | {{MC/Argument|value|double}} | ||
: Specifies the value to use. | : Specifies the value to use. | ||
: {{ | : {{MC/Arg desc|je=double}} | ||
== Result == | == Result == | ||
| Line 55: | Line 55: | ||
== Output == | == Output == | ||
{{Output table}} | {{MC/Output table}} | ||
{{Output table|edition=je|On fail|0|0|0}} | {{MC/Output table|edition=je|On fail|0|0|0}} | ||
{{Output table|cmd=/... get [<scale>]|On success|1|1|The attribute value (multiplied by {{ | {{Output table|cmd=/... get [<scale>]|On success|1|1|The attribute value (multiplied by {{MC/Cd|<scale>}}, then cast to int)}} | ||
{{Output table|cmd=/... base get [<scale>]|On success|1|1|The attribute base value (multiplied by {{ | {{Output table|cmd=/... base get [<scale>]|On success|1|1|The attribute base value (multiplied by {{MC/Cd|<scale>}}, then cast to int)}} | ||
{{Output table|cmd=/... modifier value get <id> [<scale>]|On success|1|1|The modifier value (multiplied by {{ | {{Output table|cmd=/... modifier value get <id> [<scale>]|On success|1|1|The modifier value (multiplied by {{MC/Cd|<scale>}}, then cast to int)}} | ||
{{Output table|cmd=/... base set ...<br>/... modifier add ...<br>/... modifier remove ...|On success|1|1|1}} | {{MC/Output table|cmd=/... base set ...<br>/... modifier add ...<br>/... modifier remove ...|On success|1|1|1}} | ||
{{Output table}} | {{MC/Output table}} | ||
== Examples == | == Examples == | ||
| Line 72: | Line 72: | ||
== History == | == History == | ||
{{HistoryTable | {{HistoryTable | ||
|{{HistoryLine|java}} | |{{MC/HistoryLine|java}} | ||
|{{HistoryLine||1.16|dev=20w17a|Added {{ | |{{HistoryLine||1.16|dev=20w17a|Added {{MC/Cmd|attribute|link=none}}.}} | ||
|{{HistoryLine||1.18.2|dev=1.18.2-pre3|Changed from {{ | |{{HistoryLine||1.18.2|dev=1.18.2-pre3|Changed from {{MC/Cd|resource_location}} to {{MC/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>.}} | |{{MC/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}} | |{{MC/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 {{ | |{{HistoryLine||1.21.4|dev=24w44a|Added {{MC/Cmd|attribute <target> <attribute> base reset|link=none}}. | ||
|Suggestions will now be shown for attribute modifier IDs existing on the target.}} | |Suggestions will now be shown for attribute modifier IDs existing on the target.}} | ||
}} | }} | ||
== Navigation == | == Navigation == | ||
{{Navbox commands}} | {{MC/Navbox commands}} | ||
de:Befehl/attribute | |||
es:Comandos/attribute | |||
ja:コマンド/attribute | |||
pt:Comandos/attribute | |||
zh:命令/attribute | |||
Latest revision as of 20:08, 9 April 2026
Script error: No such module "Exclusive". Template:Infobox command
Used to change or read Minecraft: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 Minecraft:attribute is applied to. Only players, armor stands, and Minecraft:mobs have attributes.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|entity}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<attribute>: resource
- Specifies the attribute.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|resource}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<scale>: double
- The number the value is multiplied with before being stored with
- REDIRECT Template:Command
Template:Redr command.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|double}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<id>: resource_location
- Specifies the id of a modifier.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|resource_location}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
<value>: double
- Specifies the value to use.
- {{#vardefine:onlyje|}}{{#vardefine:onlybe| Template:IN,}}{{#vardefine:je-arg|double}}{{#vardefine:be-arg|}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}
Result
Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table
Output
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-table-lines|-2}}{{#vardefine:output-table-lines-now|}}{{#vardefine:command-num-now|}}{{#vardefine:command-line-now|}}{{#vardefine:commands-num|}}{{#vardefine:output-edition-num-now|}}{{#vardefine:output-edition-line-now|}}{{#vardefine:output-editions-num|}}{{#vardefine:je-outputs-dis|}}
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On fail}}{{#vardefine:output1-{{#var:output-table-lines}}|0}}{{#vardefine:output2-{{#var:output-table-lines}}|0}}{{#vardefine:output3-{{#var:output-table-lines}}|0}}{{#vardefine:command-row-{{#var:commands-num}}|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-editions-num|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-edition-{{#var:output-editions-num}}|je}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|1}}
Template:Output table
Template:Output table
Template:Output table
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:situation-{{#var:output-table-lines}}|On success}}{{#vardefine:output1-{{#var:output-table-lines}}|1}}{{#vardefine:output2-{{#var:output-table-lines}}|1}}{{#vardefine:output3-{{#var:output-table-lines}}|1}}{{#vardefine:commands-num|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:command-{{#var:commands-num}}|/... base set ...}}{{#vardefine:command-row-{{#var:commands-num}}|1}}{{#vardefine:output-edition-row-{{#var:output-editions-num}}|Expression error: Unrecognized punctuation character "{".}}
/... modifier add ...
/... modifier remove ...
{{#vardefine:output-table-lines|Expression error: Unrecognized punctuation character "{".}}{{#vardefine:output-table-lines|-2}}{{#vardefine:output-table-lines-now|}}{{#vardefine:command-num-now|}}{{#vardefine:command-line-now|}}{{#vardefine:commands-num|}}{{#vardefine:output-edition-num-now|}}{{#vardefine:output-edition-line-now|}}{{#vardefine:output-editions-num|}}{{#vardefine:je-outputs-dis|}}
Examples
- To set the minimum armor value of the current entity to 5:
/attribute @s minecraft:armor base set 5- To set the minimum scale value of the current entity to .5:
/attribute @s minecraft:armor base set .5
History
de:Befehl/attribute es:Comandos/attribute ja:コマンド/attribute pt:Comandos/attribute zh:命令/attribute