Minecraft Wiki

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

了解更多

Minecraft Wiki
Advertisement
可列印版不再被支援且可能有渲染錯誤。請更新您的瀏覽器書籤並改用瀏覽器預設的列印功能。
Information icon
此特性為Java版獨有。

attribute
需要的權限等級

2

限制條件

用於變更或讀取屬性

語法

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個實體。

<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 ...屬性不存在(例如玩家沒有minecraft:horse.jump_strength屬性)
... modifier add ...修飾符已存在
... modifier remove ... modifier value get ...修飾符不存在
任意執行成功時變更或返回屬性值。

輸出

指令版本條件成功次數/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

語言

Advertisement