Minecraft Command Block – Only One Player Needs to Sleep to Skip the Night

Posted on

After hearing Xisumavoid mention in a Hermitcraft episode about having a command block set up so that only one player on the server needs to sleep (as compared to all players by default), I decided to make one myself. I didn’t look at Xisuma’s tutorial or look at his design until afterwards. I suspect this design is superior and simpler to his.

You will need:

  • 2x Command Blocks
  • 2x Redstone Dust
  • 1x Comparator
  • 1x Day/Night Sensor
  • 1x Chest
  • 3x Slab (or full block, personal preference)
  • 352x Cobblestone
  • EDIT: 496 Cobblestone

The layout is as per below:

Fill the chest with the Cobblestone (5 and a half stacks all up) РEDIT:  7 stacks + 48

And set the command blocks as follows. The first one (closest to the comparator):
command block 01

And the second one (furthest away):
command block 02

If you prefer text to copy and paste they are set as follows:

/testfor @a {Sleeping:1b}
Repeat / Unconditional / Needs Redstone
/time set 24000
Chain / Conditional / Always Active

Finally, encase this in barrier blocks if you want to prevent players from breaking it. Don’t encase in bedrock, as this would stop the daylight sensor (I think… I assume that bedrock blocks light)

This works as the comparator is testing for the signal from the daylight sensor to be weaker than the chest (this is within a few seconds of the same time that you can enter a bed). The moment it is, the first command block starts repeatedly checking to see if any players are currently in a bed. If they are, the second command block changes the time to (more or less) the same time that sleeping in a bed would).

There are two potential cons with this design:

  1. The animation of sleeping in a bed and the delay that follows is non existent. This could be solved by padding out with a timer circuit, but this is a non-issue to me and my server
  2. The weather isn’t cleared by sleeping in a bed. This could be solved by chaining a third command block to clear the weather, but this is also a non-issue to me and my server

If you are running a modded server, this functionality can also be achieved using the Morpheus Mod

EDIT: Changed cobblestone amount to keep this working during rain/snow.