Target Selectors
Target selectors allow you to choose specific entities.
There are 6 selectors:
A player name.
@s
: Self (the player or command block running the command)@a
: All players@e
: All entities@r
: Random player@p
: Nearest player
@r
and @p
can also select multiple players or other entities if using the type
or limit
/c
arguments (explained below).
Selector Arguments
Selectors support various arguments, which allow you to select more specific entities. To add arguments to a selector, put them in [square brackets]
like this:
@e[type=mobs_mc:zombie,name=Bob]
You can include spaces if you want (although this many spaces seems a bit excessive):
@e [ type = mobs_mc:zombie , name = Bob ]
This selector selects all MCLA/VL zombies named Bob.
All arguments must be satisfied for an entity to be selected.
@s
and player names do not support arguments.
Excluding with !
!
Some arguments (such as name
and type
) allow you to prefix the value with !
. This means that it will match anything except the entered value. For example, since @e[type=player]
matches all players, @e[type=!player]
matches all entities that are not players. Arguments testing for equality cannot be duplicated, while arguments testing for inequality can. In other words, you can have as many type=!<something>
as you want but only one type=<something>
.
Current argument list
distance
Range
Distance from where the command was run
@e[distance=..10]
selects all entities within a 10-node radius (inclusive) of the execution position.
gamemode
/m
String (creative
or survival
)
Filters entities based on gamemode (in non-MineClone-like games, they are filtered by whether they have the creative
privilege). Non-players are excluded.
@a[gamemode=creative]
selects all players in creative mode.
level
Range
Filters entities based on their experience level (MineClone-like games only). Non-players are excluded.
@a[level=..5]
selects all players with 5 XP levels or less.
limit
/c
Number
The maximum number of entites to match. limit
and c
do exactly the same thing, and only one can be included.
@e[sort=furthest, limit=5]
selects the furthest 5 entities.
lm
/l
Number
Equivalent to level=<lm>..<l>
(m
is for minimum)
@a[lm=5,l=23]
selects all players with 5 to 23 XP levels (inclusive).
name
String (can include spaces)
The name of the entity. Can use !
to select only non-matching entities.
@a[name=!ThePython10110]
selects all players that do not have the name ThePython10110
.
rm
/r
Number
Equivalent to distance=<rm>..<r>
(m
is for minimum)
@e[rm=4]
selects all entities outside of a 4-node radius (inclusive) of the execution position.
sort
String
The method for sorting entities. Can be Can be arbitrary
(default for @a
and @e
), nearest
(default for @p
), furthest
, or random
(default for @r
).
@e[sort=nearest,limit=1
selects the nearest entity.
type
String (entity ID or alias)
The type of entity (such as mobs_mc:zombie
). Can use !
to select only non-matching entities.
@e[type=player]
is equivalent to @a
(but slower).
x
/y
/z
Absolute or relative coordinate
Changes the position for the distance
/rm
/r
arguments. If one or more are left out, they stay the same.
@e[y=3.5, z=~-10, distance=..10]
selects all entities within a 10-node radius (inclusive) of ~ 3.5 ~-10
(relative to the execution position).
History
v1.0
Added target selectors
v2.0
Added level
, lm
/l
, and gamemode
/m
selector arguments
Last updated