-1

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

1
  • 1
    Can you specify the desired exact result of your device? How do you define game time? Numbers of ticks that have passed since the start? Sending a screenshot without elaboration doesn't do anything.
    – hfanatic
    Dec 26, 2021 at 13:16

1 Answer 1

2

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.

2
  • Thank you if I wanted to lets say change something like a /fill command at a certain time of the day using this command would there be any way of doing that? Dec 27, 2021 at 2:31
  • 1
    Yes. execute if scoreboard $time time matches <range> run <command> . range works like x..y (inclusive) or just x
    – BunnyMerz
    Dec 27, 2021 at 6:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .