Target selectors let a command pick who it affects: @p is the nearest player, @a is every player, @r is a random player, @s is whoever runs the command, @e is every entity, and @n (Java only) is the nearest entity. Add filters in square brackets, such as @e[type=zombie,distance=..10].
Intermediate Java Bedrock
The selectors
| Selector | Picks |
|---|---|
@s | The entity running the command (you in chat, the target in an execute command) |
@p | The nearest player |
@a | All players |
@r | A random player |
@e | All entities: players, mobs, dropped items, armor stands and more |
@n | The nearest entity (Java only) |
Filters for Java and Bedrock
Filters go in square brackets and are separated by commas. Put an exclamation mark before a value to say not, as in type=!player.
| What to filter | Java | Bedrock |
|---|---|---|
| Entity type | type=zombie | type=zombie |
| Distance | distance=..10 | r=10 (max) and rm=2 (min) |
| How many | limit=1 | c=1 (negative picks the farthest) |
| Sort order | sort=nearest, furthest, random | Use c together with the selector |
| Name | name=Steve | name=Steve |
| Tag | tag=boss | tag=boss |
| Game mode | gamemode=survival | m=survival |
| Experience level | level=5.. | l=5 (max) and lm=1 (min) |
| Score | scores={kills=5..} | scores={kills=5..} |
| Box area | x= y= z= dx= dy= dz= | x= y= z= dx= dy= dz= |
| NBT data | nbt={...} | Not available |
A range uses two dots. In Java, 5.. means 5 or more, ..5 means 5 or less and 1..5 means 1 to 5. Bedrock scores use the same range style.
Examples
Kill the nearest zombie to you
Java: /kill @e[type=zombie,limit=1,sort=nearest]
Bedrock: /kill @e[type=zombie,c=1]Give an effect to every player within 20 blocks
Java: /effect give @a[distance=..20] regeneration 10
Bedrock: /effect @a[r=20] regeneration 10Teleport everyone except yourself to you
Java: /tp @a[distance=1..] @s
Bedrock: /tp @a[rm=1] @sRemove all dropped items
/kill @e[type=item]Common mistakes
- Using @e with no type. It matches every entity, so /kill @e kills items, mobs and armor stands, and in some cases players. Always add a type.
- Using @s in a command block. A command block is not a player. Use @p, a tag, or execute as.
- Mixing editions. distance and limit are Java. r and c are Bedrock.
- Forgetting a comma between filters. They need commas but no spaces.
FAQ
What does @e mean in Minecraft?
@e selects every entity: players, mobs, dropped items, armor stands and more. Add type=zombie or another filter to narrow it.
What is the difference between @p and @s?
@p is the nearest player to where the command runs. @s is the entity that is running the command.
How do I select only mobs and not players?
Use @e[type=!player]. Be careful, because that still includes items and armor stands.
What is @n in Minecraft?
@n selects the nearest entity of any kind. It exists in Java Edition only.
Why does my selector filter not work on Bedrock?
Bedrock uses different parameters from Java: r and rm for distance, c for the number of targets, m for game mode and l and lm for levels.
Checked by the Game Respawned editorial team against the current Java and Bedrock versions. Spotted something out of date? Tell us.