指令

出自Minecraft基岩版开发Wiki

指令(Command)是透過輸入特定文字字串而啟動的高級功能。

使用方法[編輯]

在用戶端中,指令透過Minecraft的聊天視窗輸入,透過按下T鍵、鍵喚出聊天視窗。使用/鍵會同時輸入指令必需的前綴斜槓(/),因此這是個實用的快捷鍵。

鍵可瀏覽之前輸入的文字,包含所有之前執行的指令。

在輸入指令時按下Tab ↹鍵會循環顯示目前可用的指令或參數。

當游標在某些參數(比如一個ID)的對應位置時,在文字框上方會展示一個可用值的列表。如果這個參數已經輸入了一半,這個列表則只會展示包含目前輸入內容的值。

指令方塊中,指令可以以前綴斜槓開頭,但不是必須的。在指令方塊中的指令通常還需要一個可選參數,如玩家名稱。

指令也可以在多人伺服器的控制台中輸入,但是應加入前綴/。在英語中,以這種方式執行指令的伺服器管理員被稱為「ghosting」。

大多數指令只能在以下狀況有效:

  • 在Minecraft多人遊戲伺服器遊戲中,由管理員或指令方塊使用。
  • 在其他的多人模式遊戲中,由開啟區域網並允許作弊的玩家,或主持多人遊戲伺服器的玩家使用。
  • 在單人模式中,建立世界時開啟作弊。

權限等級為0的指令所有玩家均可用。詳見權限等級

目標選擇器[編輯]

大多數以實體或玩家作為參數的指令,可以透過某些限定條件來選擇一個或多個實體或玩家,而不必指定實體名或玩家名。要用條件來選擇實體或玩家,應先輸入一個目標選擇器變數,如有需要,還可再使用一個或多個目標選擇器參數以制定具體的條件(可選)。

比如,把標籤為A的玩家的遊戲模式改為創造模式,但不使用玩家名來逐個指明:

/gamemode creative @a[tag=A]


目標選擇器變數[編輯]

目標選擇器變數匯總
變數 功能
@p 距離最近的玩家
@r 隨機玩家
@a 所有玩家
@e 所有實體
@s 指令的執行者
@c 自己的智慧體‌ ‌[僅教育版]
@v 所有智慧體‌ ‌[僅教育版]
@initiator 與NPC互動的玩家

目標選擇器變數用於指定待選目標的大致分類。共有8種變數:

@p
選擇最近的玩家。在伺服器控制台中輸入時,預設基準點為(0, 0, 0)。如果有多個最近的玩家,他們與基準點距離完全相同,那麼會選擇其中最晚進入伺服器的玩家。
目標選擇器參數可以進一步篩選待選目標。例如,@p[m=survival]只會選擇生存模式的玩家中距離最近的玩家,即使有其他非生存模式的玩家更為靠近。
c目標選擇器參數可以用來追加待選目標。例如,@p[c=3]將選擇三個最近的玩家。
若參數c是負值,會反轉選擇目標的順序。例如,@p[c=-1]會選擇最遠的一名玩家。
type參數不適用於@p
@r
選擇隨機玩家。
目標選擇器參數可以進一步篩選待選目標。例如,@r[m=creative]只會隨機選擇創造模式的玩家。
c目標選擇器參數可以用來追加待選目標。例如,@r[c=3](特別地,c=-1在此處並不適用)將隨機選擇三個玩家。
如果沒有使用type參數,@r只會選擇隨機玩家。type參數還可以用來選擇非玩家的實體。例如,@r[type=zombie]會隨機選擇一個殭屍,@r[type=!player]會隨機選擇一個非玩家實體。
@a
選擇所有玩家,包括已死亡玩家。
目標選擇器參數可以進一步篩選待選目標。例如,@a[m=creative]只會選擇創造模式的所有玩家。
type參數不適用於@a
@e
選擇所有實體(包含玩家),但不包含死亡的實體。只有@a@s可以選中死亡的玩家。
目標選擇器參數可以進一步篩選待選目標。例如,@e[type=cow]只會選擇牛。
@s
只選擇唯一一個實體:該指令的執行者,包括已死亡玩家。若指令執行者不是一個實體,比如是指令方塊或伺服器控制台執行指令,則此選擇器不會選中任何東西
目標選擇器參數可用於確定執行者是否會成為目標。例如,@s[type=cow]只會在指令執行者是一頭牛時才會將其選中。
@c
選擇自己的智慧體。‌ ‌[僅教育版]
目標選擇器參數可以用於標記自己的智慧體。例如,/tp @c 50 60 40會將自己的智慧體傳送到指定的位置。
@v
選擇所有的智慧體。‌ ‌[僅教育版]
目標選擇器參數可以用於標記所有的智慧體。例如,/remove @v將移除所有的智慧體。
@initiator
選擇目前與NPC互動的玩家。
對於NPC內建的指令介面,有一個特有的選擇器變數為@initiator,它可以選擇目前與該NPC進行互動(例如開啟NPC對話框、使用NPC按鈕和關閉NPC對話框)的玩家。如果該選擇器用於外置指令,則不會報錯,但不會選擇到任何玩家。
目標選擇器參數可以用於進一步篩選目標,例如,@initiator[m=!1]只會在執行者是與NPC進行互動的非創造模式玩家時才會將其選中。


目標選擇器參數[編輯]

目標選擇器參數匯總
透過座標
參數 選擇標準
x, y, z 座標
rrm 距離
dx, dy, dz 體積尺寸
透過計分板參數
參數 選擇標準
scores 記分項分數
tag 計分板標籤
透過其他特性
參數 選擇標準

c
數量

llm
經驗等級

m
遊戲模式
name 實體名稱

rxrxm
垂直旋轉角度

ryrym
水平旋轉角度
type 實體型別
family

在使用目標選擇器之後,你可以使用參數來限定所要選擇的群組。當使用@a@e時,待選目標從全體篩選成特定的少數。當使用@p@r時,參數將從完整的待選列表縮小到被篩選後的待選列表。當使用@s時,指令執行者只有在所有參數都滿足時才會被選擇,否則指令將執行失敗。

