Testing for a Specific time

Help | Java 1.16

I'm trying to run a command block that will run at a certain time.

I feel like there's an easy way to do this but I cannot find out how. I'm trying to avoid a Daylight Sensor and would rather the command able to run once it hits nighttime. Is there any default time stat?

Let's say I want this to run every time night falls :

/say Hello it's now nighttime.

Posted Jan 10, 2021, 10:01 PM UTC

14
JesusRemixHope I can help. :snoo_simple_smile:•

I believe the command you are looking for is /time query daytime This will give you the current time in your world, however if you want to use it you would need to set up a scoreboard.

Ex. In two sets of command blocks

First Command Block (Impulse, Unconditional, Needs Redstone)

/scoreboard objectives add TimeObjective dummy

2nd Command Block (Chain, Unconditional, Always Active)

/scoreboard players add CurrentTime TimeObjective

​

First Command Block (Repeat, Unconditional, Always Active)

/execute store result score CurrentTime TimeObjective run time query daytime

2nd Command Block (Chain, Unconditional, Always Active)

/execute if score CurrentTime TimeObjective matches 13000 run say It's Night Time!

2
FlappersnapperOP•

Ahhhhhh thank you. I figured I could use the scoreboard and objectives, I just did not know about the /time query daytime.

1
BeNjAmInLaNdRy•

Daylight sensor would be by far the easiest, I can help with that if you want.

Other than that, you can use a predicate to check if the time is 13000 (night), or villagers sleeping (unreliable). I can't help with predicates because you need a whole datapack and a bunch of other crap, but I know they are people on the sub who can.

Hope this helps!

1
FlappersnapperOP•

It would be the easiest but I'd rather have something entirely outside of the physical game, or at least hidden and completely away from Players. A Sensor would still have to have open sky above it. Whereas I encase and hide my Command Blocks with Bedstone deep below the spawn chunk. Thank you though.

2