![]() |
VOOZH | about |
Target selectors are used in commands to select players and entities arbitrarily, without needing to specify an exact player name or a UUID. One or more entities can be selected with a target selector variable, and targets can be filtered from the selection based on certain criteria using the target selector arguments.
| Variable | Selects |
|---|---|
@p |
the nearest player |
@r |
a random player |
@a |
all players |
@e |
all entities |
@s |
the entity executing the command |
@n |
the nearest entity |
@c |
the player's agentβ[edu only] |
@v |
all agentsβ[edu only] |
@initiator |
the player who clicks an NPC dialogue buttonβ[BE & edu only] |
A target selector variable identifies the broad category of targets to select. There are six in Java Edition, seven in Bedrock Edition and nine in Minecraft Education:
@p@p selects only players who are alive.@n@r@r can be used to select non-player entities via the type selector argument; in Java Edition, to select a random entity, use @e[sort=random,limit=1] or @n[sort=random] instead.@r can select only entities who are alive.@a@e@s@cβ[Minecraft Education only]@vβ[Minecraft Education only]| Selection by Spatial Properties | ||
|---|---|---|
| Argument(s) | Selection criteria | |
x, y, z
|
coordinate | |
distanceβ[JE only]r, rmβ[BE only]
|
distance | |
dx, dy, dz
|
volume dimensions | |
x_rotationβ[JE only]rx,rxmβ[BE only]
|
vertical rotation (pitch) | |
y_rotationβ[JE only]ry,rymβ[BE only]
|
horizontal rotation (yaw) | |
| Selection by Scoreboard Values | ||
| Argument(s) | Selection criteria | |
scores
|
scores | |
tag
|
tag | |
team β[JE only]
|
team name | |
| Selection by Entity Species | ||
| Argument(s) | Selection criteria | |
name
|
entity name | |
type
|
entity type | |
familyβ[BE only]
|
entity family | |
predicateβ[JE only]
|
predicate | |
| Selection by Entity Data | ||
| Argument(s) | Selection criteria | |
nbtβ[JE only]
|
nbt | |
hasitemβ[BE only]
|
item | |
has_propertyβ[BE only]
|
property | |
| Selection by Player Data | ||
| Argument(s) | Selection criteria | |
levelβ[JE only]l,lmβ[BE only]
|
experience level | |
gamemodeβ[JE only]mβ[BE only]
|
game mode | |
advancementsβ[JE only]
|
advancements | |
haspermissionβ[BE only]
|
permission | |
| Selection by Traits | ||
| Argument(s) | Selection criteria | |
limit,sortβ[JE only]cβ[BE only]
|
limit | |
After a target selector, optional arguments can be used to narrow down the set of targets to a group that also matches certain criteria. When used with @a or @e, arguments narrow down the targets from the full list to a specific group. When used with @p or @r, the nearest or random player is selected from the group. When used with @s, the player using the command is targeted only if they would be in the narrowed group.
Argument-value pairs appear within square brackets after the target selector variable, separated by commas:
@<variable>[<argument>=<value>,<argument>=<value>,...].In Java Edition, arguments and values are case-sensitive. Spaces are allowed around the brackets, equal signs, and commas, except in Java Edition between the target variable and the first bracket. Commas must be used to separate argument-value pairs.
If there are multiple argument-value pairs, they all must be satisfied to add a potential target to the group. (In other words, they are AND-ed together).
[x=<value>,y=<value>,z=<value>] β Define a position in the world that the selector starts at, for use with the distance argument, the volume arguments, or the sort and limit arguments. Using these arguments alone does not restrict the entities found (except in Java Edition), and affect only the sorting of targets. Cannot duplicate any one of these three arguments.12.34. In Java Edition they are not center-corrected, meaning x=0 is not corrected to x=0.5. In Bedrock Edition, if distance or volume arguments are not used, positions that are written as integers are center-corrected, x=0 becomes x=0.5. To avoid this, use x=0.0 instead./execute in overworld as @e[x=0] will select only entities that are in the overworld.[distance=<value>] β Specifies the range of distance. Float ranges are supported to select a specific region. Only unsigned values are allowed.[r=<value>] and [rm=<value>] β Specifies the maximum and minimum range to find entities, respectively. Only unsigned values are allowed.@e[distance=10..] β Target all entities more than ten blocks away.@e[distance=..10] β Target all entities less than ten blocks away.@e[distance=10] β Target all entities exactly ten blocks away.@e[distance=8..16] β Target all entities more than eight blocks, but less than 16 blocks away (inclusive).@e[r=10] β Target all entities that are ten or fewer blocks away.@e[rm=10] β Target all entities that are ten or more blocks away.@e[rm=10,r=10] β Target all entities exactly ten blocks away.@e[rm=8,r=16] β Target all entities from 8 to 16 blocks away.[dx=<value>,dy=<value>,dz=<value>] β Filter target selection based on their x-difference, y-difference, and z-difference from some point, as measured by entities' hitboxes. Cannot duplicate any one of these three arguments.(x,y,z) to (x+dx,y+dy,z+dz) but with the vector (1,1,1) added to the x-most, y-most, z-most corner (the upper south-east corner). Because of this, the volume to check can never be smaller than a cube with a side length of 1, and no single dimension of the volume can be less than 1. Then, all entities whose hitboxes at least partially intersect with that volume are selected. If the positional arguments are left out, the selection is interpreted as originating from the position of the command's execution. Any values are allowed, including signed and fractional numbers.x y z) to the delta position (x+dx y+dy z+dz)) and selecting any entity whose hitbox intersects with those blocks. So, if you have built a cuboid of blocks in the world, you can subtract the coordinates of one corner block from the coordinates of the opposite corner block to get the dx, dy, and dz values for selecting those entities.dx, dy, and dz specify signed differences from the given coordinate. They do not specify a separate coordinate, nor do they extend in both the positive and negative directions as you might expect from a position predicate.@a[dx=15] is equivalent to @a[dx=15,dy=0,dz=0].@e[x=1,y=2,z=3,dx=0,dy=0,dz=0] β Select all entities whose hitbox intersects with the block at 1 2 3.@e[x=1,y=2,z=3,dx=4,dy=5,dz=-6] β Select all entities whose hitbox intersects with the block region 1~5, 2~7, -3~3.
1.0 2.0 -3.0 to 6.0 8.0 4.0).{ (x,y,z)βRΒ³ | xβ[1.0,6.0], yβ[2.0,8.0], zβ[-3.0,4.0] }), or [scores={<objective>=<value>,...}] β Filter target selection based on their scores in the specified objectives. All tested objectives are in a single object, separated by commas. Each objective and score value pair is separated by an equals sign. The score values support integer ranges. Cannot duplicate this argument.
@e[scores={myscore=10}] β Select all entities with a score in objective myscore of exactly ten.@e[scores={myscore=10..12}] β Select all entities with a score in objective myscore of between ten and 12 (inclusive).@e[scores={myscore=5..}] β Select all entities with a score in objective myscore of five or greater.@e[scores={myscore=..15}] β Select all entities with a score in objective myscore of 15 or less.@e[scores={foo=10,bar=1..5}] β Select all entities with a score in objective foo of exactly ten, and a score in objective bar of between one and five (inclusive).! can be used to invert selection.
@e[scores={myscore=!10}] β Exclude any entities with a score in objective myscore of exactly ten.@e[scores={myscore=!10..15}] β Exclude any entities with a score in objective myscore of between ten and 15 (inclusive).[tag=<string>] β Include only targets with the specified tag.[tag=!<string>] β Exclude any targets with the specified tag.[tag=] β Include only targets with exactly zero tags.[tag=!] β Include only targets that have at least one tag.[team=<teamName>] β Include only targets in the given team.[team=!<teamName>] β Exclude any targets in the given team.[team=] β Include only targets not in a team.[team=!] β Exclude any targets not in a team.@p and @r, this argument defaults to one. Applying the limiting argument to them may increase the number of nearest or random targets selected. When applying this argument to @a or @e, this argument returns only a limited number of targets. Cannot duplicate these arguments.[limit=<value>,sort=(nearest|furthest|random|arbitrary)] β Limit the number of targets, and specify selection priority.
sort=nearest β Sort by increasing distance. (Default for @p)sort=furthest β Sort by decreasing distance.sort=random β Sort randomly. (Default for @r)sort=arbitrary β Do not sort. This often returns the oldest entities first due to how the game stores entities internally, but no order is guaranteed. (Default for @e, @a)[c=<value>] β Limit the number of targets.@p, @a, and @e, [c=<value>] selects only the specified number of targets by increasing distance from the selector's position. When c is negative, it reverses the order of targeting (for example, @p[c=-1] targets the furthest player). Inverse sorting does not work with @r.@a[limit=3,sort=nearest] or @p[limit=3] β Select the nearest three players.@a[limit=4,sort=furthest] β Select the furthest four players.@a[limit=2,sort=random] or @r[limit=2] β Select two players, chosen randomly.@a[c=3] β Select the nearest three players.@a[c=-4] β Select the furthest four players.@r[c=2] β Select two living players, chosen randomly.[level=<value>] β Specifies the range of levels. Integer ranges are supported to select a range of values.[l=<value>] and [lm=<value>] β the maximum and minimum level range to search for, respectively.@a[level=10] β Select all players who have exactly ten levels.@a[level=8..16] β Select all players who have between eight and 16 levels (inclusive).@a[lm=10,l=10] β Select all players who have exactly ten levels.@a[lm=8,l=16] β Select all players who have between eight and 16 levels (inclusive).[gamemode=<gamemodeName>] β Include only players in the given game mode.[gamemode=!<gamemodeName>] β Exclude any players in the given game mode.[m=<gamemodeName>] β Include only players in the given game mode.[m=!<gamemodeName>] β Exclude any players in the given game mode.spectator, survival, creative, adventure and defaultβ[BE only]. In Bedrock Edition, the shorthand values s and 0, c and 1, a and 2, and d and 5 may be used for Survival mode, Creative mode, Adventure mode, and Default mode respectively.[name=<givenName>] β Include only targets with the given name.[name=!<givenName>] β Exclude any targets with the given name.[x_rotation=<value>] β Specifies the range of x-rotation. Float ranges are supported to select a specific range of angles.[rx=<value>] and [rxm=<value>] β Specifies the maximum and minimum x-rotation, respectively.@e[x_rotation=0] β Select all entities that are looking directly at the horizon.@e[x_rotation=30..60] β Select all entities that are looking between 30Β° and 60Β° (inclusive) below the horizon.@e[x_rotation=..0] β Select all entities that are looking at or above the horizon.@e[rxm=0,rx=0] β Selects all entities that are looking directly at the horizon.@e[rxm=30,rx=60] β Selects all entities that are looking between 30Β° and 60Β° (inclusive) below the horizon.@e[rx=0] β Select all entities that are looking at or above the horizon.[y_rotation=<value>] β Specifies the range of y-rotation. Float Ranges are supported to select a specific range of angles.[ry=<value>] and [rym=<value>] β Specifies the maximum and minimum y-rotation values, respectively.@e[y_rotation=0] β Select all entities that are facing due south.@e[y_rotation=-90..0] β Select all entities that are facing in the 90Β° between due east and due south (inclusive).@e[y_rotation=0..180] β Select all entities that are not facing at all east.@e[rym=0,ry=0] β Select all entities that are facing due south.@e[rym=-90,ry=0] β Select all entities that are facing in the 90Β° between due east and due south (inclusive).@e[rym=0,ry=180] β Select all entities that are not facing at all east.minecraft namespace. Entity IDs or tags are case-sensitive. Arguments testing for equality cannot be duplicated, while arguments testing for inequality can. In Java Edition, using this argument with @a, @p or @r is not allowed.[type=<entityType>] β Include only targets of the specified entity type or tag.[type=!<entityType>] β Exclude any targets of the specified entity type or tag.type=<entityType> (without ! symbol) can appear only once, and type=!<entityType> cannot appear with it. If type=<entityType> does not exist, then type=!<entityType> may appear multiple times.@e[type=creeper] - Include only creepers.@e[type=creeper, type=pig] - Invalid selector.@e[type=creeper, type=!pig] - Invalid selector.@e[type=!creeper, type=!pig] - Exclude all creepers and pigs.mob and inanimate, as well as more specific families like zombie and skeleton, and single-mob families like wandering_trader and creeper. Multiple family arguments are allowed, and all arguments must be fulfilled for an entity to be selected.[family=<family>] β Include only targets in the specified type family.[family=!<family>] β Exclude any targets in the specified type family.@e[family=skeleton] β Select all skeletons, wither skeletons, strays, bogged, parched, and withers.@e[family=mob,family=!monster] β Select all mobs that are not monsters (so for example cows, chickens, pigs, but not zombies or skeletons).@e[family=monster,family=undead] β Select all monsters that are also undead (that includes monsters like zombies and skeletons, but not creepers, spiders or endermen).[nbt=<compoundTag>] β Include only targets with the specified NBT data.[nbt=!<compoundTag>] β Exclude any targets with the specified NBT data.@a[nbt={OnGround:true}] β Select all players on the ground.@e[type=sheep,nbt={Color:0b}] β Select all sheep that are dyed white.@e[type=item,nbt={Item:{id:"minecraft:slime_ball"}}] β Selects all slime ball item entities.@e[nbt={Tags:[a,b]}] is the same as @e[tag=a,tag=b]. The latter is simpler and reduces CPU load.[advancements={<resource location>=<bool>}] β Include only players with the specified advancements and values.[advancements={<resource location>={<criteria>=<bool>}}] β Include only players with the specified advancement's criteria.@a[advancements={story/smelt_iron=true}] β Include only players who have completed the advancement minecraft:story/smelt_iron.@a[advancements={story/form_obsidian=false}] β Include only players who haven't completed the advancement minecraft:story/form_obsidian.@a[advancements={story/follow_ender_eye=true}] is the same as @a[advancements={story/follow_ender_eye={in_stronghold=true}}].@a[advancements={adventure/kill_all_mobs={witch=true}}] β Include only players who have killed a witch, for the advancement minecraft:adventure/kill_all_mobs.[predicate=<resource location>] β Include only targets that match the specified predicate.[predicate=!<resource location>] β Exclude any targets that match the specified predicate.[hasitem={<argument>=<value>,<argument2>=<value2>,...}] β Include only targets that have the specified items.[hasitem=[{<argumentA>=<valueA>,...},{<argumentB>=<valueB>,...}]] β Include only targets that have item A and item B, etc.item (required)
data
{item=potion} can target only water bottle, though {item=potion,data=1} can target mundane potion.data is always considered as invalid and defaults back to 0, and aux value of these items in inventory are also always considered as 0. That means you can't target items like coarse dirt, green wool solely.quantity
1 - exact match of 1. ..5 - less than or equal to 5. 5.. - more than or equal to 5. 0..5 - between 0 and 5, inclusive.).! can be used to invert selection. For example, {item=apple,quantity=!5} can exclusive entities who have five apples.quantity=1... When quantity=0, entities must have 0 the specified item (i.e. do not have the specified item) to be targeted.location and slot
slot without location is invalid.slot must be an integer range. (e.g. 1 - exact match of 1. ..5 - less than or equal to 5. 5.. - more than or equal to 5. 0..5 - between 0 and 5, inclusive.)@s[hasitem={item=stick,location=slot.weapon.mainhand}][haspermission={<permission>=<state>,...}] β Filter target selection based on the player permissions status. All tested permissions are in a single object, separated by commas. Cannot duplicate this argument.@a[haspermission={camera=enabled}] β Include only players who have the camera permission enabled.@a[haspermission={movement=disabled}] β Include only players who have the movement permission disabled.@a[haspermission={camera=disabled,movement=enabled}] β Include only players who have the camera permission disabled and the movement permission enabled.[has_property={<property>=<value>,...}] β Include only targets that have the specified property values.[has_property={<property>=!<value>,...}] β Exclude only targets that have the specified property values.[has_property={property=<property>,...}] β Include only targets that have the specified properties.[has_property={property=!<property>,...}] β Exclude only targets that have the specified properties.@e[type=chicken,has_property={minecraft:climate_variant=!"cold"}] β Selects all chickens that do not have the minecraft:climate_variant property cold.@e[has_property={minecraft:climate_variant="warm"}] β Selects all entities that have the minecraft:climate_variant property warm (it would only apply to cows, chickens, etc.).@e[has_property={minecraft:has_nectar=true}] β Selects all entities that have the minecraft:has_nectar property true (it would only apply to bees).@e[has_property={minecraft:creaking_swaying_ticks=!1..}] β Selects all entities that do not have the minecraft:creaking_swaying_ticks property 1 or higher (it would apply to all entities except creakings that are swaying).@e[has_property={minecraft:climate_variant=!"temperate",property=minecraft:climate_variant}] β Selects all entities that have the minecraft:climate_variant property except those whose value is temperate.@e[has_property={property=minecraft:armadillo_state}] β Selects all entities that have the minecraft:armadillo_state property.unrolled, rolled_up, rolled_up_peeking, rolled_up_relaxing, or rolled_up_unrolling β Applies to π Imagetrue or false β Applies to π Imagenone, take, take_fail, put, or put_fail β Applies to π Imagetemperate, warm, or cold β Applies to π Imageneutral, hostile_observed, hostile_unobserved, twitching, or crumbling β Applies to π Image0 to 6 β Applies to π Imagetrue or false β Applies to π Imagetrue or false β Applies to π Imagetrue or false β Applies to π Imagetrue or false β Applies to π Imagetrue or false β Applies to π Imageunoxidized, exposed, weathered, or oxidized β Applies to π Imagedefault, big, cute, grumpy, mad, puglin, or sad β Applies to π Imagetrue or false β Applies to π ImageSome command arguments require a player-type selector, while some require an entity-type selector.
Entity type means that there's no additional restrictions. Any valid selector can be used in this command argument.
A player-type selector is a selector that can only select players, including:
@e, @n with type=player.@a, @p (without type argument in Bedrock Edition).@r with type=playerβ[Bedrock Edition only] or without type argument.In Java Edition, if a command argument requires a player type selector, but the entered argument is not in player type, the command is unparseable.
In Bedrock Edition, if a command argument requires a player type selector, but the entered argument is not in player type, the command is parseable but fails.
Some command arguments require a single-type selector, while some require a multiple-type selector.
Multiple type means that there's no additional restrictions. Any valid selector can be used in this command argument.
A single-type selector is a selector that can only select one target, including:
@a, @e with limit=1.@s without limit argument.@p, @r without limit argument or with limit=1.If a command argument requires a single-type selector, but the entered argument is not in single-type, the command is unparseable.
| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.4.2 | 12w32a | Added target selectors. | |||||
| 12w38a | Added target selector arguments with x, y, z, r, m and c. | ||||||
| 12w39b | Added l and lm target selector arguments for indicating players with a maximum level, and minimum level, respectively. | ||||||
Added the rm target selector argument for indicating players from a minimum distance. | |||||||
| ? | Added the name target selector argument. | ||||||
| 1.5 | ? | Added the score_objective and score_objective_min target selector arguments, where objective should be replaced with the objective to test. | |||||
Added the team target selector argument. | |||||||
| 1.8 | 14w02a | Added the @e target selector variable. | |||||
Added the type target selector argument. | |||||||
| 14w03a | Added dx, dy, and dz target selector arguments. | ||||||
| 14w07a | Added rx, rxm, ry and rym target selector arguments. | ||||||
| 1.9 | 15w32b | Added the tag target selector argument. | |||||
| 16w02a | The m selector now accepts the standard literal gamemode values and abbreviations, such as a and adventure, and these may be negated as well. | ||||||
| 1.11 | 16w38a | Removed implicit target selectors (for example, @e[167,28,454]).
| |||||
Invalid target selectors (such as @e[Type=creeper], @e[asdf=nonexistent], and @e[malformed]) now generate an error instead of being silently ignored. | |||||||
| 1.12 | 17w16b | Added the @s target selector variable. | |||||
| 1.13 | 17w45a | Target selector arguments can now be quoted. | |||||
The shorthand argument names have been renamed.
| |||||||
Arguments that formerly had a "min" and "max" now support ranges using .. (for example distance=12..34).
| |||||||
x, y, z, distance, x_rotation, and y_rotation arguments are now doubles.
| |||||||
x and z are no longer center-corrected.
| |||||||
gamemode argument no longer allows numerical or shorthand IDs.
| |||||||
limit argument no longer supports negative values for sorting by furthest.
| |||||||
name argument now supports spaces (as long as it is quoted).
| |||||||
| Multiple occurrences of the same argument is now possible. | |||||||
Added sort and advancements arguments.
| |||||||
Specifying scores now looks like scores={foo=1,bar=1..5}.
| |||||||
| 17w45b | Added the nbt target selector argument. | ||||||
| 1.15 | 19w38a | Added the predicate target selector argument. | |||||
| 1.21 | 24w21a | Added the @n selector which selects the nearest entity. | |||||
| pre1 | @n no longer selects dying entities.[1] | ||||||
| 1.21.5 | 25w05a | The team argument can now select non-living entities.[2] | |||||
| Pocket Edition Alpha | |||||||
|---|---|---|---|---|---|---|---|
| v0.16.0 | build 1 | Added target selectors along with Commands. | |||||
| Bedrock Edition | |||||||
| 1.17.10 | beta 1.17.10.22 | Added the @initiator target selector variable. | |||||
| 1.18.30 | beta 1.18.20.21 | Added the hasitem target selector argument. | |||||
| 1.19.80 | Preview 1.19.80.21 | Added the haspermission target selector argument. | |||||
| 1.20.70 | Preview 1.20.70.21 | Added the has_property target selector argument. | |||||
| 1.21.100 | Preview 1.21.100.21 | Added the @n selector which selects the nearest entity. | |||||
Issues relating to "Target selectors" are maintained on the bug tracker. Issues should be reported and viewed there.