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?


Adjust blocks around the bed in such a way that the player will wake up on 1 particular block every time.

Circuit A :

Now add pressure plate (preferably stone) on that block.

Circuit B:

Now use daylight sensor somewhere outside add repeater to extend the signal.

Circuit Main:

Use "And" gate with input from A and B and output of the and gate will be linked to your counting command-block.

  • I could be wrong but I don't this this could be a solution to the problem OP has presented, I believe the OP runs a server and building a redstone circuit above every users bed could be impossible. I think he wants to be able to programmatically or otherwise restrict the user from exiting the bed. – Christopher Allen Aug 20 '16 at 21:59
  • He hasn't mentioned it. He might be making a map. – Fennekin Aug 21 '16 at 10:46
  • I'm making a map. Sorry that I didn't mention it – AutoDemolisher Aug 30 '16 at 20:54

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.

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.