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)
- EDIT: 496 Cobblestone
If you prefer text to copy and paste they are set as follows:
Repeat / Unconditional / Needs Redstone
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:
- 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
- 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.