在目標選擇器變數之後附加鍵值對構成的逗號分隔,並包含在方括弧中:

@<变量>[<参数>=<>,<参数>=<>,…]

參數和值不區分大小寫,括弧、等號和逗號旁可以有空格(目標選擇器和第一個方括弧之間除外)。鍵值對只能用逗號分隔。

指定基準點
[x=<>,y=<>,z=<>]
在世界中定義一個位置,用於r參數、rmdxdydz參數。如果沒有這些參數,單獨定義位置是沒有用的,所以將它(並且只有它)應用於@e仍然會選擇世界上的所有實體。
座標可以是整數或像12.34這樣的小數(具體為倍精度浮點數)且不會進行中心校正(center-corrected),這意味著x=0不再自動更正為x=0.5波浪號可用於此參數。
透過距離選擇目標
[r=R] — 只選擇所有小於R個方塊的目標執行指令。
[rm=RM] — 只選擇所有大於RM個方塊的目標執行指令。
支援使用範圍表示,以定義球形區域:
  • @e[rm=10,r=10] — 選擇所有距離執行位置10個方塊的實體。
  • @e[rm=10,r=12] — 選擇所有距離執行位置10至12個方塊之間(包含)的實體。
  • @e[rm=5] — 選擇所有距離執行位置大於5個方塊的實體。
  • @e[r=15] — 選擇所有距離執行位置小於15個方塊的實體。
透過體積尺寸選擇目標
[<x>,<y>,<z>,dx=<>,dy=<>,dz=<>] — 選擇所有位於一定長方體區域內部的目標。體積定義為從基準點開始,向「x」方向(東方)延伸特定格(包括基準點本身,下同),向「y」方向(上方)延伸特定格,並向「z」方向(南方)延伸特定格。
這可以解釋為建立一個由初始位置(<x>, <y>, <z>)至對角線向量(<dx>, <dy>, <dz>)組成的長方體,然後選擇腳部座標與其重疊的所有實體。如果位置參數未定義,則相對於指令執行的位置計算。允許任何值,包括負數和小數。
注意dxdydz用來指定與座標的距離;它們不是指定一個新的座標。
  • @e[x=1,y=2,z=3,dx=4,dy=5,dz=6] — 選擇腳部座標和方塊區域(1~5,2~7,3~9)(或以數學語言來講,範圍是{(x,y,z)|x∈[1,6),y∈[2,8),z∈[3,10)})有重疊的所有實體。
  • @e[x=1,y=2,z=3,dx=0,dy=0,dz=0] — 選擇腳部座標和方塊區域(1,2,3)有重疊的所有實體。
可以將透過按距離來選擇與按體積來選擇組合在一起, 在這種情況下,指令將選擇在兩個區域的重疊內的實體(在基準點的某個半徑範圍內,且不在定義的體積之外)。
透過分數選擇目標
[scores={<记分项>=<>,...}] — 根據指定目標的分數過濾目標。
所有的記分項都放在一個單獨的標籤中,並這個標籤中分別列出分數選擇器。此選擇器支援使用範圍。
  • @e[scores={myscore=10}] — 選擇所有記分項myscore分數為10的目標。
  • @e[scores={myscore=10..12}] — 選擇所有記分項myscore分數為10到12之間(包含)的目標。
  • @e[scores={myscore=5..}] — 選擇所有記分項myscore分數為5及以上的目標。
  • @e[scores={myscore=..15}] — 選擇所有記分項myscore分數為15及以下的目標。
  • @e[scores={foo=10,bar=1..5}] — 選擇所有記分項foo分數為10,且記分項bar分數為1到5之間(包含)的目標。
透過標籤選擇目標
[tag=<标签名>] — 選擇所有有標籤「標籤名」的目標。
[tag=!<标签名>] — 選擇所有沒有標籤「標籤名」的目標。
[tag=] — 選擇所有沒有標籤的目標。
[tag=!] — 選擇所有有標籤的目標。
允許使用多個參數。被選擇的實體必須滿足所有的參數條件。
  • @e[tag=a,tag=b,tag=!c] — 選擇所有擁有標籤a和b,但沒有標籤c的目標。
  • @r[tag=a] — 選擇一個有標籤a的隨機玩家。
指定數量並排序選擇目標
[c=<>] — 通常以距離指令執行點的順序排列。
當使用@p@r變數時,此參數預設為1。對它們使用c參數時會增加選擇最近或隨機目標的數量。當使用@a@e變數時,此參數會限制目標數量。
當輸入的值為負值時,目標的順序會被反轉。舉例來說,@p[c=-3] 會回傳3個最遠的目標,而且,如果所有目標距離都一樣遠,@e[c=-3] 會選擇3個剛載入/生成的目標。
  • @p[c=3] — 選擇距離最近的3名玩家。
  • @p[c=-4] — 選擇距離最遠的4名玩家。
  • @r[c=2] — 隨機選擇2名玩家。
透過經驗等級選擇目標
[l=L] — 只選擇所有經驗等級低於L的目標。
[lm=LM] — 只選擇所有經驗等級高於LM的目標。
此選擇器支援使用範圍。
  • @a[l=10] — 選擇所有10級的玩家。
  • @a[lm=10,l=12] — 選擇所有10級與12級之間(包含)的玩家。
  • @a[lm=5] — 選擇所有至少為5級的玩家。
  • @a[l=15] — 選擇所有至多為15級的玩家。
透過遊戲模式選擇目標
[m=M] — 選擇所有處於指定遊戲模式的玩家。
[m=!M] — 選擇所有不處於指定遊戲模式的玩家。
<遊戲模式>的值可以為adventurecreativesurvivaldefault
這將自動過濾非玩家目標。
M可以為全稱,也可以是數字(0=生存模式,1=創造模式,2=冒險模式,5=預設模式)或縮寫(s=生存模式,c=創造模式,a=冒險模式,d=預設模式)。
  • @a[m=0]@a[m=s] — 選擇所有生存模式的玩家。
  • @a[m=!survival,m=!adventure] — 選擇所有既不是生存模式又不是冒險模式的玩家。
