I want to create a clock that tells the player the current game time out of the 20 minutes in a day. I couldn't figure out any commands that did this, so I made a Redstone clock that activates every minute. But now I don't know how to separate the output.
If anyone could give me a command that does this, or a way to separate the output, it would help a lot. Thanks.

enter image description here


Solution 1:

If you want to know the exact ingame time and show it somewhere, the /time and /execute store are your friend.

First we create a scoreboard to store the time and set some constants. Do the following in chat.

  • /scoreboard objectives add time dummy
  • /scoreboard players set $TickToHour time 1000 (This is so we divide the result of /time query daytime to get current hour)
  • You can set more constants just like the above one for more time units (like seconds or minutes), but I will leave you to that. Here is a template: /scoreboard players set $<var name> time <amount>

Then inside command blocks, pointing in a chain, in order, we will have:

  • execute store result score $time time run time query daytime // this returns from 0 to 24000. 0 is sun rising, 6000 is sun above head, 12000 is sun setting.
  • execute store result score $hour time run time query daytime
  • scoreboard players operation $hour time /= $TickToHour time // this will devide it by 1000 returning 0->24. Basically time in hours.

Now if you want to show this value you can do in a bunch of different ways... But since you didn't specify how, I'll leave a idea/recomendation here:

/title @a actionbar {"score":{"name":"$time","objective":"time"},"color":"red"}

I don't particulary like constantly showing numbers above hotbar, but it works.