Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/execute (old)

From SAS Gaming Wiki
Revision as of 18:08, 20 November 2025 by imported>MinecraftBedrockPlayer7
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Outdated feature {{#vardefine:displaytitle_set|1}} Template:Infobox command

Executes a command on behalf of one or more other entities, with originating permissions, optionally on condition that a single-block Template:Cmd-style check passes.

Syntax

execute <entity> <x> <y> <z> <command …>
An alternate syntax allows the command to be executed only if a specific block is detected:
execute <entity> <x> <y> <z> detect <x2> <y2> <z2> <block> <dataValue|state> <command …>
execute <origin: target> <position: x y z> <command: command>
An alternate syntax allows the command to be executed only if a specific block is detected:
execute <origin: target> <position: x y z> detect <detectPos: x y z> <block: Block> <data: int> <command: command>

Arguments

Template:El: entity
Template:El: Template:Argument

Specifies the target to be the command's executor. Must be a player name or target selector. If more than one entity is selected, the command is run once as each of them.

Template:El: x y z
Template:El: Template:Argument

Specifies the position from which to run the command. Coordinates specified with tilde and caret notation are relative to the target, not to the position of the command's execution.

Template:El: command
Template:El: Template:Argument

Specifies the command to be run. Must be a valid command.

Template:El: x2 y2 z2
Template:El: Template:Argument

Specifies the position of the block to check. May use tilde and caret notation to specify distances relative to position: x y z.

Template:El: block
Template:El: Template:Argument

Specifies the block ID that the block at x2 y2 z2 or detectPos must match for the command to run. Must be a valid block ID.

Template:El: dataValue
Template:El: Template:Argument

Must be a valid block data for that type of block or -1 to match any block data.

Template:El: state

Must be a valid block state for that type of block or * to match any block state.

Result

Fails if arguments are not specified correctly, if entity or origin: target fails to resolve to one or more valid entities (named players must be online), if the checked block is not of the correct block id, data or state, or if the specified command fails.
On success, executes the specified command as if executed by the specified target(s), done with Minecraft:operator-level permission at the specified coordinate.

Examples

  • To summon lightning bolts at the positions of every zombie:
    execute @e[type=zombie] ~ ~ ~ summon lightning_bolt
  • To summon lightning bolts at the positions of every zombie standing on any type of sand:
    execute @e[type=zombie] ~ ~ ~ detect ~ ~-1 ~ sand -1 summon lightning_bolt
  • To summon 10 creepers at the nearest player's position (works as long as there are at least 10 entities in the loaded world):
    execute @e[c=10] ~ ~ ~ execute @p ~ ~ ~ summon creeper ~ ~ ~
  • To summon an ender dragon at the position of another player:
    execute @a[name=name_of_player] ~ ~ ~ summon ender_dragon

History

Template:HistoryTable

See also

Template:Cmd — tests for a certain block at a specified position (including specific data tags)

Navigation

Template:Navbox commands

Minecraft:de:Befehl/execute/Vor 1.13 Minecraft:ko:명령어/execute/이전 Minecraft:pt:Comandos/execute/Antes Minecraft:zh:命令/execute/旧版