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.
Posted the original version these on http://www.minecraftforum.net/topic/1487156-new-command-block-commands-list/page__gopid__18816142#entry18816142
Would be nice to have the ability to target mobs.
Creatures (Passive, Hostile, Player):
@nc Nearest
@ac All
@rc Random
@fc Farthest
Passive (Animals, Villagers, etc)
@np Nearest
@ap All
@rp Random
@fp Farthest
Hostile (Skeletons, Zombies, Etc)
@nh Nearest
@ah All
@rh Random
@fh Farthest
EntityNames (Specify an Entity name, or comma delimited list of entity names. Eg. 'Cow,Sheep,Chicken')
@n'EntityNames' Nearest
@A'EntityNames' All
@r'EntityNames' Random
@f'EntityNames' Farthest
/equip (target) (item | north | south | west | east | up | down)
If the item is equipment, it attempts to equip it on the target in its logical spot, causing whatever is equipped in that slot to go into inventory if it has one and dropped if it doesn't or doesn't have a free spot.
Extra Info: If a direction is chosen, it will choose the first valid item from adjacent container on that side and apply it to the target without consuming it.
/apply (target) (item | north | south | west | east | up | down)
If the item is a consumable item (food, potion, not thrown item), it applies the effects of it instantly to the targets.
Extra Info: If a direction is chosen, it will choose the first valid item from adjacent container on that side and apply it to the target without consuming it.
/give (target) (item | north | south | west | east | up | down)
Gives an item to the target. If the target is a NPC, it will attempt to put it in its hand
Extra Info: If a direction is chosen, it will choose the first valid item from adjacent container on that side and apply it to the target without consuming it.
/spawner state (on | 1 | off | 0 | toggle) (north | south | west | east | up | down)
Will set the state of a spawner, preventing it from acting normally. If a direction is not specified, targets all adjacent spawners (if command block), or the targeted spawner (if player).
/spawner set (entityID) (north | south | west | east | up | down)
Overwrites the entity of a spawner. If a direction is not specified, targets all adjacent spawners (if command block), or the targeted spawner (if player).
/spawner trigger (north | south | west | east | up | down)
Triggers a spawner to prematurely spawn. If a direction is not specified, targets all adjacent spawners (if command block), or the targeted spawner (if player).
Someone else posted the original version these on http://www.minecraftforum.net/topic/1487156-new-command-block-commands-list/#entry18116528 I modified them slightly.
/spawn (entityID) (x) (y) (z) (number to spawn)
Spawns an entity. Spawns 1 if a number is not specified.
/block place (block ID) (x) (y) (z)
Places a block at the specified coordinates with a block matching the block ID.
/block set (block ID) (x) (y) (z)
Replaces a block at the specified coordinates with a block matching the block ID. Can be used to remove a block by setting 0 as the block ID.
Note on above, would be nice to be able to do a set of coordinates. Perhaps using {[x,y,z],[x,y,z]} format in order to target multiple locations.