Is there any way to keep my minecraft server from going through the day/night cycle when no one's online?

Is there any way to keep my minecraft server from going through the day/night cycle when no one's online? - Drone view of snowy valley among mountains covered coniferous forest and road going between mountain ridge through clouds in sunny winter day

My friends and I use the day number as part of our server rules, so we want to keep the day from changing while we're offline, but the only way I know of to do that is to stop the server from running...



Best Answer

You should be able to use command blocks to automatically detect whether players are online or not, then appropriately set the doDaylightCycle rule appropriately. Try placing the following setup in the server spawn chunks:

enter image description here

(Piston is a sticky one.)

The general idea is that the left command checks for online players a few times every second and the comparator next to it will only output a signal if there is at least one player online. Once everyone logs off, the piston retracts and turns off the day/night cycle. As soon as someone logs in again, the comparator will turn on again and toggle the day/night cycle back on.




Pictures about "Is there any way to keep my minecraft server from going through the day/night cycle when no one's online?"

Is there any way to keep my minecraft server from going through the day/night cycle when no one's online? - Snowy road and river in valley among mountains in winter
Is there any way to keep my minecraft server from going through the day/night cycle when no one's online? - View through moving car window of horizon line with dark star sky and blurred trees
Is there any way to keep my minecraft server from going through the day/night cycle when no one's online? - Sportsman riding bicycle on road in countryside



How do you stop a day night cycle on a Minecraft server?

You can lock or unlock the Day-Night cycle using the /daylock command in Minecraft. This command is a shortcut to change the dodaylightcycle game rule (as an alternative to using the /gamerule command).

Does time pass on a Minecraft server when no one is online?

Time in the sense of day/night cycle and weather passes while no one is on, however in all other senses time doesn't pass in a given chunk unless a player is online and nearby enough (although for a small set of chunks near the default spawn, "nearby enough" is anywhere in the Overworld).

How do I permanently set it to day in Minecraft?

Yes, but only in relatively new versions of Minecraft. Simply execuse "/time set 21000" to set it to night and then "/gamerule doDaylightCycle false" to prevent your world from ever transitioning to day time.



Minecraft: Auto start/stop server when players connect | SleepingServerStarter




More answers regarding is there any way to keep my minecraft server from going through the day/night cycle when no one's online?

Answer 2

As an alternative to @SpectralFlame's solution that works with a setblock/fill clock (for reduced lag), you can use the following two commands (in this order):

gamerule doDaylightCycle false
execute @p ~ ~ ~ gamerule doDaylightCycle true

The second command will fail when there is no player to execute on, meaning the result of the first command won't be immediately overridden.

Answer 3

If you are on version 1.8+ (which i suspect you are, for you have not specified any version) then the following will help:

When the last person gets off the server, they should type the command /gamerule doDaylightCycle false this will stop the sun/moon from moving.

When the first person gets back online, you can do /gamerule doDaylightCycle true to start it back up.

Otherwise, you can put command blocks with these commands in them in an admin-only spot where you people will go when the last/first person gets on/off.

Answer 4

What kind of server are you running? By default most servers will keep the sawn chunk loaded all the time.

I think this may work, but I haven't actually tested. If you are running a server that supports adding the Multiverse-Core then you can change the option keepSpawnInMemory to keep the spawn chunks loaded. I suspect, but am not certain, that if no chunks are loaded then they time would basically stop.

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: ArtHouse Studio, ArtHouse Studio, Dids, Rubenstein Rebello