透過名稱選擇目標
[name=<某名称>] — 選擇所有名字為「某名稱」的目標。
[name=!<某名称>] — 選擇所有名字不為「某名稱」的目標。
這是一個字串,包含空格時應當用雙引號括起。不能是JSON文字
  • @e[name=!Steve] — 選擇不叫「Steve」的目標。
透過垂直旋轉選擇目標
[rx=RX] — 僅選擇所有最大垂直旋轉角度為RX的目標。
[rxm=RXM] — 僅選擇所有最小垂直旋轉角度為RXM的目標。
更具體地說,是旋轉高度與地平線的夾角,以度為單位。垂直旋轉值從-90(垂直向上)向上增加,之後增加到0(水平),最後增加到90(豎直向下)(因此垂直旋轉值隨著向下旋轉而增加)。
此選擇器支援範圍。
  • @e[rx=0,rxm=0] — 選擇所有看向地平線的目標。
  • @e[rx=60,rxm=30] — 選擇所有看向地平線偏下30°至60°(包含)的目標。
  • @e[rxm=45] — 選擇所有看向地平線偏下45°(包含)及更低的目標。
  • @e[rx=0] — 選擇所有看向地平線偏上的目標。
透過水平旋轉選擇目標
[ry=RY] — 僅選擇最大水平旋轉為RY的目標。
[rym=RYM] — 僅選擇最小水平旋轉為RYM的目標。
其角度以正南(或正Z軸方向)為基準順時針旋轉。水平旋轉值從-180(面向正北)開始,到-90(面向正東),再到0(面向正南),再到90(面向正西),最後到180(再次面向正北)。
此選擇器支援範圍。
  • @a[ry=0,rym=0] — 選擇所有看向正南的玩家。
  • @a[ry=45,rym=45] — 選擇所有看向南偏西45°的玩家。
  • @a[ry=96,rym=96] — 選擇所有看向西偏北6°的玩家。
  • @a[ry=0,rym=-90] — 選擇所有看向正東和正南(包含)之間的玩家。
  • @a[ry=90,rym=-90] — 選擇所有看向正東和正西之間(包含)的玩家,區域穿過正南。
  • @a[rym=0] — 選擇所有不看向南方(包含)和東方之間的玩家。
透過實體型別選擇目標
[type=<实体类型>] — 選擇所有特定的實體型別的目標。
[type=!<实体类型>] — 選擇所有不是特定的實體型別的目標。
實體型別必須使用有效的實體ID或或實體標籤。如果實體ID的命名空間在minecraft:內則可以省略命名空間。(舉例來說,minecraft:creeper指定苦力怕,minecart指定普通礦車,tnt指定點燃的TNT等等)實體ID或標籤區分大小寫。
當與@r一起使用時,原本用來選擇玩家的指令也可以被用來選擇其他實體。
  • @e[type=skeleton] — 選擇所有骷髏。
  • @e[type=!chicken,type=!cow] — 選擇所有除雞和牛之外的目標。
  • @e[type=chicken,type=cow] — 無效選擇:選擇所有既是雞又是牛的目標(不存在)。
透過族選擇目標
[family=<>] — 選擇屬於指定的族的實體。
[family=!<>] — 選擇不屬於指定的族的實體。
給定的實體的族可以是任何字串,但不包括命名空間。這些實體的族在實體型別的族行為元件中定義。原版行為包使用的預設值包括更廣泛的大型族(例如mobinanimatemonsterundead)以及更具體的小型族(例如zombieskeleton)和單個生物的族(例如wandering_traderendermancreeper)。單個實體可以屬於多個族。
  • @e[family=skeleton] — 選擇所有骷髏、凋零骷髏和流髑。
  • @e[family=mob,family=!monster] — 選擇所有不是攻擊型生物的生物(例如:會選中牛和豬,但不會選中殭屍和骷髏)。
  • @e[family=monster,family=undead] — 選擇所有是不死生物的攻擊型生物(例如:會選中殭屍和骷髏,但不會選中苦力怕和終界使者)。


相對座標和局部座標[編輯]

世界座標被視作絕對座標。很多指令可以使用波浪號~)來指定相對座標,使用插入符^)來指定局部座標(也有人稱本地座標)。在波浪號和插入符後可以跟一個數字,表示相對基準點的偏移量。基準點由指令本身決定。舉例來說,常見的基準點包括指令的執行位置和指令指定的其他座標。局部座標的基準點預設為是腳部。

相對座標以世界的絕對座標為偏移量。局部座標以執行者的頭部為基準點,並在包括頭部的傾斜角度下分別指向左、上、前方為座標軸 x y z 的正方向。無論是哪一個,數字的正負號都表示向座標軸的正或負方向偏移。一個單獨的波浪號~~0的簡寫,表示沒有偏移。同樣地,^^0的簡寫。

舉例來說,/tp 0 64 0將會移動使用者到座標(0, 64, 0),而/tp ~3 ~ ~-3會使使用者往x軸的正方向(東方)移動3米,保持原本高度,並在z軸的負方向(北方)移動3米,而/tp ^ ^ ^3會使使用者往前移動3米。

通常絕對座標和相對座標可以混合使用,但局部座標不可與絕對或相對座標混合使用。舉例來說,/tp ~ 64 ~會保持執行者的x軸和z軸座標,但是將傳送執行者到絕對高度64。/tp ^-5 ^ ^將根據頭部的傾斜,將玩家向右傳送5個方塊的距離。

多個指令參數有時可以不需要空格,如~~~可以代表~ ~ ~~~1~可以代表~ ~1 ~,比如/tp @a ~1 ~2 ~3可以簡寫為/tp @a ~1~2~3。注意~~1不能代表~ ~ 1,因為~1會被視為一個整體,而1~不會。

原始JSON文字[編輯]

