Skip to content

Instantly share code, notes, and snippets.

@jgierer12
Forked from Dinnerbone/gist:3736487
Created April 21, 2014 20:42
Show Gist options
  • Save jgierer12/11155896 to your computer and use it in GitHub Desktop.
Save jgierer12/11155896 to your computer and use it in GitHub Desktop.

Syntax

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 argument=value. For example, @p[x=0,y=5,z=-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].

Global Arguments:

Argument Function Default Restrictions Notes
x X coordinate for the search area, being the center for radial selection and the starting corner for cubic selection Executors X coordinate Must be an integer n/a
y Y coordinate for the search area, being the center for radial selection and the starting corner for cubic selection Executors Y coordinate Must be an integer n/a
z Z coordinate for the search area, being the center for radial selection and the starting corner for cubic selection Executors Z coordinate Must be an integer n/a
dx X coordinate offset to define a rectangular search area 0 Must be an integer -1 = None
dy Y coordinate offset to define a rectangular search area 0 Must be an integer -1 = None
dz Z coordinate offset to define a rectangular search area 0 Must be an integer -1 = None
r Maximum search radius -1 Must be an integer -1 = None
rm Minimum search radius -1 Must be an integer -1 = None
rx Maximum x rotation n/a Must be an integer n/a
rxm Minimum x rotation n/a Must be an integer n/a
ry Maximum y rotation n/a Must be an integer n/a
rym Minimum y rotation n/a Must be an integer n/a
m A player's game mode -1 Must be either -1, 0, 1, 2 or 3 -1 = All; 0 = Survival; 1 = Creative; 2 = Adventure; 3 = Spectator
c Number of players (or entities) n/a Must be an integer If negative, uses players (or entities) from the end of the list first
l Maximum experience level of players n/a Must be an integer n/a
lm Minimum experience level of players n/a Must be an integer n/a
score_name For the objective name, the maximum score this player (or entity) has n/a Must be an integer n/a
score_name_min For the objective name, the minimum score this player (or entity) has n/a Must be an integer n/a
team Checks if player is in the specified team n/a Must be a string Inserting an ! before the team name checks only for players not on this team; Providing no team name allows for checking for all players without a team
name Checks for players or entities with this name n/a Must be a string Inserting an ! before the name checks only for players/entities who do not have this name
type Checks for entities with this entity type n/a Must be a string Inserting an ! before the name checks only for entities of another type

Selectors:

Selector Function
p Nearest player
r Random player
a All players
e All Entities

All selectors are lists, but only p and r have a default count limit of 1. 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.

Examples

  • @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.

  • @e[,,,10,c=5,type=Zombie]: The closest 5 Zombies within 10 blocks of your current position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment