16

While there is a command that you can use to set the time, the problem with it is that one would have to remember to use it when it's getting late to set it back.

I'm looking for a way to slow down the day/night cycle to add a little more danger to the game when I get caught out at night without a shelter and a bed, and also so that when I'm building I have more daylight to not have to worry about Creepers blowing crap up and more nighttime to see if I have enough lights around.

19

Using command blocks and some redstone, this can be achieved.

First of all, you need to set /gamerule doDaylightCycle to false, to stop the natural daylight cycle. From here, we are going to use command blocks (/give <username> command_block), some redstone, and the command /time add <number> to control the daylight cycle.

Here is a very simple, and pretty easy to tune setup:

A hopper clock increments the time by 1 (out of 24,000) every given interval

The command on the command block is /time add <number>, tuned however you would like (1 item in the clock with an increment of 5 results in a 28 minute day). There is no hidden redstone, and both pistons are sticky. The hoppers feed into each other, and you choose the number of items put in (more items means slower day/night cycle).

The formula for calculating the length of daytime is 140 * (items / number) minutes of daytime (double that for the length of a whole day).

You're also going to want to use the command /gamerule commandBlockOutput false if you don't want periodic chat updates saying Added 1 to time.

You're also going to want to put this in your spawn chunk if you intend for it to work no matter where you are in the world (determine your spawn chunk by breaking your bed and killing yourself).

  • Obviously, this can only be done in a cheats-enabled world. (you can enable cheats through some LAN game magic if they are disabled) – Unionhawk Sep 2 '13 at 6:55
  • Will this spam messages to chat? – Orc JMR Sep 2 '13 at 14:47
  • 2
    @OrcJMR Yes, but there's a gamerule for that, I believe. /gamerule commandBlockOutput false should do the trick. I'll test that real quick though. For science. – Unionhawk Sep 2 '13 at 16:55
  • 1
    @Memor-X The chunk you spawned in is always loaded. – Unionhawk Sep 3 '13 at 23:16
  • 2
    @Memor-X No, it has to be in the original spawn of the world. The spot you spawn at if you break your bed and die. – Unionhawk Sep 4 '13 at 0:17
5

There is no way to do this directly in Vanilla Minecraft, no. You may be able to find a mod to do this, or you can probably rig something up with Command Blocks. Specifically, if you hook up a circuit to send a redstone pulse alternately into one of two Command Blocks, with the commands

gamerule doDaylightCycle true
gamerule doDaylightCycle false

Then they will alternately turn on and off the code that advances the day/night cycle. Use some repeaters to control how long the pause is between them activating, and you should be able to control the rate pretty carefully, but this will only work as long as the chunk containing the whole setup remains loaded; wander too far away, and time will go back to normal.

4

This can also be achieved using purely command blocks (because redstone is an evil lag-machine), ideally using 1.9's new command blocks.

First, set the gamerules commandBlockOutput and doDaylightCycle to false to turn off command block spam and the natural daylight cycle. We'll also need an objective to store a timer.

/scoreboard objectives add TIMER dummy

1.9

Next, place one repeat command block and three chain command blocks in a line. Set the last two to "conditional" and put the following commands

/scoreboard players add #TIMER TIMER 1
/scoreboard players test #TIMER TIMER <X>
/time add <Y>
/scoreboard players set #TIMER TIMER 0

#TIMER is a nonexistent player (the # makes the name illegal for real players) who counts ticks for us.

Replace <X> and <Y> with appropriate numbers. Time will advance at a rate of <Y>/<X> the normal speed. Try and use low numbers, or time will "stutter" because it's only advanced every <X> ticks.


1.8

Emulating 1.9's conditional command blocks in 1.8 without using redstone is non-trivial (but doable). Hence using /scoreboard players test won't work.

We can use /execute instead, but that won't work on a non-existing player because those are not entities. We can use an invisible armorstand instead:

/summon ArmorStand ~ ~ ~ {CustomName:"#TIMER",Marker:1b,Invisible:1b}

Create a fill clock and place the following three commands:

/scoreboard players add @e[type=ArmorStand,name=#TIMER] TIMER 1
/execute @e[type=ArmorStand,name=#TIMER,score_TIMER=0] ~ ~ ~ /time add <Y>
/scoreboard players set @e[type=ArmorStand,name=#TIMER,score_TIMER_min=<X>] TIMER 0

As above, set <X> and <Y> accordingly.

  • Thank you for this, it's an excellent solution. You can put the command blocks in a chunk that you /forceload nowadays so that it always works. – Guimoute Mar 28 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.