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, @p[a=0,b=5,c=-500]
.
There is a special short syntax for just specifying x
, y
, z
and r
arguments; simply list their values separated by a comma, without x=
. For example: @p[100,64,-100,5]
for 5 range, x=100
, y=64
and z=-100
. Each of these are optional and skippable by leaving them empty. For example, to just specify y
coordinate: @p[,64]
.
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.
@p[r=5]
Closest person within 5 blocks. If there's nobody within 5 blocks, the command will fail.
@a[x=100,y=64,z=-100,c=10,r=5]
Closest 10 players within 5 blocks of 100,64,-100.
@p[0,64,0,c=-2]
The furthest 2 players from 0,64,0.
@a[,,,10,c=5]
The closest 5 players within 10 blocks of your current position.
@ShareDVI I strongly suggest that multiple commands in the command block is a bad idea.
It'd be wiser in my opinion to be able to have a default server command that executes a predefined script that has been uploaded to the server somehow, which has access to all the @* data in the script.
Mostly, because scripts will get unweildy and complicated, and if your only interface to edit these scripts is Minecraft, well, I can see "oops, dialog closed and I lost all my chages" being a real nightmare, let alone the question "how do I version this code in git?".
Perhaps it would also be nice to have a standard feature in the client side that allows users to select a file on their local machine, and upload it over the minecraft protocol, and store it on the server, in order to associate that script with the command block.
Additionally, it may be nice to be able to grant people some kind of "read only" access to various command blocks so they can see what code it runs.