原始JSON文字可以作用於/tellraw的內容、/titleraw的標題、書和羽毛筆的文字(題目和作者除外)、告示牌的文字以及NPC的對話的編輯(操作員在編輯時,效果不可見)。

權限等級[編輯]

權限等級用於控制指令執行者可以執行什麼指令。比如/kick不能在指令方塊中執行,因為這個指令需要3的權限等級,而指令方塊的權限等級僅為1

權限等級可為01234

  • 指令方塊或指令方塊礦車的權限等級為1
  • 伺服器控制台的權限等級為4
  • 函式和附加包中的腳本的權限等級為1
  • /execute執行子指令的權限等級為1[需要驗證]
  • 對於玩家來說:
    • 如果該玩家在伺服器中,且該玩家在「玩家權限」畫面中的「操作員指令」開關已開啟,那麼他的權限等級預設為1(可在server.properties中變更)。
    • 如果該玩家在單人遊戲世界或區域網世界中,且該玩家在「玩家權限」畫面中的「操作員指令」開關已開啟,那麼他的權限等級預設為3
    • 否則,他的權限等級為0。‌[需要測試]

註:指令的權限等級與暫停選單和「玩家權限」畫面中的身分(訪客,成員,操作員或自訂)不同。例如在單人遊戲世界中,身分為操作員的玩家的權限等級為3,因為其對應的「操作員指令」開關已開啟;身分為訪客或成員的玩家的權限等級為0,因為其對應的「操作員指令」開關沒有開啟。

指令列表[編輯]

