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): Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Remove broken links to missing pages
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
 
Line 1: Line 1:
{{about|the {{cmd|execute|link=none}} command before Java Edition 1.13 and [[Minecraft:Bedrock Edition 1.19.50]]|the main command in current versions|Commands/execute}}
{{about|the {{MC/Cmd|execute|link=none}} command before Java Edition 1.13 and [[Minecraft:Bedrock Edition 1.19.50]]|the main command in current versions|Commands/execute}}
{{outdated feature}}
{{outdated feature}}
{{#vardefine:displaytitle_set|1}}
{{#vardefine:displaytitle_set|1}}
Line 10: Line 10:
}}
}}


Executes a command on behalf of one or more other entities, with originating permissions, optionally on condition that a single-block {{cmd|testforblock}}-style check passes.
Executes a command on behalf of one or more other entities, with originating permissions, optionally on condition that a single-block {{MC/Cmd|testforblock}}-style check passes.


==Syntax==
==Syntax==


* {{el|java}}
* {{MC/El|java}}
: <code>execute <''entity''> <''x''> <''y''> <''z''> <''command …''></code>
: <code>execute <''entity''> <''x''> <''y''> <''z''> <''command …''></code>


Line 21: Line 21:
: <code>execute <''entity''> <''x''> <''y''> <''z''> detect <''x2''> <''y2''> <''z2''> <''block''> <''dataValue''|''state''> <''command …''></code>
: <code>execute <''entity''> <''x''> <''y''> <''z''> detect <''x2''> <''y2''> <''z2''> <''block''> <''dataValue''|''state''> <''command …''></code>


* {{el|bedrock}}
* {{MC/El|bedrock}}
: <code>execute <origin: target> <position: x y z> <command: command></code>
: <code>execute <origin: target> <position: x y z> <command: command></code>


Line 30: Line 30:
== Arguments ==
== Arguments ==


{{el|je|short=1}}: ''entity''<br>
{{MC/El|je|short=1}}: ''entity''<br>
{{el|be|short=1}}: {{argument|be=1|origin: target|CommandSelector<Actor>}}
{{MC/El|be|short=1}}: {{MC/Argument|be=1|origin: target|CommandSelector<Actor>}}
:: Specifies the target to be the command's executor. Must be a player name or [[Minecraft:Target selectors|target selector]]. If more than one entity is selected, the command is run once as each of them.
:: Specifies the target to be the command's executor. Must be a player name or [[Minecraft:Target selectors|target selector]]. If more than one entity is selected, the command is run once as each of them.


