Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
(// Edit via Wikiplus)
(Arguments)
(未显示12个用户的17个中间版本)
第1行: 第1行:
 
{{Tr|mode=H|基值|基礎值}}
 
{{Tr|mode=H|基值|基礎值}}
{{snapshot|java}}
 
{{exclusive|java}}
 
<onlyinclude>
 
 
{{Infobox command
 
{{Infobox command
|attribute
+
|name=attribute
  +
|oplevel=2
|op
 
|1.16|20w17a
 
 
}}
 
}}
 
{{exclusive|java}}
 
用于更改或读取[[属性]]。
 
用于更改或读取[[属性]]。
   
 
== 语法 ==
 
== 语法 ==
:<code>attribute <''target''> <''attribute''> [base] get [<''scale''>]</code>
+
:<code>attribute <target> <attribute> [base] get [<scale>]</code>
:<code>attribute <''target''> <''attribute''> base set <''value''></code>
+
:<code>attribute <target> <attribute> base set <value></code>
:<code>attribute <''target''> <''attribute''> modifier add <''uuid''> <''name''> <''value''> (add|multiply|multiply_base)</code>
+
:<code>attribute <target> <attribute> modifier add <uuid> <name> <value> (add|multiply|multiply_base)</code>
:<code>attribute <''target''> <''attribute''> modifier remove <''uuid''></code>
+
:<code>attribute <target> <attribute> modifier remove <uuid></code>
:<code>attribute <''target''> <''attribute''> modifier value get <''uuid''> [<''scale''>]</code>
+
:<code>attribute <target> <attribute> modifier value get <uuid> [<scale>]</code>
   
 
=== 具体用法 ===
 
=== 具体用法 ===
:<code>attribute <''target''> <''attribute''> ...</code>
+
:<code>attribute <target> <attribute> ...</code>
::<code>... get [<''scale''>]</code>
+
::<code>... get [<scale>]</code>
 
:::返回指定属性的总值。
 
:::返回指定属性的总值。
   
::<code>... base get [<''scale''>]</code>
+
::<code>... base get [<scale>]</code>
 
:::返回指定属性的基值。
 
:::返回指定属性的基值。
   
::<code>... base set <''value''></code>
+
::<code>... base set <value></code>
 
:::用给定值覆盖指定属性的基值。
 
:::用给定值覆盖指定属性的基值。
   
 
::<code>... modifier (add|remove|value get)</code>
 
::<code>... modifier (add|remove|value get)</code>
:::<code>... add <''uuid''> <''name''> <''value''> (add|multiply|multiply_base)</code>
+
:::<code>... add <uuid> <name> <value> (add|multiply|multiply_base)</code>
 
::::如果已不存在具有相同UUID的修饰符,则添加具有指定属性的属性修饰符。
 
::::如果已不存在具有相同UUID的修饰符,则添加具有指定属性的属性修饰符。
   
:::<code>... remove <''uuid''></code>
+
:::<code>... remove <uuid></code>
 
::::删除具有指定UUID的属性修饰符。
 
::::删除具有指定UUID的属性修饰符。
   
:::<code>... value get <''uuid''> [<''scale''>]</code>
+
:::<code>... value get <uuid> [<scale>]</code>
 
::::返回具有指定UUID的修饰符的值。
 
::::返回具有指定UUID的修饰符的值。
   
 
== 参数 ==
 
== 参数 ==
;<code><target></code>
+
{{argument|target|entity}}
:应用[[属性]]的实体,只接受单个目标,只有玩家、生物和盔甲架有属性。
+
: 应用[[属性]]的实体只有玩家、生物和盔甲架有属性。
  +
: {{arg desc|je=entity|type=entities|amount=single}}
   
;<code><attribute></code>
+
{{argument|attribute|resource_location}
:指定[[属性]]的[[命名空间ID]]。
+
: 指定[[属性]]的[[命名空间ID]]。
  +
: {{arg desc|je=resource_location}}
   
  +
{{argument|scale|double}}
;<code><scale></code>
 
  +
:用于<code>/[[命令/execute#存储子命令|execute]] store result</code>命令,将获取的值与该值相乘的数字作为返回值(小数会向下取整)。
:在返回值之前与该值相乘的数字。{{verify}}
 
  +
: {{arg desc|je=double}}
   
  +
{{argument|uuid|uuid}}
;<code><uuid></code>
 
 
:以[[UUID#String|字符串格式]]指定[[属性#已知修饰符|修饰符]]的[[UUID]]。具有相同UUID的修饰符不堆叠。
 
:以[[UUID#String|字符串格式]]指定[[属性#已知修饰符|修饰符]]的[[UUID]]。具有相同UUID的修饰符不堆叠。
  +
: {{arg desc|je=uuid}}
  +
  +
{{argument|name|string}}
  +
: 指定该属性修饰器的名称。
  +
: {{arg desc|je=string|type=phrase}}
  +
  +
{{argument|value|double}}
  +
: 指定使用的值。
  +
: {{arg desc|je=double}}
   
 
== 结果 ==
 
== 结果 ==
使用<code>get</code>时,如果修饰符已经存在,则失败。
 
   
  +
{{Result table|onlyje=1}}
使用<code>set</code>时,如果值为无效的双精度(64位整数)值,则失败。
 
  +
{{Result table|不正确的参数|unparseable}}
  +
{{Result table|<code><target></code> 无法解析为单个实体(指定的玩家必须在线)|fail}}
  +
{{Result table|cmd=... modifier add ...|修饰符已经存在}}
 
{{Result table|cmd=... set ...|值为无效的双精度(64位整数)值}}
 
{{Result table|cmd=|succeed|更改或返回属性值。}}
  +
{{Result table}}
   
 
== 输出 ==
成功时,更改或返回属性值。
 
  +
  +
{{Output table}}
  +
{{Output table|edition=je|执行失败|0|0|0}}
  +
{{Output table|cmd=... get [<scale>]|执行成功|1|1|指定属性的值 (乘以 {{cd|<倍率>}}),小数会向下取整。)}}
  +
{{Output table|cmd=... base get [<scale>]|执行成功|1|1|指定属性的基值 (乘以 {{cd|<倍率>}}),小数会向下取整。)}}
  +
{{Output table|cmd=... modifier value get <uuid> [<scale>]|执行成功|1|1|指定属性修饰符的值 (乘以 {{cd|<倍率>}}),小数会向下取整。)}}
  +
{{Output table|cmd=... base set ...<br>... modifier add ...<br>... modifier remove ...|执行成功|1|1|1}}
  +
{{Output table}}
   
 
== 示例 ==
 
== 示例 ==
* 将自己的最小盔甲值设定为5:
+
将自己的基础盔甲值设定为5:
*: <code>/attribute @s minecraft:generic.armor base set 5</code>
 
   
 
* <code>/attribute @s minecraft:generic.armor base set 5</code>
== 历史 ==
 
   
  +
将所有玩家的最大生命值设置为2(经典极限生存):
{{History|java upcoming}}
 
  +
  +
* <code>/execute as @a run attribute @s minecraft:generic.max_health base set 2</code>
  +
  +
== 历史 ==
 
{{History|java}}
 
{{History||1.16|snap=20w17a|加入了{{cmd|attribute|link=none}}。}}
 
{{History||1.16|snap=20w17a|加入了{{cmd|attribute|link=none}}。}}
 
{{History|foot}}
 
{{History|foot}}
第73行: 第99行:
 
[[en:Commands/attribute]]
 
[[en:Commands/attribute]]
 
[[pt:Comandos/attribute]]
 
[[pt:Comandos/attribute]]
  +
[[tr:Komutlar/attribute]]

2021年12月17日 (五) 17:42的版本

attribute
需要的权限等级

2

限制条件

Information icon
此特性为Java版独有。

用于更改或读取属性

语法

attribute <target> <attribute> [base] get [<scale>]
attribute <target> <attribute> base set <value>
attribute <target> <attribute> modifier add <uuid> <name> <value> (add|multiply|multiply_base)
attribute <target> <attribute> modifier remove <uuid>
attribute <target> <attribute> modifier value get <uuid> [<scale>]

具体用法

attribute <target> <attribute> ...
... get [<scale>]
返回指定属性的总值。
... base get [<scale>]
返回指定属性的基值。
... base set <value>
用给定值覆盖指定属性的基值。
... modifier (add|remove|value get)
... add <uuid> <name> <value> (add|multiply|multiply_base)
如果已不存在具有相同UUID的修饰符,则添加具有指定属性的属性修饰符。
... remove <uuid>
删除具有指定UUID的属性修饰符。
... value get <uuid> [<scale>]
返回具有指定UUID的修饰符的值。

参数

<target>entity

应用属性的实体。只有玩家、生物和盔甲架有属性。
必须为玩家名、目标选择器或UUID。且目标选择器只允许1个实体。

{{argument|attribute|resource_location}

指定属性命名空间ID
必须为命名空间ID

<scale>double

用于/execute store result命令,将获取的值与该值相乘的数字作为返回值(小数会向下取整)。
必须为双精度浮点数

<uuid>uuid

字符串格式指定修饰符UUID。具有相同UUID的修饰符不堆叠。
必须为带连字符的十六进制UUID。接受下列字符:
  • -
  • A-F
  • a-f
  • 0-9

<name>string

指定该属性修饰器的名称。
必须为字符串。且必须为带引号词组(单个词或者引号括起的字符串,允许的字符包括:-+._A-Za-z0-9)。

<value>double

指定使用的值。
必须为双精度浮点数

结果

命令触发条件Java版
任意不正确的参数 无法解析
<target> 无法解析为单个实体(指定的玩家必须在线) 执行失败
... modifier add ...修饰符已经存在
... set ...值为无效的双精度(64位整数)值
任意执行成功时更改或返回属性值。

输出

命令版本条件成功次数/execute store success .../execute store result ...
任意Java版执行失败000
... get [<scale>]执行成功11指定属性的值 (乘以 <倍率>),小数会向下取整。)
... base get [<scale>]执行成功11指定属性的基值 (乘以 <倍率>),小数会向下取整。)
... modifier value get <uuid> [<scale>]执行成功11指定属性修饰符的值 (乘以 <倍率>),小数会向下取整。)
... base set ...
... modifier add ...
... modifier remove ...
执行成功111

示例

将自己的基础盔甲值设定为5:

  • /attribute @s minecraft:generic.armor base set 5

将所有玩家的最大生命值设置为2(经典极限生存):

  • /execute as @a run attribute @s minecraft:generic.max_health base set 2

历史

Java版
1.1620w17a加入了/attribute