指令概述
指令 描述 權限等級 指令旗標1 指令旗標2
/? 提供指令使用幫助。 0 8 64
/ability 賦予或剝奪玩家的能力。 1 0 0
/addrider 為一個實體加入騎手。 1
/agent 操縱智慧體。 1 6 0
/aicreate 為生物建立AI意向。 1
/aigoals 開關實體頂部的AI意向的資訊繪製。 1
/aistop 停用實體的AI意向 1
/alwaysday 鎖定或解鎖日夜循環。 1 0 0
/audioaction commands.audioaction.description 1
/automate 執行自動化行為樹。 1
/bhave 執行行為樹。 1
/bossbar 修改或查詢Boss欄。 0
/bounds 開關實體邊界箱的繪製。 1
/camera commands.camera.description 1
/camerashake 啟用鏡頭抖動效果。 1 0 0
/changedimension 傳送玩家到一個在其它維度的位置。 1
/changename 變更一個生物的名字。 1
/changesetting commands.changesetting.description 4 0 0
/cheat_ability pins an ability to a specified state, simulating cheating 0
/cheat_local_player_health sets a player's health to the specified value, but doesn't send it to the server, for testing server authoritative health changes 0
/cheat_movement_debug enables debug rendering for movement cheating 0
/classroommode 嘗試啟動並連接到教室。 0 0 0
/cleanroom Helper command that Runs 'spawning' and 'wipeout' at the same time. So all entities go away and do not come back through spawning. 1
/clear 清空玩家背包中的物品。 1 0 0
/clearloadedstructures 清楚載入的結構。 1
/clearspawnpoint 移出一個玩家的世界重生點。 1 0 0
/clone 將一個區域的方塊複製到另一個區域。 1 0 0
/closewebsocket 關閉Websocket連接。 0 6 0
/code 啟動程式碼編輯器 0 0 0
/codebuilder commands.codebuilder.description 1 4 0
/connect 嘗試使用給出的URL連結連接到Websocket伺服器。 2 16 0
/corruptworld Corrupts the world loaded on the server. 1
/crashclient 1
/crashserver 使連接到的伺服器端崩潰(可能是本地)。 1
/createlocalworld 在本機建立一個新的世界。 1
/currenttick 設定目前世界每秒的刻數。 0
/daylock 鎖定或解鎖晝夜交替。 1 0 0
/debugcamera commands.debugcamera.description 1
/debugprofile Captures the last N frames and saves the data to a file. 1
/dedicatedwsserver 嘗試連以給出的URL連結接到WebSocket伺服器。 0 6 0
/deop 撤銷一個玩家的管理員權限。 2 64 0
/destroyblock 破壞指定位置的方塊。 1
/dialogue 為一名玩家開啟NPC的對話介面。 1 0 0
/difficulty 設定世界難易度。 1 0 0
/dumpblocknames Gets block names from a range and dumps them into a string. 1
/dumpblockpalette Outputs valid block nbt for vanilla and bedrock blocks in a binary format. 1
/dumpentitiesclient Dump out info on all entities in the current dimension 1
/dumpentitiesserver Dump out info on all entities in the current dimension 1
/effect 為生物加入或移出狀態效果。 1 0 0
/enableedunpc 是否允許在地圖內生成NPC: true允許, false禁止 0
/enableencryption commands.enableencryption.description 0 6 0
/enchant 為一名玩家手持的物品附魔。 1 0 0
/enchantrandom 為玩家手持的物品附魔隨機附魔。 1
/equip Equips a selection of entities with an item 0
/event 為指定實體觸發事件。 1 0 0
/execute 以不同的方式執行指令。 1 0 0
/fill 在一個區域內填充方塊。 1 0 0
/fillchestblock 使用物品填充儲物箱。 1
/filldrive Fills the user save and keeps a certain amount of bytes remaining. 1
/filllevelstorage Fill level storage with bytes of dummy data. 1
/findanchoredbuildpos Given a specific destination block position, this method finds a valid position for the player to be at in order for them to place a block at that position. 1
/findflatarea Finds a flat area for further actions. 1
/findnearbypickup Finds a nearby pickup. 1
/fixbiomes Regenerate biomes in a chunk radius around the players 1
/fly 變更玩家的飛行狀態。 1
/fog 加入或移除迷霧檔案。 1 0 0
/function Runs commands found in the corresponding function file. 1 0 0
/gamemode Sets a player's game mode. 1 0 0
/gamerule Sets or queries a game rule value. 1 64 0
/gametest Interacts with gametest. 1 1 0
/getblockname Gets block names at a given blockpos 1
/getchestcontents Gets contents of a chest 1
/getchunkdata Gets pixels for a specific chunk. 3 6 0
/getchunks Gets list of chunks that are loaded. 3 6 0
/getdurability Durability of selected item. 0 1 0
/geteduserverinfo commands.geteduserverinfo.description 0 6 0
/getexperience Returns the players current experience (score) 1
/getmobdebuginfo Retrieves the debug string for a given mob. 1
/getpower Gets the power at a given blockpos. 1
/getselecteditemcount Determine item count of inventory item. 1
/getspawnpoint Gets the spawn position of the specified player(s). 3 6 0
/getstructure Gets the structure that the player is current occupying 1
/gettopsolidblock Gets the position of the top non-air block below the specified position 0‌ ‌[僅教育版] / 1‌  ‌[僅基岩中國版] 6 0
/getworidname Gets the name of the current world (aka level). 1
/give Gives an item to a player. 1 0 0
/globalpause Sets or gets the paused state of the game for all players. 3 6 0
/health Modifies a mobs's health. 1
/help Provides help/list of commands. 0 8 64
/hunger Modifies a player's hunger level. 1
/immutableworld Sets the immutable state of the world. 1 0 0
/insomnia Gets and sets the player's insomnia level. 1
/islargechestblock Check to see if block is a large chest. 1
/isplayercrouching Returns if the player is crouching 1
/isplayerflying Returns if the player is flying 1
/isplayergrounded Returns if the player is grounded 1
/isworldloaded Checks if the client is loaded into a world. 1
/joinlangame Join a game on a remote host. 1
/kick Kicks a player from the server.‌ ‌[僅基岩版] / Removes a player from the game.‌ ‌[僅教育版] 1‌  ‌[僅基岩中國版] / 3‌ ‌[僅教育版] 64 0
/kill Kills entities (players, mobs, etc.). 1 0 0
/kit Gives the local player a kit. 0
/leaveworld Leaves the current world (aka level), goes back to start menu screen. 1
/lighttexturewriter Write the current dimension light texture to disk 1
/list Lists players on the server. 0 64 0
/listd commands.listd.description 3 6 0
/loadbehaviortreedefinitions Loads all of the automation behavior tree definitions. 1
/locate Displays the coordinates for the closest structure of a given type. 1 0 0
/log Modifies log settings or filters. 0
/lookat Forces the player to look at a floating point location 1
/me Displays a message about yourself. 0 32 64
/memwarn Fires low memory warning. 0
/mobevent Controls what mob events are allowed to run. 1 0 0
/mobinfo Toggles drawing mob information 1
/msg Sends a private message to one or more players. 0 32 64
/music Allows you to control playing music tracks. 1 0 0
/nearbyentityisbaby Returns true if the nearest entityType is a baby 1
/notifyprofiler Sends a message to the profiler to peform an action. 1
/op Grants operator status to a plaqer. 2 64 0
/openlocalworld Opens an existing world (aka level) on the local machine. 1
/ops Reloads and applies permissions. 4 0 0
/option Allows you to check or change the value of an option for the primary user 1
/packetprofile outputs verbose historq of packet stats to console 0
/particle Creates a particle emitter 1 0 0
/particlelegacy Fires a legacy particle in the world 0
/paths Disables Drawing Paths 1
/pause commands.pause.description 1
/permission Reloads and applies permissions. 4 0 0
/placefeature Places a feature or feature rule in the given chunk. 1
/placefromhand Places the current selected inventory item to the given position, if possible 1
/placejigsaw Places a jigsaw piece and goes through the jigsaw generation in the given chunk. 1
/placestructure Places a structure 1
/playanimation Makes one or more entities play a one-off animation. Assumes all variables are setup corrrectly. 1 0 0
/playerstat Gets stats about a player 1
/playsound Plaqs a sound. 1 0 0
/postrackclient Track a position within the world using a handle (Client) 1
/postracksrv Track a position within the world using a handle (Server) 1
/profile Shows the players profile with the specified name. 1
/querytarget Gets transform, name, and id information about the given target entity or entities. 0‌ ‌[僅教育版] / 2‌  ‌[僅基岩中國版] 6 0
/quit Quit the app. 1
/raid Triggers a raid at the originator's location, if they are in or near a village 1
/record Records or replays a session. 1
/redstonetest Outputs the redstone graph to a visual studio test. 1
/register3pserver Registers a 3P Server in the 3P Server Repositoty. 1
/reload Reloads all function files from all behavior packs. 2 0 0
/reloadanims Reload animation data. 1
/remove Removes entities (players, mobs, etc.). 2 0 0
/removeedunpc 刪除地圖內所有NPC 0
/replaceitem Replaces items in inventories. 1 0 0
/resourceuri Sets the resource URI in pause menu 0 0
/restart commands.restart.description 1
/resupply Triggers resupply on an entity's economy trade table. 1
/ride Makes entities ride other entities, stops entities from riding, makes rides evict their riders, or summons rides or riders. 1 0 0
/rot Sets a player's current rotation. 1
/save Control or check how the game saves data to disk. 4 0 0
/savestructure Saves a structure 1
/say Sends a message in the chat to other players. 1 32 64
/schedule Schedules an action to be executed once an area is loaded, or after a certain amouont of time. 1 0 0
/scheduler Disables Drawing scheduler information 1
/scoreboard Tracks and displays scores for various objectives. 1 0 0
/seencredits Marks or unmarks an actor as having seen credits. 1
/selectinventoryitem Equips a passed item. 1
/sendmodalform Sends a request to show a form to the target player 1
/sendshowstoreoffer Sends a request to show a store offer to the target player. 1
/serverinfo Show Environment in which server is running 1
/setblock Changes a block to another block. 1 0 0
/setmaxplayers Sets the maximum number of players for this game session. 3 0 0
/setworldspawn Sets the world spawn. 1 0 0
/showallitems Sends a request to show third party store offers to player. 0
/showfrustum Displays and freezes the player frustum. 1
/simlock Locks simulation time. 1
/simscale Scales the passage of simulation time. 1
/skin Gets the current player skin. 1
/spawnfeature commands.spawnfeature.description 1
/spawngroup Spawns a mob group at a specified location. 1
/spawning Toggles the spawning of enti ties. 1
/spawnitem Spawns an item entity at position 1
/spawnmob Spawns a mob to a particular state. 1
/spawnpoint Sets the spawn point for a plaqer. 1 0 0
/spreadplayers Teleports entities to random locations. 1 0 0
/stop Stops the server. 4 0 0
/stopsound Stops a sound. 1 0 0
/stoptime Resumes time elapse. 1
/structure Saves or loads a structure in the world. 1 0 0
/summon Summons an entity. 1 0 0
/systemstat Returns or sets runtime statistics for the game 1
/tag Manages tags stored in entities. 1 0 0
/takepicture Takes a photo of a player or from a player's point of view. 1 0 0
/teleport Teleports entities (players, mobs, etc.). 1 0 0
/tell Sends a private message to one or more players. 0 32 64
/tellraw Sends a JSON message to players. 1 32 64
/test Exectues‌[原文如此] a test via the test manager. 1
/testassets Upload or download test assets via the test manager. 1
/testfor Counts entities (plagers, mobs, items, etc.) matching specified conditions. 1 0 0
/testforblock Tests whether a certain block is in a specific location. 1 0 0
/testforblocks Tests whether the blocks in two regions match. 1 0 0
/tickingarea Add, remove, or list ticking areas. 1 0 0
/time Changes or queries the world's game time. 1 0 0
/timelock Resumes time elapse. 1
/title Controls screen titles. 1 32 0
/titleraw Controls screen titles with JSON messages. 1 32 0
/toggledownfall Toggles the weather. 1 0 0
/tp Teleports entities (players, mobs, etc.). 1 0 0
/tpb Teleport to specified biome 0
/tptobiome Teleport to specified biome 0
/tptosuitabletree Teleports the player to a position where they can chop down a tree. 1
/transferserver Transfers a player to another server. 1
/validategamelighting Validate game lighting for a specified region 1
/videostream Attempts to connect to the websocket server to send a video stream. 0 0 0
/videostreamaction Perform a videostream related action. 0 0
/villagehero Forces the Village to start bestowing the Hero of the Village effect as if you won a raid. 1
/villages Disables Drawing Village Debug Info 1
/w Sends a private message to one or more players. 0 32 64
/wb Toggle World Builder status of caller. 1 0 0
/weather Sets the weather. 1 0 0
/whitelist Manages the server whitelist. 4 0 0
/wipeout Wipes out entities across all dimensions. 1
/worldbuilder Toggle World Builder status of caller. 1 0 0
/wsserver Attempts to connect to the websocket server on the provided URL. 2 16 0
/xp Adds or removes player experience. 1 0 0

