Updated:
Quick reference
| Selector | Selects | Typical use |
|---|---|---|
@p | The nearest player | Give an item to whoever stands at a command block |
@a | All players | Messages or effects for everyone |
@r | One random player | Draws, choosing who is "it" |
@e | All entities: mobs, items, arrows, armor stands and more | Clearing mobs or dropped items in an area |
@s | Whoever runs the command | Yourself in chat; the current target inside /execute |
@n | The nearest entity (Java 1.21+) | Acting on a single nearby mob |
@e really means everything
/kill @e removes mobs, dropped items, item frames, armor stands, minecarts and you. Always add type when you mean mobs:
/kill @e[type=minecraft:zombie]
/kill @e[type=minecraft:item]
/kill @e[type=!minecraft:player]
type=!minecraft:player means "not players", which still includes armor stands and item frames. In worlds with builds, limit the area too.
@s depends on who runs it
In chat, /effect give @s speed affects you. In a command block, the runner is the block, which is not an entity, so @s selects nobody. Use @p there, or switch the runner with execute:
/execute as @a[distance=..5] run effect give @s minecraft:speed 10 1
as makes each selected player the runner in turn, so @s is that player. See execute as vs at.
Where @p measures from
From your position in chat and from the block in a command block. execute at moves that point. In chat, the nearest player is usually you.
Common arguments (Java)
distance=..10: within 10 blockslimit=3,sort=nearest: the three nearesttag=boss: only targets with that tagname="Boss": by name; quote names with spacesscores={money=100..}: score of 100 or moreteam=red: members of team red
Combine any number of arguments with commas. Bedrock uses other names, such as r for distance and c for limit.
When nothing is selected
If you see "No entity was found", remove the arguments one at a time to find the one that filters too much.
Common questions
- @p keeps picking me. In chat you are the nearest player. Exclude yourself with
@p[name=!YourName], or select by name or tag. - Are dead players selected? On Java,
@aincludes players on the respawn screen;@p,@rand@eonly select living targets. Use@afor death handling. - Does @e include players? Yes. Add
type=!minecraft:playerto leave them out. - Does Bedrock have @n? No; use
@e[c=1].
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.