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

Argument

distance

Value type

Range

Description

Distance from where the command was run

Example

@e[distance=..10] selects all entities within a 10-node radius (inclusive) of the execution position.

Argument

gamemode/m

Value type

String (creative or survival)

Description

Filters entities based on gamemode (in non-MineClone-like games, they are filtered by whether they have the creative privilege). Non-players are excluded.

Example

@a[gamemode=creative] selects all players in creative mode.

Argument

level

Value type

Range

Description

Filters entities based on their experience level (MineClone-like games only). Non-players are excluded.

Example

@a[level=..5] selects all players with 5 XP levels or less.

Argument

limit/c

Value type

Number

Description

The maximum number of entites to match. limit and c do exactly the same thing, and only one can be included.

Example

@e[sort=furthest, limit=5] selects the furthest 5 entities.

Argument

lm/l

Value type

Number

Description

Equivalent to level=<lm>..<l> (m is for minimum)

Example

@a[lm=5,l=23] selects all players with 5 to 23 XP levels (inclusive).

Argument

name

Value type

String (can include spaces)

Description

The name of the entity. Can use ! to select only non-matching entities.

Example

@a[name=!ThePython10110] selects all players that do not have the name ThePython10110.

Argument

rm/r

Value type

Number

Description

Equivalent to distance=<rm>..<r> (m is for minimum)

Example

@e[rm=4] selects all entities outside of a 4-node radius (inclusive) of the execution position.

Argument

sort

Value type

String

Description

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).

Example

@e[sort=nearest,limit=1 selects the nearest entity.

Argument

type

Value type

String (entity ID or alias)

Description

The type of entity (such as mobs_mc:zombie). Can use ! to select only non-matching entities.

Example

@e[type=player] is equivalent to @a (but slower).

Argument

x/y/z

Value type

Absolute or relative coordinate

Description

Changes the position for the distance/rm/r arguments. If one or more are left out, they stay the same.

Example

@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

Version
Action

v1.0

Added target selectors

v2.0

Added level, lm/l, and gamemode/m selector arguments

Last updated