指令可用性[編輯]

指令 BE CN EE BEDEV CNDEV BDS CB DC UC EDU EX
/?
/ability
/addrider
/agent
/aicreate
/aigoals
/aistop
/alwaysday
/audioaction
/automate
/bhave
/bossbar
/bounds
/camera
/camerashake 即將到來 即將到來 即將到來
/changedimension
/changename
/changesetting
/cheat_ability
/cheat_local_player_health
/cheat_movement_debug
/classroommode 是‌[隱藏] 是‌[隱藏]
/cleanroom
/clear
/clearloadedstructures
/clearspawnpoint 即將到來 即將到來 即將到來
/clone
/closewebsocket
/closewebsocket
/code 是‌[隱藏]
/codebuilder
/connect
/corruptworld
/crashclient
/crashserver
/createlocalworld
/currenttick
/daylock
/debugcamera
/debugprofile
/dedicatedwsserver
/deop
/destroyblock
/dialogue
/difficulty
/dumpblocknames
/dumpblockpalette
/dumpentitiesclient
/dumpentitiesserver
/effect
/enableedunpc
/enableencryption
/enchant
/enchantrandom
/equip
/event 即將到來 即將到來 即將到來
/execute
/fill
/fillchestblock
/filldrive
/filllevelstorage
/findanchoredbuildpos
/findflatarea
/findnearbypickup
/fixbiomes
/fly
/fog 即將到來 即將到來 即將到來
/function
/gamemode
/gamerule
/gametest 即將到來 即將到來 即將到來
/getblockname
/getchestcontents
/getchunkdata 是‌[隱藏] 是‌[隱藏]
/getchunks 是‌[隱藏] 是‌[隱藏]
/getdurability 是‌[隱藏]
/geteduserverinfo
/getexperience
/getmobdebuginfo
/getpower
/getselecteditemcount
/getspawnpoint 是‌[隱藏] 是‌[隱藏]
/getstructure
/gettopsolidblock
/getworidname
/give
/globalpause 是‌[隱藏] 是‌[隱藏]
/health
/help
/hunger
/immutableworld
/insomnia
/islargechestblock
/isplayercrouching
/isplayerflying
/isplayergrounded
/isworldloaded
/joinlangame
/kick
/kill
/kit
/leaveworld
/lighttexturewriter
/list
/listd
/loadbehaviortreedefinitions
/locate
/log
/lookat
/me
/memwarn
/mobevent
/mobinfo
/msg
/music 即將到來 即將到來 即將到來
/nearbyentityisbaby
/notifyprofiler
/op
/openlocalworld
/ops
/option
/packetprofile
/particle
/particlelegacy
/paths
/pause
/permission
/placefeature
/placefromhand
/placejigsaw
/placestructure
/playanimation 即將到來 即將到來 即將到來
/playerstat
/playsound
/postrackclient
/postracksrv
/profile
/querytarget
/quit
/raid
/record
/redstonetest
/register3pserver
/reload
/reloadanims
/remove
/removeedunpc
/replaceitem
/resourceuri
/restart
/resupply
/ride 即將到來 即將到來 即將到來
/rot
/save
/savestructure
/say
/schedule 即將到來 即將到來 即將到來
/scheduler
/scoreboard
/seencredits
/selectinventoryitem
/sendmodalform
/sendshowstoreoffer
/serverinfo
/setblock
/setmaxplayers
/setworldspawn
/showallitems
/showfrustum
/simlock
/simscale
/skin
/spawnfeature
/spawngroup
/spawning
/spawnitem
/spawnmob
/spawnpoint
/spreadplayers
/stop
/stopsound
/stoptime
/structure 即將到來 即將到來 即將到來
/summon
/systemstat
/tag
/takepicture
/teleport
/tell
/tellraw
/test
/testassets
/testfor
/testforblock
/testforblocks
/tickingarea
/time
/timelock
/title
/titleraw
/toggledownfall
/tp
/tpb
/tptobiome
/tptosuitabletree
/transferserver
/validategamelighting
/videostream
/videostreamaction
/villagehero
/villages
/w
/wb
/weather
/whitelist
/wipeout
/worldbuilder
/wsserver
/xp

