Updated:
1. Count play time
/scoreboard objectives add playtime minecraft.custom:minecraft.play_time "Play time"
It goes up on its own: 20 per second, 1200 per minute and 72000 per hour. In 1.16 and older it was named minecraft.play_one_minute, though it still counted ticks. It only counts from when the objective is created.
2. Setup for hours and minutes (once)
/scoreboard objectives add hours dummy "Hours played"
/scoreboard objectives add mins dummy
/scoreboard objectives add const dummy
/scoreboard players set #72000 const 72000
/scoreboard players set #1200 const 1200
/scoreboard players set #60 const 60
3. Calculate (repeating)
/execute as @a run scoreboard players operation @s hours = @s playtime
/execute as @a run scoreboard players operation @s hours /= #72000 const
/execute as @a run scoreboard players operation @s mins = @s playtime
/execute as @a run scoreboard players operation @s mins /= #1200 const
/execute as @a run scoreboard players operation @s mins %= #60 const
%= keeps the remainder, so mins holds the minutes left over after full hours. Division rounds down.
4. Let players check their own time
/scoreboard objectives add check trigger
/scoreboard players enable @a check
/execute as @a[scores={check=1..}] run tellraw @s [{"text":"Play time: "},{"score":{"name":"@s","objective":"hours"}},{"text":" h "},{"score":{"name":"@s","objective":"mins"}},{"text":" min"}]
/scoreboard players set @a[scores={check=1..}] check 0
/scoreboard players enable @a check
Players run /trigger check. See trigger command.
5. Rewards (repeating)
/give @a[scores={hours=1..},tag=!play1h] diamond 3
/tag @a[scores={hours=1..},tag=!play1h] add play1h
6. Distance, jumps and deaths
/scoreboard objectives add walk minecraft.custom:minecraft.walk_one_cm
/scoreboard objectives add jumps minecraft.custom:minecraft.jump "Jumps"
/scoreboard objectives add deaths deathCount "Deaths"
/scoreboard objectives add alive minecraft.custom:minecraft.time_since_death
walk_one_cm counts centimeters, so divide by 100 for blocks. time_since_death resets to 0 on death.
Troubleshooting
- Minutes stay at 0: set #1200 and #60 in step 2.
- /trigger fails: run the enable command.
- Bedrock Edition: only dummy objectives exist there.
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.