
Command reference
Target Selectors
A target selector picks the players or entities a command acts on. It starts with @ and a letter and can be narrowed down with filters in square brackets.
| Selectors | @p, @a, @r, @s, @e, @n |
| Selector arguments | 21 |
| Filter syntax | @e[name=value,name=value]. Spaces around = and , are allowed. All filters must match. |
| Negation | Put ! before the value, for example type=!minecraft:player. Works for name, gamemode, team, type, tag, nbt and predicate. |
| Ranges | 5 (exactly), 3.. (at least), ..10 (at most), 3..10 (between). The smaller number comes first. |
| Other targets | A player name (up to 16 characters) or an entity UUID can be typed instead of a selector. |
| Removed entities | @e and @n skip entities that have died or been removed. Every other entity counts, including items, arrows and minecarts. |
| Search area | Normally every dimension is searched. Using distance, x, y, z, dx, dy or dz limits the search to the dimension the command runs in. |
| One target only | Commands that take a single target refuse a selector that could return more. Add limit=1 to @a or @e to use it there. |
| Players only | Commands that take players refuse @e and @n unless the selector is limited to players, for example with type=minecraft:player. |
| Permission | Selectors need permission to use. Without it the game answers "Selector not allowed". |
| @p | The nearest player | Nearest first | 1 | /tp @p 0 64 0 |
| @a | All players | No fixed order | None | /gamemode creative @a |
| @r | A random player | Random | 1 | /give @r minecraft:diamond 1 |
| @s | The entity running the command | Not used | 1 | /tp @s ~ ~10 ~ |
| @e | All entities that are alive | No fixed order | None | /kill @e[type=minecraft:arrow] |
| @n | The nearest entity that is alive | Nearest first | 1 | /damage @n[type=minecraft:pig] 2 |
| name | Entities with this name | Text, in quotes if it has spaces. Once, or several times with ! | /effect give @a[name=!Steve,name=!Alex] minecraft:speed 30 |
| distance | Distance from the command position in blocks | Number or range, not negative. Once | /kill @e[type=minecraft:zombie,distance=..10] |
| level | Players by experience level | Whole number or range, not negative. Once. Players only | /xp add @a[level=30..] 1 levels |
| x | Moves the point distance and the box are measured from | Number. Once | /kill @e[x=0,y=64,z=0,distance=..5] |
| y | Moves the point distance and the box are measured from | Number. Once | /kill @e[x=0,y=64,z=0,distance=..5] |
| z | Moves the point distance and the box are measured from | Number. Once | /kill @e[x=0,y=64,z=0,distance=..5] |
| dx | Entities touching a box that reaches this far along x | Number, may be negative. Once. dy and dz count as 0 if left out | /kill @e[x=0,y=64,z=0,dx=10,dy=5,dz=10] |
| dy | Entities touching a box that reaches this far along y | Number, may be negative. Once | /kill @e[x=0,y=64,z=0,dx=10,dy=5,dz=10] |
| dz | Entities touching a box that reaches this far along z | Number, may be negative. Once | /kill @e[x=0,y=64,z=0,dx=10,dy=5,dz=10] |
| x_rotation | Up and down view angle (pitch) | Number or range in degrees. Once | /tp @a[x_rotation=-90..-45] ~ ~1 ~ |
| y_rotation | Left and right view angle (yaw) | Number or range in degrees. Once | /tp @a[y_rotation=-45..45] ~ ~1 ~ |
| limit | Keeps only the first so many results | Whole number, at least 1. Once. Not on @s | /kill @e[type=minecraft:item,limit=5] |
| sort | Order of the results before limit is applied | nearest, furthest, random or arbitrary. Once. Not on @s | /kill @e[type=minecraft:cow,sort=furthest,limit=2] |
| gamemode | Players by game mode | survival, creative, adventure or spectator. Once, or several times with !. Players only | /gamemode survival @a[gamemode=!survival,gamemode=!adventure] |
| team | Entities on this team | Team name. Empty means no team, ! alone means any team. Once, or several times with ! | /tellraw @a[team=!red,team=!blue] "x" |
| type | Entities of this type or type tag | Entity id, or a tag with #. Once, or several times with ! or with tags | /kill @e[type=!minecraft:player,type=!minecraft:villager] |
| tag | Entities that carry this tag | Tag name. Empty means no tags, ! alone means any tag. May repeat | /kill @e[tag=marked,tag=!safe] |
| nbt | Entities whose data contains these values | Data in { }. May repeat, ! allowed | /kill @e[type=minecraft:zombie,nbt={NoAI:1b}] |
| scores | Entities by scoreboard score | {objective=range,...}. Every listed score must be set and match. Once | /tellraw @a[scores={kills=10..,deaths=..3}] "x" |
| advancements | Players by advancement progress | {id=true or false}, or {id={criterion=true}}. Once. Players only | /tellraw @a[advancements={minecraft:story/mine_stone=true}] "x" |
| predicate | Entities that pass a data pack predicate | Predicate id. May repeat, ! allowed | /kill @e[predicate=my_pack:is_wet] |
| name, gamemode, team, type | One plain value, or any number of ! values. A plain value cannot follow a ! value |
| type with a tag | Several tags may be listed, each one once, as long as no plain type was given |
| tag, nbt, predicate | May be used any number of times, with or without ! |
| distance, level, x, y, z, dx, dy, dz, x_rotation, y_rotation, limit, sort, scores, advancements | Only once per selector |
| limit, sort | Cannot be used on @s |
| Player name | The online player with that name | /kill Steve |
| UUID | The entity with that unique id | /kill dd12be42-52a9-4a91-a8a1-11c01849e498 |
/kill @e[type=minecraft:zombie,distance=..10]Kills every zombie within 10 blocks.
/give @a[gamemode=survival,distance=..20] minecraft:bread 3Gives 3 bread to every survival player within 20 blocks.
/tp @e[type=minecraft:villager,sort=nearest,limit=3] @sTeleports the three nearest villagers to you.
/kill @e[type=minecraft:item,nbt={Item:{id:"minecraft:diamond"}}]Removes dropped diamonds.
/tellraw @a[scores={kills=10..},team=!red] {text:"Well done",color:"green"}Sends a message to players with at least 10 kills who are not on team red.
/kill @e[type=#minecraft:skeletons]Kills every entity in the skeletons type tag.
/execute as @a at @s run tp @s ~ ~1 ~Moves every player up one block from where they stand.