指令參數[編輯]

指令的參數(Argument)是緊跟在指令名後使用的一種資料,通常發揮著使指令的作用物件或作用方式更精確的作用。每一種指令參數都具備一種資料型別,不同的資料型別的參數將擁有不同的表現。每一種參數還具備一個參數型別,參數型別將決定該指令接受怎樣的值。

資料型別[編輯]

指令參數分為四種資料型別,分別是基本(Basic)列舉(Enum)軟列舉(Soft Enum)後固定(Postfix)。基本型別是一些固定的通用資料型別。列舉型別是一種在一些字串中選取其中一個作為其值的資料型別。軟列舉資料型別同樣在一些字串中選取其中一個作為其值的資料型別,但是其列舉的範圍由於可能會實時變化而無法預先載入指令的自動補全,比如計分板中記分項的列舉。後固定是一種在參數末尾固定了一定長度的文字的資料型別,目前僅見於/xp中的amount參數。

資料型別列舉
鍵名 描述
Basic 0 基本
Enum 1 列舉
SoftEnum 2 軟列舉
Postfix 3 後固定

指令詞法分詞型別[編輯]

分詞(Token)是基岩引擎在解析指令時用到的一種中間元素,為指令中的基本符號。分詞型別也被同時用作指令解析中的終結符型別使用。它可以和非終結符一起組成指令基本資料型別參數的各個型別。分詞代表著指令語法中的運算子、關鍵字與字面量。

分詞型別/終結符列舉
鍵名 描述
Error 0x0 技術性分詞,錯誤
Integer 0x1 一個整數
NInteger 0x2 一個負整數
Identifier 0x3 一個識別碼
Selector 0x4 @,一個選擇器
Slash 0x5 /,一個斜槓
Value 0x6 一個值
RValue 0x7 一個右值
LValue 0x8 一個左值
Equals 0x9 =,一個等號
Comma 0xA ,,一個逗號
Colon 0xB :,一個分號
Not 0xC !,一個非號
Asterisk 0xD *,一個星號
Hash 0xE #,一個哈希號
OpenBracket 0xF [,一個左方括弧
CloseBracket 0x10 ],一個右方括弧
OpenBrace 0x11 {,一個左花括弧
CloseBrace 0x12 },一個右花括弧
String 0x13 一個字串
Range 0x14 ..,一個範圍號
LessThan 0x15 <,一個小於號
GreaterThan 0x16 >,一個大於號
PlusEquals 0x17 +=,一個加等號
MinusEquals 0x18 -=,一個減等號
TimesEquals 0x19 *=,一個乘等號
DivideEquals 0x1A /=,一個除等號
ModEquals 0x1B %=,一個模等號
GreaterThanLessThan 0x1C ><,一個不等號
Unknown 0x1D 技術性分詞,未知
End 0x1E 技術性分詞,結束列舉

參數型別[編輯]

參數的符號(Symbol)對應著參數的型別。當參數為基本資料型別時,其參數型別都是由非終結符與終結符組合而成的。一些最終組合將作為指令的基本資料型別的參數參數使用,他們的列舉值也將作為該參數的符號值,其餘的非終結符無法被玩家直接使用。下面列出了非終結符的型別和部分非終結符對應的參數型別。這些參數型別都是基本資料型別的參數的型別。我們可以看到,基本資料型別的參數的符號值的小端序第21位皆為1,第22位以上皆為0。

非終結符列舉
鍵名 對應的參數型別 描述
Epsilon 0x100000
Int 0x100001 int 整數
0x100002
Val 0x100003 float 浮點數
RVal 0x100004 value 相對浮點數
WildcardInt 0x100005 wildcard int 通配符整數
Operator 0x100006 operator 運算子
Selection 0x100007 target 選擇器
0x100008
WildcardSelection 0x100009 target 通配符選擇器
NonIdSelector 0x10000A 空選擇器
ScoresArg 0x10000B 單個分數參數
ScoresArgs 0x10000C 分數參數的集合
ScoreSelectParam 0x10000D 分數選擇參數
ScoreSelector 0x10000E 分數選擇器
TagSelector 0x10000F 標籤選擇器
FilePath 0x100010 filepath 檔案路徑
FilePathVal 0x100011 檔案路徑值
FilePathCont 0x100012 檔案路徑計數
IntegerRangeVal 0x100013 整數範圍值
IntegerRangePostVal 0x100014 整數範圍後值
IntegerRange 0x100015 整數範圍
FullIntegerRange 0x100016 完整整數範圍
SelArgs 0x100017 選擇參數的集合
Args 0x100018 參數的集合
Arg 0x100019 單個單數
MArg 0x10001A 遊戲模式參數
MValue 0x10001B 遊戲模式參數值
NameArg 0x10001C 名稱參數
TypeArg 0x10001D 型別參數
0x10001E
TagArg 0x10001F 標籤參數
Id 0x100020 string 字串
IdCont 0x100021 字串計數
CoordXInt 0x100022 整數X座標
CoordYInt 0x100023 整數Y座標
CoordZInt 0x100024 整數Z座標
CoordXFloat 0x100025 浮點數X座標
CoordYFloat 0x100026 浮點數Y座標
CoordZFloat 0x100027 浮點數Z座標
Position 0x100028 x y z 整數座標組
PositionFloat 0x100029 x y z 浮點數座標組
MessageExp 0x10002A
Message 0x10002B
MessageRoot 0x10002C message 訊息根
PostSelector 0x10002D 後選擇器
RawText 0x10002E text 原始文字
RawTextCont 0x10002F 原始文字計數
JsonValue 0x100030 JSON值
JsonField 0x100031 JSON欄位
JsonObject 0x100032 json JSON物件
JsonObjectFields 0x100033 JSON物件欄位
JsonObjectCont 0x100034 JSON物件計數
JsonArray 0x100035 JSON陣列
JsonArrayValues 0x100036 JOSN陣列值的集合
JsonArrayCont 0x100037 JSON陣列計數
0x100038 方塊狀態欄位‌[需要驗證]
0x100039 方塊狀態名‌[需要驗證]
0x10003A 方塊狀態值‌[需要驗證]
0x10003B 方塊狀態欄位的集合‌[需要驗證]
0x10003C block state 方塊狀態
0x10003D 方塊狀態計數‌[需要驗證]
Command 0x10003E 無斜槓指令
SlashCommand 0x10003F command 斜槓指令

