How do you prevent a player from leaving the bed once he gets in it in Minecraft?
I'm wondering if it's possible to prevent a player from leaving the bed once he gets in it. I want to count how many times a player slept in a bed in a Minecraft map. I made a scoreboard with it:
/scoreboard objectives add sleepingInBed stat.sleepInBed
The problem is that a player can quit the bed when the night isn't over. The score goes up every time the player tries to sleep in it. Is there a solution for this?
Best Answer
To automatically set the time to day when a player sleeps, you could use a comparator that activates a command block only when it shuts off. Comparators can be used to detect most block updates, but a BUD or observer may also do the trick (although only sending a pulse) if you are using a sticky piston.
Pictures about "How do you prevent a player from leaving the bed once he gets in it in Minecraft?"



How do you make it so only one person sleeps in Minecraft?
Enter the command /gamerule playersSleepingPercentage <value> (ensuring to keep the upper case letters). You may set a percentage value between 0 - 100 (Default: 100). For instance, setting this value to 50 will mean that half of your players will need to sleep in order to skip the night.What is the Gamerule for sleep?
Minecraft Interactive Experience A bed is a block that allows a player to sleep and to reset their spawn point to within a few blocks of the bed in the Overworld. If the bed is obstructed or removed, the player spawns at the default world spawning location.Why bed is occupied in Minecraft?
In Multiplayer, all Players must sleep at once to skip to dawn. In The Nether and The End, if the Player attempts to sleep, the Bed will explode. After a successful sleep, the Player's spawn point will be set to the location of the bed.Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Ivan Samkov, Charlotte May, Karolina Grabowska, Karolina Grabowska
