Skip to content

Instantly share code, notes, and snippets.

@clamytoe
Last active February 20, 2022 16:39
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clamytoe/02c363f7d54f14be573cf005e633fa28 to your computer and use it in GitHub Desktop.
Save clamytoe/02c363f7d54f14be573cf005e633fa28 to your computer and use it in GitHub Desktop.
Minecraft - One Person Sleep

Minecraft - One Person Sleep

It's always frustrating getting everyone on the server to go to sleep to prevent mobs from spawning and having to carry a "travel bed" takes up precious space when out gathering resources. With this setup only one person needs to sleep in order for the night cycle to be skipped.

Based on this video: Super Simple VANILLA MINECRAFT ONE PLAYER SLEEPING|1.13-1.14+

setup

Initial Setup

The command blocks will spam your server with constant message, so the first thing to do is to disable their output:

/gamerule commandBlockOutput false

Next we will use the scoreboard command to create a new custom objective called sleeping:

/scoreboard objectives add sleeping minecraft.custom:minecraft.sleep_in_bed

Items Needed

  • 1 Daylight Sensor
  • 1 Redstone Repeater
  • 1 Redstone Comparator
  • 3 Command Blocks

LAYOUT

Setup the items in this patter:

[DLS] =4=> [CB-I]
[CB-2] <=C= [CB-1]
L

DESCRIPTION

Item Description
DLS Daylight sensor
=4=> Repeater facing right at 4 ticks
CB-I Command block set to impulse, requires redstone signal
CB-# Command block set to repeat, requires redstone signal
<=C= Comparator facing left
L Level on top of command block, turned on

Detection

The following commands are all going to go into the command blocks that are set to repeat.

CB-1:

This command will detect when the player goes to sleep and will clear the weather:

/execute as @a[scores={sleeping=1}] run weather clear
CB-2:

This command will increase the time by 100 each game tick:

/time add 100t

RESET

Add this code to the command block set to impulse to reset the sleeping objective and have it ready for the next time:

CB-I:
/scoreboard players set @a sleeping 0
@bigboy-baby
Copy link

Cool but this is a real gamerule now

@IoIxD
Copy link

IoIxD commented Jul 30, 2021

Not in 1.16, and our server is planning on skipping to 1.18 because it's not worth it and one of our plugins is also doing so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment