![]() |
VOOZH | about |
/stats| Permission level required |
2 |
|---|---|
| Restrictions | None |
{
"title": "<code>/stats</code>",
"rows": [
{
"field": "2",
"label": "(link to Permission level article, displayed as Permission level<br>required)"
},
{
"field": "None",
"label": "(link to Commands#Restrictions article, displayed as Restrictions)"
}
],
"invimages": [],
"images": []
}
Manages the updating of scoreboard objectives with the results of other commands.
Commands can be executed by blocks (specifically, command blocks and signs) or by entities (players can execute commands directly, and other entities can be the origin of commands indirectly with the /execute command). When a command is executed, the command returns one or more "command stats": the success count, number of blocks affected, number of entities affected, number of items affected, and/or a query result (such as from /time query daytime).
The stats command allows "selectors" and "objectives" to be set (or cleared) for each of these command stats for specific blocks or entities. Selectors (for example, @e) are stored exactly as entered, and don't get evaluated immediately. When a command is later run by the block or entity, the stored selector is then used to target (other) entities and update their scoreboard objective with the value of the command stat. That value can then be displayed or operated on, just like any other scoreboard value.
The success count from a command block can also be acquired with a redstone comparator, but that is capped at a maximum value of 15, while scoreboard objectives can hold any value from -2,147,483,648 to 2,147,483,647. Success counts and query results are also usually displayed in the chat.
stats block <x> <y> <z> clear <stat>stats block <x> <y> <z> set <stat> <selector> <objective>stats entity <selector2> clear <stat>stats entity <selector2> set <stat> <selector> <objective>x y z (block mode only)
selector2 (entity mode only)
stat
AffectedBlocks — returns the number of blocks affected by a commandAffectedEntities — returns the number of entities affected by a commandAffectedItems — returns the number of items affected by a commandQueryResult — returns the result of a command querySuccessCount — returns a command's success countselector (set mode only)
objective (set mode only)
stats block 0 64 0 set QueryResult @p MyObjstats block 0 64 0 clear SuccessCountstats entity @e[type=wither_skull,c=1] set AffectedBlocks #FakePlayer NumBlocks| Java Edition | |||||||
|---|---|---|---|---|---|---|---|
| 1.8 | 14w28a | Added /stats. | |||||
| 14w29a | Added QueryResults to /stats. | ||||||
| 1.13 | 17w45a | Removed /stats. | |||||
/blockdata — can also change the selector and objectives of blocks by altering data tags directly/entitydata — can also change the selector and objectives of entities by altering data tags directly