How to test for time of day with command block in Minecraft

How to test for time of day with command block in Minecraft -

I'm trying to setup something similar to the MindCrack team's current server set up for my single player world so that the world border expands slowly as I play the game. I already know how to work the worldborder command, I just want it to happen at the exact same time every game day.

I know that you can query for the time with time query daytime which gives you the time of the day in ticks. I would set up a comparator to test the output. I just can't seem to get the testfor command to work with this. I figure I'm doing something wrong. I would guess the code would be something like this testfor [time query daytime = 1000] but of course that was wrong.

Anyone know if what I want to do is even possible?



Best Answer

The following steps apply to the 1.13.1 version of Minecraft:

  1. Create a dummy scoreboard. Type the following command into chat;

    /scoreboard objectives add timeOfDay dummy "Time of Day (in ticks)"

  2. Show the scoreboard for testing. Use the command below;

    /scoreboard objectives setdisplay sidebar timeOfDay

  3. Summon an Armor Stand and name it "timeOfDay". You could use this command;

    /summon armor_stand ~ ~1 ~ {NoGravity:1,CustomName:"{\"text\":\"timeOfDayArmorStand\"}",CustomNameVisible:1b}

  4. Set the value of the time of day (in ticks) as the timeOfDay scoreboard value for the timeOfDayArmorStand. Paste the command in an active repeating command block;

    /execute store result score @e[type=armor_stand,name=timeOfDayArmorStand] timeOfDay run time query daytime

    To remove the timeOfDay scoreboard in the right side of the screen, type this;

    /scoreboard objectives setdisplay sidebar




Pictures about "How to test for time of day with command block in Minecraft"

How to test for time of day with command block in Minecraft -
How to test for time of day with command block in Minecraft - Free stock photo of analyzing, background, blood
How to test for time of day with command block in Minecraft - Free stock photo of analyzing, background, blood



Quick Answer about "How to test for time of day with command block in Minecraft"

  • Create a dummy scoreboard. Type the following command into chat; ...
  • Show the scoreboard for testing. ...
  • Summon an Armor Stand and name it "timeOfDay". ...
  • Set the value of the time of day (in ticks) as the timeOfDay scoreboard value for the timeOfDayArmorStand.


  • How do you check time of day in Minecraft?

    You can quickly and easily find out various time values in Minecraft using the /time command. This command lets you find out the number of days elapsed, the number of game ticks since dawn or the age of the Minecraft world.



    ✔️ Minecraft: How To Change The Time of Day Using Command Blocks - (Command Block School Tutorial)




    More answers regarding how to test for time of day with command block in Minecraft

    Answer 2

    Ok I figured it out for what I was doing it was easy I just put a comparator up next to a command block with this command in it:

    /time query daytime

    Then I had two pieces of redstone going from that comparator to a block with a torch on it going to a command block.

    Answer 3

    If you are still interested in this, a way you can get around the bug where the time doesn't reset to zero, is test for if the time query is 24000, like with:

    /scoreboard players test timeFakePlayer time 23990 24000
    

    Then have the comparator set the time to 0 with /time set 0 since that time of day is equal to zero

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Geometric Photography, Geometric Photography, Artem Podrez, Artem Podrez