命令

来自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命令。

漏洞[编辑]

关于“命令”的漏洞在国际版中由漏洞追踪器维护,请在此报告漏洞。

参见[编辑]