How To Detect Entities In Minecraft
/execute executes another control but allows changing the executor, irresolute the position and bending it is executed at, adding preconditions, and storing its outcome.
Usage [ ]
In that location are twelve[ JE only ]/eleven[ BE only ] instructions (or sub-commands) for the /execute command. Multiple sub-commands are connected after /execute. Subcommands are divided into 4[ JE only ]/3[ BE only ] categories: modify subcommands, status subcommands, store subcommands, and run subcommand.
- Modify subcommands modify command variables and change the situation the command is executed, and execute subcommands following information technology with specific executor(s), execution position(southward), execution dimension(south), execution rotation(s) and execution anchor.
- Condition subcommands are used to exam whether certain conditions are true and output results or limit conditions of execution.
- [ Coffee Edition only ] Store subcommands can store the return values of the command in a scoreboard or the data of an entity, block entity, or storage, and can also change the maximum or current value of a boss bar.
-
runsubcommand is used for carrying out another command.
All needed sub-commands tin can be concatenated together. Subcommands other than the run subcommand tin be bundled arbitrarily and used multiple times. But the run subcommand can be used but once and must be put at the stop of the subcommands chain. A run subcommand or a condition subcommand finalizes the command, otherwise the command does zip. The game processes these subcommands in society from forepart to terminate, for example, the post-obit commands are unlike:
- All entities move one block forrard:
execute as @due east at @s run tp ^ ^ ^1 - All entities are teleported to one block in front of the executor:
execute at @southward as @e run tp ^ ^ ^one
The game processes other subcommands before processing run subcommands, so the run subcommand cannot touch other subcommands. In some cases, the command may terminate halfway and does aught.
In Coffee Edition, after executed (if it does non terminate halfway), the command returns a success value and a result value (run into #Store subcommand for details). These two values come from the concluding subcommand (may exist a condition subcommand or a run subcommand). Note that the return value of the command must be an integer, if not, information technology is rounded down. The success value is always 0 or ane. When the command fails, both return values are 0. The two values tin exist stored by store subcommands. When the final subcommand (may be a condition subcommand or a run subcommand) is executed multiple times, return values of each are stored after each execution.
/execute command likewise has a success count (whether or not terminates halfway), which is different from success and result value. This is normally 0 or i, but if the last subcommand is executed many times separately (as perchance with "/execute as @a -> execute") then success can exist a number higher than 1[ Java Edition merely ]. When executing information technology with a command cake, the success count is returned to the command block, which can be checked past a conditional command block for success or be read with a redstone comparator.
There are twelve[ JE only ]/eleven[ BE only ] instructions (or sub-commands) for the /execute command, and each has its own special syntax, so describing syntax takes a large branching tree.
| Command Syntax Tree-Diagram |
|---|
| This section needs to be updated. Please update this section to reverberate recent updates or newly available data. |
- Full syntax tree
- Coffee Edition
-
/execute . . .-
… align <axes> -> execute -
… anchored <anchor> -> execute -
… as <targets> -> execute -
… at <targets> -> execute -
… facing (<pos>|entity <targets> <anchor>) -> execute -
… in <dimension> -> execute -
… positioned (<pos>|equally <targets>) -> execute -
… rotated (<rot>|equally <targets>) -> execute -
… store (event|success) . . .-
… block <targetPos> <path> <type> <calibration> -> execute -
… bossbar <id> (max|value) -> execute -
… entity <target> <path> <type> <calibration> -> execute -
… score <targets> <objective> -> execute -
… storage <target> <path> <type> <scale> -> execute
-
-
… (if|unless) . . .-
… biome <pos> <biome> -> [execute] -
… cake <pos> <block> -> [execute] -
… blocks <first> <end> <destination> (all|masked) -> [execute] -
… information . . .-
… block <sourcePos> <path> -> [execute] -
… entity <source> <path> -> [execute] -
… storage <source> <path> -> [execute]
-
-
… entity <entities> -> [execute] -
… predicate <predicate> -> [execute] -
… score <target> <targetObjective> . . .-
… (<|<=|=|>|>=) <source> <sourceObjective> -> [execute] -
… matches <range> -> [execute]
-
-
-
… run <command>
-
- where
-> executerepresents the showtime of some other subcommand.
- Boulder Edition
-
/execute . . .-
… marshal <axes: string> <chainedCommand: ExecuteChainedOption_0> -
… anchored <eyes|feet> <chainedCommand: ExecuteChainedOption_0> -
… as <origin: target> <chainedCommand: ExecuteChainedOption_0> -
… at <origin: target> <chainedCommand: ExecuteChainedOption_0> -
… facing (<position: ten y z>|entity <origin: target> <eyes|feet>) <chainedCommand: ExecuteChainedOption_0> -
… in <dimension: Dimension> <chainedCommand: ExecuteChainedOption_0> -
… positioned (<position: x y z>|equally <origin: target>) <chainedCommand: ExecuteChainedOption_0> -
… rotated (<yaw: value> <pitch: value>|as <origin: target>) <chainedCommand: ExecuteChainedOption_0> -
… <subcommand: Option_ If _ Unless > . . .-
… block <position: 10 y z> <block: Cake> [<blockStates: block states>|<data: int>] [chainedCommand: ExecuteChainedOption_0] -
… blocks <begin: ten y z> <end: 10 y z> <destination: x y z> <scan mode: BlocksScanMode> [chainedCommand: ExecuteChainedOption_0] -
… entity <target: target> [chainedCommand: ExecuteChainedOption_0] -
… score <target: target> <objective: cord> . . .-
… <operation: compare operator> <source: target> <objective: cord> [chainedCommand: ExecuteChainedOption_0] -
… matches <range: integer range> [chainedCommand: ExecuteChainedOption_0]
-
-
-
… run <command: control>
-
- where
chainedCommand: ExecuteChainedOption_0represents the start of another subcommand.
Modify subcommands [ ]
align [ ]
- Updates the command'due south execution position, aligning to its current block position (an integer). Applies just along specified axes.
- This is akin to flooring the coordinates – i.eastward. rounding them downward.
- Syntax
- Java Edition:
-
align <axes> -> execute
-
- Bedrock Edition:
-
align <axes: string> <chainedCommand: ExecuteChainedOption_0> - Arguments
- JE:
<axes>: swizzle - BE:
axes: string- Whatsoever not-repeating combination of the characters '10', 'y', and 'z'. Axes can be declared in any society, just they cannot indistinguishable. (For case,
10,xz,zyx, oryz.)
- Whatsoever not-repeating combination of the characters '10', 'y', and 'z'. Axes can be declared in any society, just they cannot indistinguishable. (For case,
- Consequence
- Execution position in the given axes are floored, changing by less than one block.
- Unparseable if the argument is not specified correctly.
- Example
-
- Given (-1.eight, 2.3, v.9),
/execute align xzchanges the position to (-2, ii.iii, 5). - Given (2.4, -one.i, 3.eight),
/execute align yxz run spawnpoint @p ~ ~ ~sets the player's spawnpoint to (ii, -2, 3[ JE only ]/2, -1, 3[ BE just ]).
- Given (-1.eight, 2.3, v.9),
-
anchored [ ]
- Sets the execution anchor to the optics or anxiety. Defaults to feet.
- Running
positioned <pos> -> executeresets to feet - Effectively recenters local coordinates on either the eyes or feet, besides changing the angle the
facingsub-control (of/executeand/teleport) works off of- Syntax
- Java Edition:
-
anchored <anchor> -> execute
-
- Bedrock Edition:
-
anchored <optics|feet> <chainedCommand: ExecuteChainedOption_0> - Arguments
- JE:
<anchor>: entity_anchor (eyesorfeet) - BE:
eyes|anxiety- Whether to anchor the executed command to eyes or anxiety
- Result
- Execution ballast is set to either the eyes or the anxiety.
- Unparseable if the argument is not specified correctly.
- Example
- The effect of
/tpis to move a target by placing its feet at the given position. -
execute anchored eyes run tp ^ ^ ^effectively teleports the executor's feet to where its optics are (the execution position). -
execute anchored eyes run tp ^5 ^ ^means "identify the executor'due south feet 5 blocks left of where its optics are"
-
as [ ]
- Sets the command's executor to target entity, without changing execution position, rotation, dimension, or anchor [ needs testing in Bedrock Edition ]
- Syntax
- Java Edition:
-
as <targets> -> execute
-
- Bedrock Edition:
-
every bit <origin: target> <chainedCommand: ExecuteChainedOption_0> - Arguments
- JE:
<targets>: entity - Exist:
origin: target- Target entity/entities to go the new executor.
- Must be a role player proper noun, a target selector or a UUID. [ Java Edition only ]
- Result
- Executor is updated to target entity (which changes the meaning of
@s). - Unparseable if the statement is not specified correctly.
- Terminates if
<targets>ororigin: targetfails to resolve to one or more valid entities (named players must be online). - When multiple entities are selected, side by side sub-command is executed once by each executor.
- Case
- Get data of all sheep:
execute equally @e[type=sheep] run data get entity @s[ Java Edition but ] - Make all villagers in loaded chunks invincible:
execute every bit @e[type=villager] run data merge entity @due south {Invulnerable:one}[ Java Edition only ]
-
at [ ]
- Sets the execution position, rotation, and dimension [ needs testing in Bedrock Edition ] to lucifer those of an entity; does non modify executor.
- Syntax
- Java Edition:
-
at <targets> -> execute
-
- Bedrock Edition:
-
at <origin: target> <chainedCommand: ExecuteChainedOption_0> - Arguments
- JE:
<targets>: entity - BE:
origin: target- Target entity/entities to match position, rotation, and dimension with.
- Must be a player name, a target selector or a UUID. [ Java Edition only ]
- Result
- Execution position, rotation, and dimension are updated to friction match target entity.
- Unparseable if the argument is not specified correctly.
- Terminates if
<targets>ororigin: targetfails to resolve to 1 or more valid entities (named players must be online). - When multiple entities are selected, next subcommand is executed once at each entity's execution position, rotation, and dimension.
- Example
- Move all sheep upward 1 block:
execute as @e[type=sheep] at @south run tp ~ ~1 ~ - Kill the histrion running the control, because "
at" does not change the executor:execute at @e[blazon=sheep] run kill @s
-
facing [ ]
- Sets the execution rotation to face a given bespeak, equally viewed from its anchor (either the eyes or the feet)
- Syntax
- Java Edition:
-
facing <pos> -> execute -
facing entity <targets> <anchor> -> execute
-
- Bedrock Edition:
-
facing <position: ten y z> <chainedCommand: ExecuteChainedOption_0> -
facing entity <origin: target> <eyes|feet> <chainedCommand: ExecuteChainedOption_0> - Arguments
- Option: facing <pos>
- JE:
<pos>: vec3 - BE:
position: ten y z- Coordinate to rotate toward
- Must be a iii-dimensional coordinates with floating-point number elements. Accepts tilde and caret notations.
- JE:
- Choice: facing entity <targets> <anchor>
- JE:
<targets>: entity - BE:
origin: target- The target(s) to rotate toward
- Must be a player proper noun, a target selector or a UUID.
- JE:
<anchor>: entity_anchor (eyesorfeet) - Be:
optics|feet- Whether to bespeak at the target'due south eyes or feet
- JE:
- Result
- Execution rotation is updated to face given position or targets
- Unparseable if the argument is not specified correctly
- Terminates if
<targets>ororigin: targetfails to resolve to 1 or more valid entities (named players must be online) - When multiple entities are selected, next subcommand is executed once in each execution rotation
- Case
- Executor rotates once to the left:
execute facing ^one ^ ^ run tp ~ ~ ~[ Coffee Edition only ] - All entities motion 1 block in the direction of (0, 64, 0) (without irresolute their rotation):
execute every bit @e at @s facing 0 64 0 run tp @southward ^ ^ ^ane - All entities motility one block in the direction of (0, 64, 0) (with irresolute their rotation):
execute equally @due east at @s facing 0 64 0 run tp ^ ^ ^1 ~ ~ - All non player entities move 1 space in the direction of their nearest thespian (without irresolute their rotation):
execute as @e[blazon=!thespian] at @s facing entity @p feet run tp @s ^ ^ ^ane
-
in [ ]
- Sets the execution dimension and position
- Information technology respects dimension scaling for relative and local coordinates: the execution position (only the X/Z part) is divided by 8 when changing from the Overworld to the Nether, and is multiplied by 8 when vice versa. Applies to custom dimensions besides.
- Syntax
- Java Edition:
-
in <dimension> -> execute
-
- Bedrock Edition:
-
in <dimension: Dimension> <chainedCommand: ExecuteChainedOption_0> - Arguments
- JE:
<dimension>: dimension - BE:
dimension: Dimension- Name of the new execution dimension
- Must be the resource location of a dimension. The standard dimensions in the minecraft namespace are "overworld", "the_nether"[ JE only ]/"under"[ BE simply ], and "the_end".
- Result
- Execution dimension is updated
- Unparseable if the argument is not specified correctly
- Example
- Looking for an stop metropolis (from the overworld):
execute in the_end run locate construction minecraft:end_city - If a thespian at position
(16,64,16)in Overworld runs commandexecute in minecraft:the_nether positioned equally @due south run tp ~ ~ ~, the player is teleported to(16,64,16)in the Nether. - If a role player at position
(xvi,64,16)in Overworld runs commandexecute in minecraft:the_nether run tp ~ ~ ~, the role player is teleported to(2,64,ii)in the Under. - If a player at position
(80,64,lxxx)in Overworld runs commandexecute in minecraft:the_nether run tp ~ ~ ~5, the actor is teleported to(10,64,xv)in the Nether.
-
positioned [ ]
- Sets the execution position , without irresolute execution rotation or dimension; can match an entity'southward position
- Syntax
- Java Edition:
-
positioned <pos> -> execute -
positioned as <targets> -> execute
-
- Bedrock Edition:
-
positioned <position: 10 y z> <chainedCommand: ExecuteChainedOption_0> -
positioned equally <origin: target> <chainedCommand: ExecuteChainedOption_0> - Arguments
- Option: positioned <pos>
- JE:
<pos>: vec3 - Exist:
position: ten y z- New position
- Must be a three-dimensional coordinates with floating-betoken number elements. Accepts tilde and caret notations.
- JE:
- Selection: positioned as <targets>
- JE:
<targets>: entity - Be:
origin: target- Target entity/entities to match position with
- Must be a histrion name, a target selector or a UUID. [ Coffee Edition only ]
- JE:
- Event
- Execution position is updated. And
positioned <pos>changes execution anchor to feet. - Unparseable if the argument is not specified correctly.
- Terminates if
<targets>ororigin: targetfails to resolve to one or more than valid entities (named players must exist online). - When multiple entities are selected, side by side sub-control is executed one time in each execution position.
- Examples
- Await for a hamlet almost (0, 64, 0)
-
-
execute positioned 0 64 0 run locate structure #hamlet[ Java Edition merely ] -
execute positioned 0 64 0 run locate structure village[ Bedrock Edition only ]
-
-
-
rotated [ ]
- Sets the execution rotation; tin match an entity'due south rotation
- Syntax
- Java Edition:
-
rotated <rot> -> execute -
rotated as <targets> -> execute
-
- Bedrock Edition:
-
rotated <yaw: value> <pitch: value> <chainedCommand: ExecuteChainedOption_0> -
rotated equally <origin: target> <chainedCommand: ExecuteChainedOption_0> - Arguments
- JE:
<rot>: rotation (<yaw> <pitch>) - Exist:
yaw: valueandpitch: value- Must be a rotation with double number elements, including yaw and pitch, measured in degrees.
- For the horizontal rotation (yaw), -180.0 for due northward, -ninety.0 for due east, 0.0 for due south, 90.0 for due west, to 179.9 for only due west of due due north, earlier wrapping dorsum around to -180.0.
- For the vertical rotation (pitch), -xc.0 for straight up to 90.0 for direct down.
- Must be a rotation with double number elements, including yaw and pitch, measured in degrees.
- JE:
<targets>: entity - BE:
origin: target- Target entity/entities to match rotation with
- Must be a player proper name, a target selector or a UUID. [ Java Edition but ]
- Result
- Unparseable if the statement is non specified correctly
- Terminates if
<targets>ororigin: targetfails to resolve to one or more valid entities (named players must exist online). - When multiple entities are selected, next sub-control is executed once in each execution rotation.
- Example
- Movement every sheep one block in the management that the player closest to it is facing:
execute equally @eastward[type=sheep] at @sORpositioned every bit @s rotated every bit @p run tp @s ^ ^ ^i
-
Condition subcommands [ ]
The particular use of the if and unless subcommands are to restrict control execution to happen only under specified conditions. In near cases, unless is a negation of if, equivalent to "if not...". The two commands have identical statement structures.
- Result of condition subcommands
- Unparseable if the statement is non specified correctly.
- In some cases, for example, testing a cake exterior the world, both
ifandunlessterminates or fails. - When non at the end of the subcommands chain, but if the condition tests laissez passer is the subcommand following information technology executed; otherwise it terminates. If information technology is executed multiple times by multiple variables (e.grand. executors, execution positions, execution rotations), information technology acts as a variable filter - Only the variable that matches the status executes the adjacent subcommand.
- When at the finish of the subcommands chain, information technology checks whether the status is met and so outputs.
There are seven[ JE simply ]/four[ Exist only ] different types of conditions:
- (if|unless) biome – Tests a biome area[ Java Edition only ]
- (if|unless) block – Tests a unmarried real cake
- (if|unless) blocks – Tests a existent 3D rectangular volume against some other
- (if|unless) data – Tests the information held by a real block, entity, or a storage[ Java Edition only ]
- (if|unless) entity – Tests whether an entity similar the i given is real
- (if|unless) predicate – Tests a predicate[ Java Edition only ]
- (if|unless) score - Tests a target'south score
(if|unless) biome[ Java Edition only ] [ ]
-
- Syntax
-
(if|unless) biome <pos> <biome> -> [execute]
-
- Arguments
-
<pos>: biome_pos- Position of a target biome to test
-
<biome>: biome_predicate- A valid biome ID to test for
(if|unless) block [ ]
- Compares the block at a given position to a given block ID or block tag.
-
- Syntax
- Coffee Edition:
-
(if|unless) cake <pos> <cake> -> [execute]
-
- Boulder Edition:
-
<subcommand: Option_If_Unless> cake <position: x y z> <block: Block> [chainedCommand: ExecuteChainedOption_0] -
<subcommand: Option_If_Unless> block <position: x y z> <block: Cake> <blockStates: block states> [chainedCommand: ExecuteChainedOption_0] -
<subcommand: Option_If_Unless> block <position: x y z> <block: Cake> <data: int> [chainedCommand: ExecuteChainedOption_0]
-
-
- Arguments
- JE:
<pos>: block_pos - Be:
position: x y z- Position of a target block to test
- It must exist a block position equanimous of <ten>, <y> and <z>, each of which must be an integer or a tilde and caret note.
- JE:
<block>: block_predicate- A valid block ID or block tag to examination for
- It must be in class of
block_id[block_states]{data_tags}(accepts block tags), in which cake states and data tags can be omitted when they are non needed.
- Be:
block: Block- A valid block ID to test for[ more than information needed ]
- Be:
blockStates: cake states- A valid block country for a cake[ more information needed ]
- Exist:
information: int- A valid data value for a block[ more information needed ]
-
- Result
- Unparseable if the argument is non specified correctly
- In following conditions, terminates when this subcommand is not at the end of the subcommands chain; fails when at the end:
- If
<pos>/position: x y zis unloaded or out of the world. - If test doesn't pass.
- If
- When at the end of the subcommands concatenation, and the control is successful,
successvalue andresultvalue is one.
(if|unless) blocks [ ]
- Compares the blocks in 2 equally sized volumes
-
- Syntax
- Java Edition:
-
(if|unless) blocks <start> <end> <destination> (all|masked) -> [execute]
-
- Bedrock Edition:
-
<subcommand: Option_If_Unless> blocks <begin: x y z> <end: x y z> <destination: ten y z> <scan fashion: BlocksScanMode> [chainedCommand: ExecuteChainedOption_0]
-
-
- Arguments
- JE:
<start>: block_pos - BE:
begin: ten y z - JE:
<terminate>: block_pos - BE:
end: ten y z- Positions of any two diagonal corners of the source volume (the comparand; the volume to compare)
- It must be a block position composed of <10>, <y> and <z>, each of which must exist an integer or a tilde and caret annotation.
- JE:
<destination>: block_pos - Exist:
destination: x y z- Position of the lower northwest corner of the destination book (the comparator; the volume to compare to)
- Assumed to be of the same size as the source volume
- It must exist a block position composed of <x>, <y> and <z>, each of which must be an integer or a tilde and caret notation.
- JE:
(all|masked) - Exist:
browse style: BlocksScanMode(allormasked)- Specifies whether all blocks in the source volume should be compared, or if air blocks should be masked/ignored
-
- Effect
- Unparseable if the argument is non specified correctly
- In post-obit atmospheric condition, terminates when this subcommand is not at cease of the subcommands concatenation; fails when at the end:
- If
<start>/begin: 10 y z,<cease>/end: ten y z, or<destination>/destination: 10 y zis unloaded or out of the earth. - If the volume of the source region is greater than 32768 (the equivalent of 8 chunk sections)
- If test doesn't pass.
- If
- When at the end of the subcommands chain, and the control is successful,
successvalue is 1.- For
ifmanner,resultvalue is the number of matching blocks (the total number of blocks inallmode, or the number of source region not-air blocks inmaskedmode). - For
unlessmanner,effectvalue is 1.
- For
(if|unless) data[ Java Edition only ] [ ]
- Checks whether the targeted block, entity or storage has any data tag for a given path
-
- Syntax
-
(if|unless) data block <pos> <path> -> [execute]– for data checking a block -
(if|unless) data entity <target> <path> -> [execute]– for data checking an entity -
(if|unless) data storage <source> <path> -> [execute]– for information checking a storage
-
- Arguments
- Choice:
(if|unless) data block <pos> <path>-
<pos>: block_pos- Position of the cake for information testing.
- Information technology must exist a block position composed of <x>, <y> and <z>, each of which must be an integer or a tilde and caret notation.
-
<path>: nbt_path- Data path to check whether the block has.
- Must be an NBT path.
-
- Option:
(if|unless) information entity <target> <path>-
<target>: entity- A single entity for data testing.
- Must be a player name, a target selector or a UUID.
-
<path>: nbt_path- Information path to check whether the entity has.
- Must be an NBT path.
-
- Option:
(if|unless) data storage <source> <path>-
<source>: resource_location- The resource location of the storage for data testing.
- Must be a resources location.
-
<path>: nbt_path- Information path to bank check whether the storage has.
- Must be an NBT path.
-
-
- Result
- Unparseable if the argument is not specified correctly
- In post-obit weather condition, terminates when this subcommand is not at the end of the subcommands concatenation; fails when at the cease:
- If
<pos>is unloaded or out of the earth. - If cake at
<pos>isn't a block entity. - If
<target>fails to resolve to 1 valid entities (named players must be online) - If test doesn't pass.
- If
- When at the end of the subcommands concatenation, and the control is successful,
successvalue is 1.- For
ifmode,resultvalue is the number of matching information tags. - For
unlessmode,resultvalue is 1.
- For
(if|unless) entity [ ]
- Checks whether ane or more entities exist.
-
- Syntax
- Java Edition:
-
(if|unless) entity <entities> -> [execute]
-
- Bedrock Edition:
-
<subcommand: Option_If_Unless> entity <target: target> [chainedCommand: ExecuteChainedOption_0] - Arguments
- JE:
<entities>: entity - BE:
target: target- The target entity/ies to check
- Must be a histrion name, a target selector or a UUID.[ Java Edition merely ]
- Result
- Unparseable if the argument is non specified correctly
- If test doesn't pass, terminates when this subcommand is not at the finish of the subcommands chain; fails when at the end.
- When at the end of the subcommands chain, and the command is successful,
successvalue is 1.- For
ifmode,effectvalue is the number of matching entities. - For
unlessfashion,resultvalue is 1.
- For
-
(if|unless) predicate[ Java Edition only ] [ ]
- Checks whether the predicate evaluates to a positive result. See Predicate for more information.
-
- Syntax
-
(if|unless) predicate <predicate> -> [execute] - Arguments
-
<predicate>: resource_location- The predicate to be checked whether information technology evaluates to a positive result.
- Must be a resources location.
-
- Upshot
- Unparseable if the statement is not specified correctly
- In following atmospheric condition, terminates when this subcommand is not at the end of the subcommands chain; fails when at the end:
- If the predicate doesn't exist.
- If exam doesn't pass.
- When at the terminate of the subcommands concatenation, and the command is successful,
successandeventvalue is 1.
(if|unless) score [ ]
- Check whether a score has the specific relation to another score, or whether information technology is in a given range.
-
- Syntax
- Java Edition:
-
(if|unless) score <target> <targetObjective> (<|<=|=|>=|>) <source> <sourceObjective> -> [execute]– for comparing two scores -
(if|unless) score <target> <targetObjective> matches <range> -> [execute]– for comparing i score against a range
-
- Bedrock Edition:
-
<subcommand: Option_If_Unless> score <target: target> <objective: string> <performance: compare operator> <source: target> <objective: string> [chainedCommand: ExecuteChainedOption_0]- for comparing two scores -
<subcommand: Option_If_Unless> score <target: target> <objective: string> matches <range: integer range> [chainedCommand: ExecuteChainedOption_0]- for comparing one score against a range
-
-
- Arguments
- JE:
<target>: score_holder - Exist:
target: target- A single score holder.
- Must exist a selection of score holders. It may be either a target selector, a player proper noun, a UUID, or
*for all score holders tracked by the scoreboard. Named thespian needn't be online, and it even needn't be a real thespian's name.
- JE:
<targetObjective>: objective - BE:
objective: cord- The scoreboard objective to check under. The score of <target> in this objective is checked.
- It must be a valid scoreboard objective name.
- Option:
(<|<=|=|>=|>) <source> <sourceObjective>- JE:
<source>: score_holder - Be:
source: target- A single score holder to compare against
- Must be a selection of score holders. It may be either a target selector, a player name, a UUID, or
*for all score holders tracked past the scoreboard. Named player needn't exist online, and it even needn't be a existent role player'south proper noun.
- JE:
<sourceObjective>: objective - Exist:
objective: cord- A scoreboard objective. The score of <source> in this objective is checked.
- It must be a valid scoreboard objective proper name.
- JE:
- Option:
matches <range>- JE:
<range>: int_range - BE:
range: integer range- Range to compare score against
- Must be a range acceptable for integer values. (e.g.
0- exact match of 0...0- less than or equal to 0.0..- more than than or equal to 0.0..one- between 0 and 1, inclusive.)
- JE:
-
- Outcome
- Unparseable if the argument is not specified correctly
- In post-obit weather, terminates when this subcommand is non at the stop of the subcommands concatenation; fails when at the end:
- If
<target>/target: targetor<source>/source: targetis*. - If test doesn't pass.
- If
- When at the end of the subcommands chain, and the control is successful,
successandresultvalue is ane.
Example [ ]
- Kill all players standing on a wool:
execute as @a at @s if block ~ ~-1 ~ #wool run kill @s - Check whether your own scores A and B are equal:
execute if score @southward A = @southward B
Store subcommand [ ]
Store the final command's upshot or success value somewhere. It is first processed along with other subcommands, recording the location to store in. Afterwards the last subcommand (may be a condition subcommand or a run subcommand) is executed, render values are stored in the location. Annotation that the return values of commands must be an integer. If a decimal, it is rounded downwards.
There are five dissimilar modes of storage:
- shop (outcome|success) block – Store return value under 1 of a block's NBTs
- store (result|success) bossbar – Shop return value as a bossbar information
- store (issue|success) entity – Store return value under one of an entity's NBTs
- store (result|success) score – Store render value under a target's score on an objective
- store (result|success) storage – Shop render value under one of a storage'due south NBTs
store (result|success) block [ ]
- Saves the concluding command's render value as tag data within a block entity. Store as a byte, short, int, long, bladder, or double. If the return value is a decimal, information technology is rounded first and then multiplied by
<scale>.
-
- Syntax
-
store (result|success) cake <targetPos> <path> <type> <scale> -> execute
-
- Arguments
-
<targetPos>: block_pos- Position of target block
-
<path>: nbt_path- Location of the desired tag to hold the value in
-
<type>- Desired data size/type
- Must be one of
byte,brusk,int,long,float, ordouble.
-
<calibration>: double- Multiplier to apply before storing value, may be negative
-
- Effect
- Unparseable if the argument is not specified correctly.
- Does not store anything when the path does not exist.
store (result|success) bossbar [ ]
- Saves the terminal command'due south return value in either a bossbar's current value or its maximum value
-
- Syntax
-
store (result|success) bossbar <id> (value|max) -> execute - Arguments
-
<id>: resource_location- ID of the bossbar to target for saving
-
(value|max)- Whether to overwrite the bossbar's current value or its max value
- Result
- Unparseable if the statement is non specified correctly.
store (result|success) entity [ ]
- Save the final command'south return value in one of an entity'south data tags. Shop as a byte, short, int, long, float, or double. If the return value is a decimal, it is rounded first and and so multiplied by
<scale>. Similar the "/data" command, "/execute store <arguments>" cannot change player NBT.
-
- Syntax
-
store (issue|success) entity <target> <path> <type> <scale> -> execute
-
- Arguments
-
<target>: entity- A unmarried entity to store nether
-
<path>: nbt_path- Location of the desired tag to hold the value in
-
<blazon>- Desired data size/type
- Must be one of
byte,brusque,int,long,float, ordouble.
-
<scale>: double- Multiplier to employ before storing value, may be negative
- Result
- Unparseable if the argument is not specified correctly.
- Does not shop anything when the path does not be.
store (upshot|success) score [ ]
- Overrides the score held by
<targets>on the given<objective>with the terminal command's return value.
-
- Syntax
-
store (result|success) score <targets> <objective> -> execute
-
- Arguments
-
<targets>: score_holder- Specifies score holder(s) whose score is to exist overridden
-
<objective>: objective- A scoreboard objective
- Result
- Unparseable if the argument is not specified correctly.
store (result|success) storage [ ]
- Uses the
<path>inside storage<target>to store the return value in. Store every bit a byte, curt, int, long, float, or double. If the return value is a decimal, it is rounded first and then multiplied by<scale>. If the storage does not yet exist, it gets created.
-
- Syntax
-
store (result|success) storage <target> <path> <type> <scale> -> execute
-
- Arguments
-
<target>: resource_location (Unmarried word)- Target storage container, as a resource location
-
<path>: nbt_path- Location of the desired tag to hold the value in
-
<blazon>- Desired information size/type
- Must be one of
byte,short,int,long,float, ordouble.
-
<calibration>: double- Multiplier to utilize before storing value, may be negative
-
- Result
- Unparseable if the argument is not specified correctly
Run subcommand [ ]
The run command's single argument is the command to be executed, the variables of which may be modified past the subcommands used.
-
- Syntax
- Coffee Edition:
-
run --><control>
-
- Bedrock Edition:
-
run <command: command>
-
-
- Arguments
- JE:
<command> - BE:
command: command- Can be any command
-
- Technical[ Java Edition only ]
- Resets the control node to the root of the command dispatcher
- Information on modelling commands as chat text:
- The command dispatcher is what starts when the player begins a message with a forward-slash (
/). - A command node is the specific word/entry the cursor is editing, either a command or an argument.
- The root node comes before the first word in the electric current command.
- The command dispatcher is what starts when the player begins a message with a forward-slash (
-
- Upshot
- Execute this command. Fails if
<command>orcontrol: controlis failure.
More examples [ ]
- Teleport all players who have an detail enchanted with Efficiency in their first hotbar slot to coordinates (0, 64, 0):
-
/execute every bit @a if data entity @southward Inventory[{Slot:0b}].tag.Enchantments[{id:"minecraft:efficiency"}] run tp @s 0 64 0[ Java Edition only ]
-
- Create a smoke particle three blocks in front of all players:
-
/execute as @a at @due south anchored eyes run particle smoke ^ ^ ^3[ Coffee Edition only ]
-
- Place a saddle on pigs located inside 5 blocks of the executing thespian, and remove saddles from pigs located over 5 blocks abroad from the executing player:
-
/execute as @e[blazon=pig] at @s store success entity @s Saddle byte one if entity @p[distance=..5][ Coffee Edition only ]
-
- Make a player say "My feet are soaked!" in chat if they are located in a block of h2o:
-
/execute as @a at @due south if block ~ ~ ~ h2o run say "My feet are soaked!"
-
- Make a role player say "Score is reset" in conversation if the score 'test' is non set, eg past doing "scoreboard players reset @s test":
-
/execute as @a unless score @s test = @s test run say "Score is reset"
-
- Hurl all pigs skyward who are within 3 blocks of the nearest player:
-
/execute at @p as @e[type=hog,distance=..iii] run data merge entity @due south {Motion:[0.0,2.0,0.0]}[ Coffee Edition merely ]
-
- Kill all zombies who accept no headgear:
-
/execute as @e[type=zombie] unless information entity @s ArmorItems[3].id run kill @s[ Coffee Edition only ]
-
History [ ]
| Coffee Edition | |||||
|---|---|---|---|---|---|
| one.eight | 14w07a | Added /execute. | |||
| 14w08a | Commands run using /execute now pass their success value dorsum to the command block running them. | ||||
| 1.xi | 16w32a | Added cake land support to /execute. | |||
| 1.xiii | 17w45a | The syntax of /execute has been split off. | |||
| 17w45b | Reworked /execute store (effect|success). | ||||
| 18w02a | Added new subcommands to /execute to permit for more control over commands. | ||||
| 18w05a | Added /execute store bossbar. | ||||
| one.14 | 18w43a | Added /execute (if|unless) information. | |||
| ane.fifteen | 19w38a | Added /execute if predicate <predicate>. | |||
Added /execute store storage. | |||||
| 1.19.iii | 22w46a | Added /execute (if|unless) biome. | |||
| Pocket Edition Alpha | |||||
| v0.16.0 | build 1 | Added /execute. | |||
Functionality most is equivalent to Java Edition 1.10 usage, except the entity target is optional in /execute. | |||||
| Bedrock Edition | |||||
| Upcoming Creator Features (experimental) | beta i.19.ten.20 | Updated /execute syntax to closer resemble that of Coffee Edition | |||
| beta one.19.40.20 | Implemented the /execute rotated control. | ||||
| beta 1.19.xl.21 | Implemented the /execute facing and /execute marshal commands. | ||||
| beta 1.19.40.23 | Implemented the /execute anchored and /execute in commands. | ||||
| 1.19.50 | beta one.19.l.23 | The new /execute syntax, more than similar to Java Edition is no longer behind the "Upcoming Creator Features" experimental toggle. | |||
Source: https://minecraft.fandom.com/wiki/Commands/execute

0 Response to "How To Detect Entities In Minecraft"
Post a Comment