All target selectors start with
@. The following character is the selector type. For example,
@p means 'closest player'.
Target selectors may have additional, optional arguments. You can specify these in
[ ], using the syntax
a=0. For example,
There is a special short syntax for just specifying
r arguments; simply list their values separated by a comma, without
x=. For example:
@p[100,64,-100,5] for 5 range,
z=-100. Each of these are optional and skippable by leaving them empty. For example, to just specify
x- X coordinate for search center. Default is senders coordinate, or 0.
y- Y coordinate for search center. Default is senders coordinate, or 0.
z- Z coordinate for search center. Default is senders coordinate, or 0.
r- Range, number above 0. Default 0 ("No range limit")
m- Game mode, number above 0. Default -1 ("No mode limit")
c- Max count of results. Default 0 ("No count limit"). Numbers below 0 will make it return the last x amount of entries.
p- Closest player.
a- A list of all players.
r- A random player.
All selectors are lists, but only
p has a default count limit of 0 (unlimited). When using lists in a string context (for example,
/say Hello @a) it will list all players as strings. When used as a command argument, it will iterate the command for each player in the list.
Closest person within 5 blocks. If there's nobody within 5 blocks, the command will fail.
Closest 10 players within 5 blocks of 100,64,-100.
The furthest 2 players from 0,64,0.
The closest 5 players within 10 blocks of your current position.