无编辑摘要 标签:源代码编辑 |
(Arguments) |
||
第8行: | 第8行: | ||
== 语法 == |
== 语法 == |
||
− | :<code>attribute < |
+ | :<code>attribute <target> <attribute> [base] get [<scale>]</code> |
− | :<code>attribute < |
+ | :<code>attribute <target> <attribute> base set <value></code> |
− | :<code>attribute < |
+ | :<code>attribute <target> <attribute> modifier add <uuid> <name> <value> (add|multiply|multiply_base)</code> |
− | :<code>attribute < |
+ | :<code>attribute <target> <attribute> modifier remove <uuid></code> |
− | :<code>attribute < |
+ | :<code>attribute <target> <attribute> modifier value get <uuid> [<scale>]</code> |
=== 具体用法 === |
=== 具体用法 === |
||
− | :<code>attribute < |
+ | :<code>attribute <target> <attribute> ...</code> |
− | ::<code>... get [< |
+ | ::<code>... get [<scale>]</code> |
:::返回指定属性的总值。 |
:::返回指定属性的总值。 |
||
− | ::<code>... base get [< |
+ | ::<code>... base get [<scale>]</code> |
:::返回指定属性的基值。 |
:::返回指定属性的基值。 |
||
− | ::<code>... base set < |
+ | ::<code>... base set <value></code> |
:::用给定值覆盖指定属性的基值。 |
:::用给定值覆盖指定属性的基值。 |
||
::<code>... modifier (add|remove|value get)</code> |
::<code>... modifier (add|remove|value get)</code> |
||
− | :::<code>... add < |
+ | :::<code>... add <uuid> <name> <value> (add|multiply|multiply_base)</code> |
::::如果已不存在具有相同UUID的修饰符,则添加具有指定属性的属性修饰符。 |
::::如果已不存在具有相同UUID的修饰符,则添加具有指定属性的属性修饰符。 |
||
− | :::<code>... remove < |
+ | :::<code>... remove <uuid></code> |
::::删除具有指定UUID的属性修饰符。 |
::::删除具有指定UUID的属性修饰符。 |
||
− | :::<code>... value get < |
+ | :::<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>< |
+ | {{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: |
* <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的版本
此特性为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
{{argument|attribute|resource_location}
<scale>
:double
<uuid>
:uuid
<name>
:string
- 指定该属性修饰器的名称。
- 必须为字符串。且必须为带引号词组(单个词或者引号括起的字符串,允许的字符包括:
-
、+
、.
、_
、A
-Z
、a
-z
和0
-9
)。
<value>
:double
- 指定使用的值。
- 必须为双精度浮点数。
结果
命令 | 触发条件 | Java版 |
---|---|---|
任意 | 不正确的参数 | 无法解析 |
<target> 无法解析为单个实体(指定的玩家必须在线) | 执行失败 | |
... modifier add ... | 修饰符已经存在 | |
... set ... | 值为无效的双精度(64位整数)值 | |
任意 | 执行成功时 | 更改或返回属性值。 |
输出
命令 | 版本 | 条件 | 成功次数 | /execute store success ... | /execute store result ... |
---|---|---|---|---|---|
任意 | Java版 | 执行失败 | 0 | 0 | 0 |
... get [<scale>] | 执行成功 | 1 | 1 | 指定属性的值 (乘以 <倍率> ),小数会向下取整。) | |
... base get [<scale>] | 执行成功 | 1 | 1 | 指定属性的基值 (乘以 <倍率> ),小数会向下取整。) | |
... modifier value get <uuid> [<scale>] | 执行成功 | 1 | 1 | 指定属性修饰符的值 (乘以 <倍率> ),小数会向下取整。) | |
... base set ... | 执行成功 | 1 | 1 | 1 |
示例
将自己的基础盔甲值设定为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.16 | 20w17a | 加入了/attribute 。 |