If you have been active in the commands forum, you would see that i posted a similar post but it's regarding Area Effect Cloud but now I've mastered it. Now I am trying to learn the /stats command. I've searched YouTube, they've teached me but I still don't understand the /stats command. Any links or explanation? Thank you very much
/stats is essentially a way to store data gained from commands and then put them in scoreboards. A simple example would be using this to get nearby diamond ores by continuously replacing them with another block and revert them back, then use /stats to check the amount of blocks affected, posting to a scoreboard.
/stats is essentially a way to store data gained from commands and then put them in scoreboards. A simple example would be using this to get nearby diamond ores by continuously replacing them with another block and revert them back, then use /stats to check the amount of blocks affected, posting to a scoreboard.
I heard that using /stats you can create new gamerules. I don't understand the part where you said,"Nearby diamond ores by continuously replacing them with another block and revert them back" and the statement,"check the amount of blocks affected, posting to a scoreboard" The parts whereby is bold and underlined are words that I am mainly confused about.
I wrote a very old and outdated tutorial for creating gamerules using /stats. Most of the stuff there is still accurate, main difference is now we have repeating command chains and scoreboard tags.
Basically, the idea is that when you type this command into chat it returns that gamerules value:
/gamerule mobGriefing
This will either say "mobGriefing = true" or "mobGriefing = false". Custom game rules do not have either true or false, but are integers instead. So if we want it to be true or false, we would use 0 for false and anything else for true. But you can also use them as actual numbers, like a gamerule to use as a timers delay, for example:
You need to setup a dummy scoreboard objective that will hold the QueryResult value of the gamerule from the /stats command:
/scoreboard objectives add killTimer dummy
We will also need to know when a player dies:
/scoreboard objectives add dead deathCount
Now start an always active repeating command chain:
The /stats command only works when the command is executed with the /execute command. We are only targetting players with a max score of 0, so that we only set this scoreboard one time when the player spawns.
/kill @a[score_killTimer_min=1,score_killTimer=1]
Kill the player when their timer runs out (makes more sense when you read the next command.) We have to do this when it reaches 1 instead of 0, because of the previous command.
Now if you type "/gamerule killTimer 6001" then every player will be killed after exactly 5 minutes each time they spawn or respawn.
When we do the execute stats command, it is assigning the value of the gamerule to that players scoreboard objective, making killTimer == 6001. Each tick it decreases by 1, until hitting 1, then kills them. When they die we remove them from the killTimer scoreboard so that none of the following commands act on the player until they respawn.
If you have been active in the commands forum, you would see that i posted a similar post but it's regarding Area Effect Cloud but now I've mastered it. Now I am trying to learn the /stats command. I've searched YouTube, they've teached me but I still don't understand the /stats command. Any links or explanation? Thank you very much
Wiki link: http://minecraft.gamepedia.com/Commands#stats
/stats is essentially a way to store data gained from commands and then put them in scoreboards. A simple example would be using this to get nearby diamond ores by continuously replacing them with another block and revert them back, then use /stats to check the amount of blocks affected, posting to a scoreboard.
I heard that using /stats you can create new gamerules. I don't understand the part where you said,"Nearby diamond ores by continuously replacing them with another block and revert them back" and the statement,"check the amount of blocks affected, posting to a scoreboard" The parts whereby is bold and underlined are words that I am mainly confused about.
The block affected is the count of how many blocks the command changed
Checking for nearby diamond ores:
/execute @p ~ ~ ~ /fill ~-5 ~-5 ~-5 ~5 ~5 ~5 diamond_block 1 replace diamond_ore
/execute @p ~ ~ ~ /fill ~-5 ~-5 ~-5 ~5 ~5 ~5 diamond_ore 0 replace diamond_block 1
/stats entity @p set AffectedBlocks A B
where A is a player and B is an objective you have created
P/S: Forgot about this:http://minecraft.gamepedia.com/Tutorials/Command_stats
I wrote a very old and outdated tutorial for creating gamerules using /stats. Most of the stuff there is still accurate, main difference is now we have repeating command chains and scoreboard tags.
Basically, the idea is that when you type this command into chat it returns that gamerules value:
/gamerule mobGriefing
This will either say "mobGriefing = true" or "mobGriefing = false". Custom game rules do not have either true or false, but are integers instead. So if we want it to be true or false, we would use 0 for false and anything else for true. But you can also use them as actual numbers, like a gamerule to use as a timers delay, for example:
You need to setup a dummy scoreboard objective that will hold the QueryResult value of the gamerule from the /stats command:
/scoreboard objectives add killTimer dummy
We will also need to know when a player dies:
/scoreboard objectives add dead deathCount
Now start an always active repeating command chain:
/scoreboard players reset @a[score_dead_min=1] killTimer
/scoreboard players set @a dead 0
Only entities tracked on the scoreboard will be able to be assigned a value from /stats.
/scoreboard players add @e[type=Player,score_dead_min=0] killTimer 0
This command allows only living players to be on the scoreboard for the killTimer objective.
/stats entity @a set QueryResult @a[c=1] killTimer
This sets all players up for the next command to assign them the result of the command they execute.
/execute @a[score_killTimer=0] ~ ~ ~ gamerule killTimer
The /stats command only works when the command is executed with the /execute command. We are only targetting players with a max score of 0, so that we only set this scoreboard one time when the player spawns.
/kill @a[score_killTimer_min=1,score_killTimer=1]
Kill the player when their timer runs out (makes more sense when you read the next command.) We have to do this when it reaches 1 instead of 0, because of the previous command.
/scoreboard players remove @a[score_killTimer_min=1] killTimer 1
Now if you type "/gamerule killTimer 6001" then every player will be killed after exactly 5 minutes each time they spawn or respawn.
When we do the execute stats command, it is assigning the value of the gamerule to that players scoreboard objective, making killTimer == 6001. Each tick it decreases by 1, until hitting 1, then kills them. When they die we remove them from the killTimer scoreboard so that none of the following commands act on the player until they respawn.