Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/testfor: Difference between revisions

From SAS Gaming Wiki
imported>LauraFii
History: split
 
SyncBot (talk | contribs)
Remove broken links to missing pages
Line 9: Line 9:
}}
}}


Counts [[Minecraft:entities]] ([[Minecraft:players]], [[Minecraft:mobs]], [[Minecraft:items]], etc.) matching specified conditions.
Counts entities (players, mobs, items, etc.) matching specified conditions.


==Syntax==
==Syntax==
Line 69: Line 69:
{{Navbox commands}}
{{Navbox commands}}


[[Minecraft:de:Befehl/testfor]]
de:Befehl/testfor
[[Minecraft:es:Comandos/testfor]]
es:Comandos/testfor
[[Minecraft:ja:コマンド/testfor]]
ja:コマンド/testfor
[[Minecraft:pt:Comandos/testfor]]
pt:Comandos/testfor
[[Minecraft:ru:Команды консоли/testfor]]
ru:Команды консоли/testfor
[[Minecraft:zh:命令/testfor]]
zh:命令/testfor

Revision as of 15:45, 9 April 2026

Template:Exclusive Template:Outdated Template:Infobox command

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

Syntax

testfor <victim: target>

Arguments

Template:Argument

Specifies the entities to test.
Template:Arg desc

Result

Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table

Output

Template:Output table Template:Output table Template:Output table Template:Output table

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]
  • To check if a random player has iron ingots in their inventory testfor @r[hasitem={item=iron_ingot}]
  • To check if a random player does not have iron ingots in their inventory testfor @r[hasitem={item=iron_ingot},quantity=0]
  • To check if a random is holding iron ingots in their inventory testfor @r[hasitem={item=iron_ingot},location=slots.weapon.mainhand]

History

Java Edition

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

External links

Navigation

Template:Navbox commands

de:Befehl/testfor es:Comandos/testfor ja:コマンド/testfor pt:Comandos/testfor ru:Команды консоли/testfor zh:命令/testfor