Editing
MinecraftCommands
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== execute === {{/infobox |execute |op |1.8|14w07a }} 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. ;Syntax : <code>execute <''entity''> <span style="background-color:#FDD"><''x''> <''y''> <''z''></span> <''command β¦''></code> : An alternate syntax allows the command to be executed only if a specific block is detected: : <code>execute <''entity''> <span style="background-color:#FDD"><''x''> <''y''> <''z''></span> detect <span style="background-color:#DDF"><''x2''> <''y2''> <''z2''></span> <''block''> <''data''> <''command β¦''></code> ''Color added to make reading easier.'' ;Arguments : ''entity :: Specifies the target to be the command's executor. Must be a player name or [[#Target selectors|target selector]]. If more than one entity is selected, the command will be run once as each of them. : <span style="background-color:#FDD">''x y z''</span> :: Specifies the position from which to run the command. ''x'' and ''z'' must be within the range [[World boundary|-30,000,000 to 30,000,000]] (inclusive). Coordinates specified with [[#Tilde notation|tilde notation]] are relative to the target, not to the position of the command's execution. : ''command'' :: Specifies the command to be run. Must be a valid command. : <span style="background-color:#DDF">''x2 y2 z2''</span> (<code>detect</code> mode only) :: Specifies the position of the block to check. ''x2'' and ''z2'' must be within the range [[World boundary|-30,000,000 to 30,000,000]] (inclusive). May use [[#Tilde notation|tilde notation]] to specify distances relative to (''x'',''y'',''z''). : ''block'' and ''data'' (<code>detect</code> mode only) :: Specifies the [[Data values#Block IDs|block id and data]] which the block at (''x2'',''y2'',''z2'') must match for the command to run. ''block'' must be a valid block id (for example, <code>minecraft:stone</code>), and ''data'' must be a valid block data for that type of block or <code>-1</code> to match any block data. ;Result : Fails if arguments are not specified correctly, if ''entity'' 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 and data, or if the specified command fails. : On success, executes the specified command as if executed by the specified target(s) with [[operator]]-level permission at the specified coordinate. ;Examples : To summon lightning bolts at the positions of every zombie: :: <code>execute @e[type=Zombie] ~ ~ ~ summon LightningBolt</code> : To summon lightning bolts at the positions of every zombie standing on any type of sand: :: <code>execute @e[type=Zombie] ~ ~ ~ detect ~ ~-1 ~ minecraft:sand -1 summon LightningBolt</code> : To summon 10 creepers at the nearest player's position (only works as long as there are at least 10 entities in the loaded world): :: <code>execute @e[c=10] ~ ~ ~ execute @p ~ ~ ~ summon Creeper</code> ;See also : {{cmd|testforblock}} β tests for a certain block at a specified position (including specific data tags) <!-- please retain double newline above for section differentiation -->
Summary:
Please note that all contributions to Hegemon Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Hegemon Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information