{{el|je|short=1}}: ''x y z''<br>
{{MC/El|je|short=1}}: ''x y z''<br>
{{el|be|short=1}}: {{argument|be=1|position: x y z|CommandPositionFloat}}
{{MC/El|be|short=1}}: {{MC/Argument|be=1|position: x y z|CommandPositionFloat}}
:: Specifies the position from which to run the command. Coordinates specified with [[Minecraft:Commands#Tilde and caret notation|tilde and caret notation]] are relative to the target, not to the position of the command's execution.
:: Specifies the position from which to run the command. Coordinates specified with [[Minecraft:Commands#Tilde and caret notation|tilde and caret notation]] are relative to the target, not to the position of the command's execution.


{{el|je|short=1}}: ''command''<br>
{{MC/El|je|short=1}}: ''command''<br>
{{el|be|short=1}}: {{argument|be=1|command: command|unique_ptr<Command>}}
{{MC/El|be|short=1}}: {{MC/Argument|be=1|command: command|unique_ptr<Command>}}
:: Specifies the command to be run. Must be a valid command.
:: Specifies the command to be run. Must be a valid command.


{{el|je|short=1}}: ''x2 y2 z2''<br>
{{MC/El|je|short=1}}: ''x2 y2 z2''<br>
{{el|be|short=1}}: {{argument|be=1|detectPos: x y z|CommandPosition}}
{{MC/El|be|short=1}}: {{MC/Argument|be=1|detectPos: x y z|CommandPosition}}
:: Specifies the position of the block to check. May use [[Minecraft:Commands#Tilde and caret notation|tilde and caret notation]] to specify distances relative to <code>position: x y z</code>.
:: Specifies the position of the block to check. May use [[Minecraft:Commands#Tilde and caret notation|tilde and caret notation]] to specify distances relative to <code>position: x y z</code>.


{{el|je|short=1}}: ''block''<br>
{{MC/El|je|short=1}}: ''block''<br>
{{el|be|short=1}}: {{argument|be=1|block: Block|enum}}
{{MC/El|be|short=1}}: {{MC/Argument|be=1|block: Block|enum}}
:: Specifies the block ID that the block at ''x2 y2 z2'' or <code>detectPos</code> must match for the command to run. Must be a valid block ID.
:: Specifies the block ID that the block at ''x2 y2 z2'' or <code>detectPos</code> must match for the command to run. Must be a valid block ID.


{{el|je|short=1}}: ''dataValue''<br>
{{MC/El|je|short=1}}: ''dataValue''<br>
{{el|be|short=1}}: {{argument|be=1|data: int|int}}
{{MC/El|be|short=1}}: {{MC/Argument|be=1|data: int|int}}
:: Must be a valid block data for that type of block or <code>-1</code> to match any block data.
:: Must be a valid block data for that type of block or <code>-1</code> to match any block data.


{{el|je|short=1}}: ''state''
{{MC/El|je|short=1}}: ''state''
:: Must be a valid block state for that type of block or <code>*</code> to match any block state.
:: Must be a valid block state for that type of block or <code>*</code> to match any block state.


Line 77: Line 77:


{{HistoryTable
{{HistoryTable
|{{HistoryLine|java}}
|{{MC/HistoryLine|java}}
|{{HistoryLine||1.8|dev=14w07a|Added {{cmd|execute|link=none}}.}}
|{{HistoryLine||1.8|dev=14w07a|Added {{MC/Cmd|execute|link=none}}.}}
|{{HistoryLine|||dev=14w08a|Commands run using {{cmd|execute|link=none}} now pass their success value back to the command block running them.}}
|{{HistoryLine|||dev=14w08a|Commands run using {{MC/Cmd|execute|link=none}} now pass their success value back to the command block running them.}}
|{{HistoryLine||1.11|dev=16w32a|Added block state support to {{cmd|execute|link=none}}.}}
|{{HistoryLine||1.11|dev=16w32a|Added block state support to {{MC/Cmd|execute|link=none}}.}}
|{{HistoryLine||1.13|dev=17w45a|Reworked {{cmd|execute|link=none}}. See [[Minecraft:Commands/execute]] for new syntax.}}
|{{HistoryLine||1.13|dev=17w45a|Reworked {{MC/Cmd|execute|link=none}}. See [[Minecraft:Commands/execute]] for new syntax.}}


|{{HistoryLine|pocket alpha}}
|{{MC/HistoryLine|pocket alpha}}
|{{HistoryLine||v0.16.0|dev=build 1|Added {{cmd|execute|link=none}}.
|{{HistoryLine||v0.16.0|dev=build 1|Added {{MC/Cmd|execute|link=none}}.
|Functionality almost is equivalent to Java Edition 1.10 usage, except the entity target is optional in {{cmd|execute|link=none}}.}}
|Functionality almost is equivalent to Java Edition 1.10 usage, except the entity target is optional in {{MC/Cmd|execute|link=none}}.}}
|{{HistoryLine|bedrock}}
|{{MC/HistoryLine|bedrock}}
|{{HistoryLine||1.19.10|exp=Upcoming Creator Features|dev=Preview 1.19.10.20|Added new {{cmd|execute|link=None}} syntax to closer resemble that of {{el|java}}.}}
|{{HistoryLine||1.19.10|exp=Upcoming Creator Features|dev=Preview 1.19.10.20|Added new {{MC/Cmd|execute|link=None}} syntax to closer resemble that of {{MC/El|java}}.}}
|{{HistoryLine||1.19.50|dev=Preview 1.19.50.23|The new {{cmd|execute|link=none}} syntax is no longer behind the "Upcoming Creator Features" experimental toggle.}}
|{{HistoryLine||1.19.50|dev=Preview 1.19.50.23|The new {{MC/Cmd|execute|link=none}} syntax is no longer behind the "Upcoming Creator Features" experimental toggle.}}
}}
}}


==See also==
==See also==


: {{cmd|testforblock}} — tests for a certain block at a specified position (including specific data tags)
: {{MC/Cmd|testforblock}} — tests for a certain block at a specified position (including specific data tags)


== Navigation ==
== Navigation ==
{{Navbox commands}}
{{MC/Navbox commands}}


de:Befehl/execute/Vor 1.13
de:Befehl/execute/Vor 1.13

Latest revision as of 20:09, 9 April 2026

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

  1. REDIRECT Template:Command

Template:Redr-style check passes.

Syntax

  1. REDIRECT Template:Edition

Template:Rcat

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 …>
  1. REDIRECT Template:Edition

Template:Rcat

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

  1. REDIRECT Template:Edition

Template:Rcat: entity

  1. REDIRECT Template:Edition

Template:Rcat: origin: target: CommandSelector<Actor>

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.
  1. REDIRECT Template:Edition

Template:Rcat: x y z

  1. REDIRECT Template:Edition

Template:Rcat: position: x y z: CommandPositionFloat

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.
  1. REDIRECT Template:Edition

Template:Rcat: command

  1. REDIRECT Template:Edition

Template:Rcat: command: command: unique_ptr<Command>

Specifies the command to be run. Must be a valid command.
  1. REDIRECT Template:Edition

Template:Rcat: x2 y2 z2

  1. REDIRECT Template:Edition

Template:Rcat: detectPos: x y z: CommandPosition

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

Template:Rcat: block

  1. REDIRECT Template:Edition

Template:Rcat: block: Block: enum

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.
  1. REDIRECT Template:Edition

Template:Rcat: dataValue

  1. REDIRECT Template:Edition

Template:Rcat: data: int: int

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

Template:Rcat: 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 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

  1. REDIRECT Template:Command

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

Navigation

All editions
Removed
Template:El only
Debug
Removed
Template:Els only
Template:El only
Removed
Template:El only
Removed
Template:Els only
Removed
Joke
Related

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