![]() |
VOOZH | about |
/testfor| Permission level required |
|
|---|---|
| Restrictions | Cheat only |
{
"title": "<code>/testfor</code>",
"rows": [
{
"field": "\n* 2 <sup class=\" nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Java Edition\">(link to Java Edition article, displayed as JE) only</span></i>]</sup>\n* 1 <sup class=\" nowrap Inline-Template \" title=\"\">[<i><span title=\"This statement only applies to Bedrock Edition\">(link to Bedrock Edition article, displayed as BE) only</span></i>]</sup>",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "(link to Cheat article, displayed as Cheat) only<br>",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Counts entities (players, mobs, items, etc.) matching specified conditions.
testfor <victim: target>victim: target: CommandSelector<Actor>
| Command | Trigger | Bedrock Edition |
|---|---|---|
| Any | The command is incomplete, or any argument is not specified correctly. | Unparseable |
victim: target fails to resolve to one or more entities (named players must be online). | Failed | |
| Otherwise | Successful |
| Command | Edition | Situation | Success Count |
|---|---|---|---|
| Any | Bedrock Edition | On fail | 0 |
| On success | the number of the specified entities. |
testfor Alicetestfor @a[x=0,y=64,z=0,r=3,m=0]testfor @e[x=0,y=64,z=0,r=20,type=zombie]testfor @r[hasitem={item=iron_ingot}]testfor @r[hasitem={item=iron_ingot},quantity=0]testfor @r[hasitem={item=iron_ingot},location=slots.weapon.mainhand]| 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. | |||||
/testfor Command" – Microsoft Learn, October 11, 2023.