Commands/execute/Before

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

Syntax



 * An alternate syntax allows the command to be executed only if a specific block is detected:






 * An alternate syntax allows the command to be executed only if a specific block is detected:



Arguments

 * entity
 * 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.
 * 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.


 * x y z
 * 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.
 * 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.


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


 * x2 y2 z2
 * Specifies the position of the block to check. May use tilde and caret notation to specify distances relative to.
 * Specifies the position of the block to check. May use tilde and caret notation to specify distances relative to.


 * block
 * Specifies the block ID that the block at x2 y2 z2 or  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  must match for the command to run. Must be a valid block ID.


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


 * 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  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:
 * To summon lightning bolts at the positions of every zombie standing on any type of sand:
 * To summon 10 creepers at the nearest player's position (works as long as there are at least 10 entities in the loaded world):
 * To summon ender dragon at the position of another player:
 * To summon 10 creepers at the nearest player's position (works as long as there are at least 10 entities in the loaded world):
 * To summon ender dragon at the position of another player:
 * To summon ender dragon at the position of another player: