Run Commands on Behalf of Entities
The /execute command in Minecraft Bedrock Edition lets you run a command on behalf of one or more entities. You can chain different clauses together to change who runs the command, where it runs, which direction it faces, and which conditions must be met first.
Players and map makers use this command when building custom mechanics with command blocks. It requires Game Directors permission and cheats must be enabled in your world.
/execute as <origin: target> <chainedCommand: executechainedoption_0>As another entity
/execute at <origin: target> <chainedCommand: executechainedoption_0>At the position of an entity
/execute in <dimension: Dimension> <chainedCommand: executechainedoption_0>In dimension
/execute positioned <position: x y z> <chainedCommand: executechainedoption_0>Positioned
/execute positioned as <origin: target> <chainedCommand: executechainedoption_0>Positioned as a selected entity
/execute rotated <yaw: rotation> <pitch: rotation> <chainedCommand: executechainedoption_0>Rotated with a specific yaw/pitch
/execute rotated as <origin: target> <chainedCommand: executechainedoption_0>Rotated as a another entity
/execute facing <position: x y z> <chainedCommand: executechainedoption_0>Facing a position
/execute facing entity <origin: target> <anchor: ActorLocation> <chainedCommand: executechainedoption_0>Facing a selected entity
/execute align <axes: string> <chainedCommand: executechainedoption_0>Align
/execute anchored <anchored: ActorLocation> <chainedCommand: executechainedoption_0>Anchored
/execute <subcommand: Option_If_Unless> block <position: x y z> <block: Block> [chainedCommand: executechainedoption_0]If/unless block matches type
/execute <subcommand: Option_If_Unless> block <position: x y z> <block: Block> <blockStates: block properties> [chainedCommand: executechainedoption_0]If/unless block has block states
/execute <subcommand: Option_If_Unless> blocks <begin: x y z> <end: x y z> <destination: x y z> <scan mode: BlocksScanMode> [chainedCommand: executechainedoption_0]If unless a set of blocks matches scan criteria
/execute <subcommand: Option_If_Unless> entity <target: target> [chainedCommand: executechainedoption_0]If/unless an entity matches
/execute <subcommand: Option_If_Unless> score <target: target> <objective: ScoreboardObjectives> <operation: compareoperator> <source: target> <objective: ScoreboardObjectives> [chainedCommand: executechainedoption_0]If/unless score
/execute <subcommand: Option_If_Unless> score <target: target> <objective: ScoreboardObjectives> matches <range: fullintegerrange> [chainedCommand: executechainedoption_0]If/unless score in range
/execute run <command: codebuilderargs>Run
| Argument | Type | What it means |
|---|---|---|
anchor | ActorLocation | - `anchored`: ActorLocation |
axes | string | A string representing the block axes to which the command positions are aligned (floored). |
block | Block | The specific block ID to compare against the block at the given coordinates. |
blockStates | block properties | The set of block properties that the tested block must match. |
command | codebuilderargs | A string of the final valid command to run once all contexts and conditions are processed. |
destination: x y z | position | - `dimension`: Dimension |
end: x y z | position | - `objective`: ScoreboardObjectives |
operation | compareoperator | - `origin`: target The target of the command to execute. Must be a player name or target selector. |
pitch | rotation | Up-and-down rotation of the command |
position: x y z | position | A `vector` of where to run the command from. |
range | fullintegerrange | - `scan mode`: BlocksScanMode |
source | target | - `subcommand`: Option_If_Unless |
target | target | - `yaw`: rotation Left-to-right rotation context of the command |
/execute as @p run say Hello!Makes the nearest player say a greeting in the chat as if they typed it themselves.
/execute at @r run summon cow ~ ~ ~Summons a cow right at the current location of a random player.
/execute positioned 100 64 -200 run setblock ~ ~ ~ stoneSets the execution position to 100, 64, -200 and places a stone block there.
/execute as @a at @s if block ~ ~-1 ~ diamond_block run give @s apple 1Checks every player and gives an apple to anyone currently standing directly on top of a diamond block.
/execute unless entity @e[type=zombie] run time set dayChanges the world time to day only if there are no zombies currently loaded.
/execute in nether positioned 0 70 0 run summon blaze ~ ~ ~Summons a blaze at coordinates 0, 70, 0 inside the Nether dimension regardless of which dimension the command runs from.
/execute as @e[type=villager] at @s facing 50 65 50 run tp @s ~ ~ ~ ~ ~Rotates all villagers in place so that they are looking toward the coordinates 50, 65, 50.
/execute as @a if score @s coins matches 10.. run clear @s dirtClears dirt from the inventory of any player whose score in the coins objective is 10 or higher.
Minecraft Java Edition uses the same chained /execute structure with matching subcommands such as align, anchored, as, and at.
The as clause changes the entity executing the command (who is targeted by @s), while the at clause changes the coordinates, rotation, and dimension to match the selected entity's location.
Minecraft Bedrock Edition updated to the new execute syntax, which replaces the old format with chained subcommands like as, at, if, and run.
You must have Game Directors permission level and cheats must be turned on in the world settings to run /execute.
/dialogue/function/packstack/reload/reloadpacketlimitconfig/schedule/scoreboard/scriptevent/sendshowstoreoffer/tag/testfor/testforblock/testforblocks/toggledownfall