From Minecraft Wiki
Jump to: navigation, search
This page contains information about features that have been removed in the latest development versions.
These features are present in the current version, but may be removed when the next update is released.


First introduced

1.5 (13w03a)
PE 1.0.5 (PE 1.0.5 build 1)



Counts entities (players, mobs, items, etc.) matching specified conditions.

  • Java Edition
testfor <player> [dataTag]
  • Bedrock Edition
testfor <victim: target>
player (BE: victim: target)
Specifies the targets to count. Must be a player name or a target selector (@e is permitted to target entities other than players).
dataTag (optional)[Java Edition only]
Specifies the data tags the entities must have to match successfully. Must be a compound NBT tag (for example, {XpLevel:3}).
Fails if the arguments are not specified correctly, or if player fails to resolve to one or more entities (named players must be online).
On success, produces a success count equal to the number of targets matching player, which can be measured by a redstone comparator facing away from the command block.
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]
To count the number of players currently flying: testfor @a {abilities:{flying:1b}}
To test if an arrow is in a block: testfor @e[type=arrow] {inGround:1b}

Promotional Content