當參數為列舉資料型別時,它的參數型別將會顯示為一個大駝峰字串。這將根據其符號值來確定。列舉型別的參數的符號值的小端序第21位為0,第22位為1,第23位以上皆為0。在對應到列舉型別時,它的第22位將歸0,同時第28位將轉換為1,以此確定對應的列舉型別。下面列出了目前所有的列舉型別。

指令列舉型別列舉
鍵名 對應列舉結構 對應的參數型別 描述

當參數為軟列舉資料型別時,其對應的參數型別將始終顯示為string。此時其符號值表現為小端序第21位、第22位為0,第23位為1,第24位以上皆為0。

當參數為後固定資料型別時,其對應的參數型別將始終顯示為int。此時其符號值表現為小端序第21位至第24位為0,第25位為1,第26位以上皆為0。

歷史[編輯]

攜帶版(Alpha)
0.7.4加入了對指令的支援,但尚未實現任何指令的執行。
0.16.0build 1加入了/clearfixedinv/clone/deop/execute/fill/gamemode/give/help(及其別名/?)、/kill/list/op/say/setblock/setfixedinvslot/setworldspawn/spawnpoint/summon/tell(及其別名/msg/w)、/testforblock/testforblocks/time/toggledownfall/tp(及其別名/teleport)、/weather/wsserver/xp指令。
大部分指令的功能與Java版1.10相同。差別在於:不支援資料標籤、/clone指令無法使用forced模式、/gamemode指令僅允許指定創造模式和生存模式、/give指令中玩家目標為可選參數,以及/execute指令中實體目標為可選參數。
build 2移除了/clearfixedinv/setfixedinvslot及其他教育版相關的指令。
build 5加入了/enchant指令。
攜帶版
1.0.00.17.0.1加入了/locate/connect指令。
0.17.0.2移除了/locate指令。
1.0.0.0重新加入了/locate指令。僅能用於查找要塞。
1.0.31.0.3.0加入了/transferserver指令。
1.0.51.0.5.0加入了/clear/difficulty/effect/gamerule/me/particle/playsound/replaceitem/spreadplayers/stopsound/testfor/title指令。
1.0.5.3移除了/particle指令。
/effect指令的amplifier參數不再允許為負值。
1.1.01.1.0.0/replaceitem支援canplaceoncandestroy
/locate可查找其他結構。
加入了遊戲規則dodaylightcycledoentitydropsdofiretickdomobspawningdomoblootdotiledropsdoweathercyclekeepinventorymobgriefing
?加入了/setmaxplayers
基岩版
1.2.01.2.0.2加入了/tickingarea
1.4.0?/transferserver移動到開發人員指令,玩家不再能夠正常使用。
1.5.01.5.0.0為啟用教育版功能的世界加入了5個新指令。
1.6.01.6.0.6/gamerule加入了遊戲規則doInsomnia
1.7.01.7.0.2加入了/scoreboard
加入了了遊戲規則commandblocksenabled
1.8.01.8.0.8重新加入了/particle
加入了randomTickSpeed遊戲規則。
加入了/reload
加入了/function
1.9.01.9.0.0加入了/tellraw
加入了showdeathmessages遊戲規則。
加入了immediaterespawn遊戲規則。
/particle加入了新粒子。
1.11.01.11.0.1加入了/resupply,但並沒有作用。
1.11.0.3加入了/mobevent
1.12.01.12.0.2加入了spawnradius遊戲規則。
/clear的特殊值功能失效。
加入了sendcommandblockfeedback遊戲規則。
/particle加入了更多的新粒子。
為地圖製作及Add-ons加入了新指令。
?移除了/resupply
1.14.01.14.0.3/clear的特殊值功能被修復。
1.16.01.16.0.57加入了/kick指令。
正式版加入了/whitelist指令。
1.16.1001.16.100.52加入了/playanimation/ride/structure指令。
1.16.100.54加入了/fog指令。
1.16.100.57加入了/camerashake/clearspawnpoint/event指令。
1.16.100.58加入了/music指令。
1.16.100.59加入了/schedule指令。
1.16.2101.16.210.53移除了/mixer指令。
1.16.210.54重新加入了/mixer指令。
1.16.210.58再次移除了/mixer指令。
1.16.210.60加入了/gametest指令。
1.17.01.16.230.50/whitelist重新命名為/allowlist
1.17.101.17.10.22加入了/dialogue指令。

錯誤[編輯]

關於「指令」的錯誤在國際版中由錯誤追蹤器維護,請在此回報錯誤。

參見[編輯]