watch 28:07
Minecraft Interactive Experience
Do you like this video?
Play Sound
This feature is exclusive to Bedrock Edition.
This page describes content that exists only in outdated versions of Java Edition.
This feature used to be in the game but has since been removed.
testfor
Permission level required |
|
---|---|
Restrictions |
Cheat only |
Counts entities (players, mobs, items, etc.) matching specified conditions.
Contents
Syntax[]
testfor <victim: target>
Arguments[]
<victim: target>
: CommandSelector<Actor>
- Specifies the entities to test.
- Must be a player name or a target selector.
Result[]
Command | Trigger | Bedrock Edition |
---|---|---|
any | the arguments are not specified correctly | Failed |
<targets> or player: target is not specified, and the command's executor is not a player | ||
<victim: target fails to resolve to one or more entities (named players must be online) | ||
On success | Shows detected entities. |
Output[]
Command | Edition | Situation | Success Count |
---|---|---|---|
any | Bedrock Edition | On fail | 0 |
On success | the number of the specified entities. |
Examples[]
- To test if Alice is online:
testfor Alice
- To count the number of players in survival mode within a 3-block radius of (0,64,0):
testfor @a[x=0,y=64,z=0,r=3,m=0]
- To count the number of zombies within a 20-block radius of (0,64,0):
testfor @e[x=0,y=64,z=0,r=20,type=zombie]
History[]
Java Edition | |||||
---|---|---|---|---|---|
1.5 | 13w03a | Added /testfor . | |||
1.8 | 14w02a | Added dataTag argument to /testfor .
| |||
/testfor is no longer exclusive to command blocks. | |||||
14w07a | /testfor can now test for partial NBT tag matches. | ||||
1.13 | 17w45a | Removed /testfor . | |||
Pocket Edition | |||||
1.0.5 | alpha 1.0.5.0 | Added /testfor . |