
/execute
作弊 / OP 2Java版 26.3
以其他实体的身份、在其他位置或仅在满足条件时执行另一条命令。基本格式为 /execute if biome <pos> <biome>;共有17 种语法格式和27 个参数。权限:作弊 / OP 2。
/execute 语法
游戏数据游戏接受的所有格式。<尖括号> 中的词是需要你填写的参数,其余部分按原样输入。
/execute if biome <pos> <biome>/execute if block <pos> <block>/execute if blocks <start> <end> <destination> all/execute if blocks <start> <end> <destination> masked/execute if data block <source> <path>/execute if data entity <source> <path>/execute if data storage <source> <path>/execute if dimension <dimension>/execute if entity <entities>/execute if items block <source> <slots> <item_predicate>/execute if items entity <source> <slots> <item_predicate>/execute if loaded <pos>/execute if predicate <predicate>/execute if score <target> <targetObjective> < <source> <sourceObjective>/execute if score <target> <targetObjective> <= <source> <sourceObjective>/execute if score <target> <targetObjective> = <source> <sourceObjective>/execute if score <target> <targetObjective> > <source> <sourceObjective>部分分支会接入另一条命令的语法(以 … 表示),例如 /execute 的 run。
/execute 示例
可直接粘贴的示例(需开启作弊)。@s 是你自己,@p 是最近的玩家,@a 是所有玩家,@e 是所有实体。
/execute as @a at @s run summon minecraft:firework_rocket ~ ~1 ~- 在每位玩家头顶发射一枚烟花。
/execute if block ~ ~-1 ~ minecraft:gold_block run say Gold!- 如果你站在金块上,就说“Gold!”。
/execute 参数
每个参数需要填写什么,以及游戏强制的限制。
| 参数 | 类型 | 限制 |
|---|---|---|
<axes> | 坐标轴(x、y、z 的任意组合) | — |
<anchor> | eyes 或 feet | — |
<targets> | 目标选择器或玩家名(@s、@p、@a、@e、@r) | 一个或多个 |
<pos> | 位置(x y z,可用小数) | — |
<biome> | 游戏ID或 #标签 | worldgen/biome |
<block> | 方块ID或 #标签,可附加 [状态] | — |
<start> | 方块坐标(x y z,~ 为相对坐标,^ 为局部坐标) | — |
<end> | 方块坐标(x y z,~ 为相对坐标,^ 为局部坐标) | — |
<destination> | 方块坐标(x y z,~ 为相对坐标,^ 为局部坐标) | — |
<source> | 方块坐标(x y z,~ 为相对坐标,^ 为局部坐标) | — |
<path> | NBT 路径 | — |
<dimension> | 维度(minecraft:overworld、the_nether、the_end) | — |
<entities> | 目标选择器或玩家名(@s、@p、@a、@e、@r) | 一个或多个 |
<name> | 函数ID或 #标签 | — |
<slots> | 槽位来源 | — |
<item_predicate> | 物品ID或 #标签,可附加组件 | — |
<predicate> | 谓词ID | — |
<target> | 分数持有者(选择器、名称或 *) | 单个目标 |
<targetObjective> | 记分板目标名称 | — |
<sourceObjective> | 记分板目标名称 | — |
<range> | 数字范围(如 1..5) | — |
<id> | 带命名空间的ID(minecraft:…) | — |
<heightmap> | 高度图类型 | — |
<rot> | 旋转(偏航角 俯仰角) | — |
<scale> | 数字 | — |
<objective> | 记分板目标名称 | — |
<entity> | 注册表中的游戏ID | entity_type |
以其他实体的身份、在其他位置或仅在满足条件时执行另一条命令。 它有17 种语法格式,可由以下人员执行:作弊 / OP 2。
另请参阅
/execute 常见问题(Java版 26.3)
我的世界中 /execute 有什么作用?
以其他实体的身份、在其他位置或仅在满足条件时执行另一条命令。
/execute 的语法是什么?
基本格式为 /execute if biome <pos> <biome>。所有格式见上方列表。
/execute 有什么使用示例?
/execute as @a at @s run summon minecraft:firework_rocket ~ ~1 ~ — 在每位玩家头顶发射一枚烟花。
使用 /execute 需要开启作弊吗?
需要:作弊 / OP 2。在单人游戏中打开“允许作弊”(或以允许作弊的方式对局域网开放)。