Skip to content

Instantly share code, notes, and snippets.

@Sidneys1
Forked from Dinnerbone/gist:3736487
Last active September 21, 2019 17:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Sidneys1/ff8d5d0c818e536ebf38 to your computer and use it in GitHub Desktop.
Save Sidneys1/ff8d5d0c818e536ebf38 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 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].

Global Arguments:

(Case sensitive)

  • 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 - Maximum range, number above 0.
  • rm - Minimum range, number above 0.
  • m - Game mode, number above 0.
  • c - Max count of results. Numbers below 0 will make it return the last x amount of entries.
  • l - Maximum experience level, number above 0.
  • lm - Minimum experience level, number above 0.
  • score_name - Maximum value of a scoreboard objective named 'name'.
  • score_name_min - Minimum value of a scoreboard objective named 'name'.
  • team - Scoreboard team name.
  • name - Player or entity name.
  • dx - Volume dimension X. If dx, dy, or dz are specified, search area is cuboid area from point (x,y,z) with dimensions (dx,dy,xz)
  • dy - Volume dimension Y.
  • dz - Volume dimension Z.
  • rx - Maximum vertical orientation.
  • rxm - Minimum vertical orientation.
  • ry - Maximum horizontal orientation.
  • rym - Minimum horizontal orientation.
  • type - Entity type.

Selectors:

  • p - Closest player.
  • a - A list of all players.
  • r - A random player.
  • e - A list of all entities (including players)

All selectors are lists, but only a and e have 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.

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.

@Cyxo
Copy link

Cyxo commented Jun 15, 2015

Hi think that the "maximum range" r doesn't work very good... I tried
@e[r=5]
and it selected all entities without taking care of this range...

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