Minecraft Wiki

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

了解更多

Minecraft Wiki
无编辑摘要
标签源代码编辑
(Arguments)
第8行: 第8行:
   
 
== 语法 ==
 
== 语法 ==
:<code>attribute <''目标''> <''属性''> [base] get [<''倍率''>]</code>
+
:<code>attribute <target> <attribute> [base] get [<scale>]</code>
:<code>attribute <''目标''> <''属性''> base set <''值''></code>
+
:<code>attribute <target> <attribute> base set <value></code>
:<code>attribute <''目标''> <''属性''> modifier add <''uuid''> <''名称''> <''值''> (add|multiply|multiply_base)</code>
+
:<code>attribute <target> <attribute> modifier add <uuid> <name> <value> (add|multiply|multiply_base)</code>
:<code>attribute <''目标''> <''属性''> modifier remove <''uuid''></code>
+
:<code>attribute <target> <attribute> modifier remove <uuid></code>
:<code>attribute <''目标''> <''属性''> modifier value get <''uuid''> [<''倍率''>]</code>
+
:<code>attribute <target> <attribute> modifier value get <uuid> [<scale>]</code>
   
 
=== 具体用法 ===
 
=== 具体用法 ===
:<code>attribute <''目标''> <''属性''> ...</code>
+
:<code>attribute <target> <attribute> ...</code>
::<code>... get [<''倍率''>]</code>
+
::<code>... get [<scale>]</code>
 
:::返回指定属性的总值。
 
:::返回指定属性的总值。
   
::<code>... base get [<''倍率''>]</code>
+
::<code>... base get [<scale>]</code>
 
:::返回指定属性的基值。
 
:::返回指定属性的基值。
   
::<code>... base set <''值''></code>
+
::<code>... base set <value></code>
 
:::用给定值覆盖指定属性的基值。
 
:::用给定值覆盖指定属性的基值。
   
 
::<code>... modifier (add|remove|value get)</code>
 
::<code>... modifier (add|remove|value get)</code>
:::<code>... add <''uuid''> <''名称''> <''值''> (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''> [<''倍率''>]</code>
+
:::<code>... value get <uuid> [<scale>]</code>
 
::::返回具有指定UUID的修饰符的值。
 
::::返回具有指定UUID的修饰符的值。
   
 
== 参数 ==
 
== 参数 ==
  +
{{argument|target|entity}}
;<code>''目标''</code>
 
:应用[[属性]]的实体,只接受单个目标,只有玩家、生物和盔甲架有属性。
+
: 应用[[属性]]的实体只有玩家、生物和盔甲架有属性。
  +
: {{arg desc|je=entity|type=entities|amount=single}}
   
  +
{{argument|attribute|resource_location}
;<code>''属性''</code>
 
:指定[[属性]]的[[命名空间ID]]。
+
: 指定[[属性]]的[[命名空间ID]]。
  +
: {{arg desc|je=resource_location}}
   
  +
{{argument|scale|double}}
;<code>''倍率''</code>
 
 
:用于<code>/[[命令/execute#存储子命令|execute]] store result</code>命令,将获取的值与该值相乘的数字作为返回值(小数会向下取整)。
 
:用于<code>/[[命令/execute#存储子命令|execute]] store result</code>命令,将获取的值与该值相乘的数字作为返回值(小数会向下取整)。
  +
: {{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}}
   
 
== 结果 ==
 
== 结果 ==
第52行: 第64行:
 
{{Result table|onlyje=1}}
 
{{Result table|onlyje=1}}
 
{{Result table|不正确的参数|unparseable}}
 
{{Result table|不正确的参数|unparseable}}
{{Result table|<code><目标></code> 无法解析实体(指定的玩家必须在线)|fail}}
+
{{Result table|<code><target></code> 无法解析为单个实体(指定的玩家必须在线)|fail}}
 
{{Result table|cmd=... modifier add ...|修饰符已经存在}}
 
{{Result table|cmd=... modifier add ...|修饰符已经存在}}
 
{{Result table|cmd=... set ...|值为无效的双精度(64位整数)值}}
 
{{Result table|cmd=... set ...|值为无效的双精度(64位整数)值}}
第69行: 第81行:
   
 
== 示例 ==
 
== 示例 ==
将自己的最小盔甲值设定为5:
+
将自己的基础盔甲值设定为5:
   
 
* <code>/attribute @s minecraft:generic.armor base set 5</code>
 
* <code>/attribute @s minecraft:generic.armor base set 5</code>

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