Data Packs Server Utility

No Offline Day Cycle!

  • 1.4k views 1 today
  • save_alt 92 downloads
Compatibility
Minecraft 1.18
to version
Minecraft 1.21
Changes include
  • Functions
  • 4
  • 4
  • 1
ShinyN_
Lvl 20Expert Nerd
2


This simple and lightweight datapack stops the Day/Night Cycle, as well as the Weather Cycle when an online server is empty, as in there being no players online on the server.

The reason you would want this is so that the Day Count of the server does not progress while the server’s players are absent, meanwhile the server itself can stay online 24/7. This datapack in essence freezes the progression of the server when it is empty.

The datapack has as minimal an amount of bloat as possible in order not to disturb your experience when actually playing the game together with your friends! This means that the datapack sends no messages to chat or anything else of the like, and instead simply chugs along in the background while you play Minecraft.



In-depth explaination of how the datapack works:
Every tick, the datapack runs a command to check if there are any players online, using the “/execute” command. Simultaneously, the datapack also runs a similar command to see if there aren’t any players online. Since neither command can return the same value at one time, as there will always either be players online, or there won’t be, the datapack uses whichever command returns a value of “true” and then sets the “doDaylightCycle” and “doWeatherCycle” gamerules to either “true” or “false”, depending on which of the checks return “true”.

Full commands below:
execute if entity @a run gamerule doDaylightCycle true”,
execute if entity @a run gamerule doWeatherCycle true”,
execute unless entity @a run gamerule doDaylightCycle false”,
execute unless entity @a run gamerule doWeatherCycle false

These four commands running every gametick are the only commands necessary to make the datapack work in its entirety — it is a very lightweight datapack after all.


About compatility with “AFK Checker” datapacks:
If you require compatibility with an “AFK datapack”, that checks if players are AFK and stops the Day/Night cycle accordingly, I redirect you to clo4’s datapack “Pause Day Cycle” on Modrinth, which has full compatibility with his own “Detect AFK Players” datapack.

This datapack has slightly different use cases than this pack, and might well be more of interest to you than this one. It does however have a tad bit more “bloat” if you want to call it that.


This Datapack is designed with 1.21 in mind, however it is likely to work for multiple older versions.


☀️


More like this

  Have something to say?

ShinyN_
07/18/2024 3:26 pm
Level 20 : Expert Nerd
If you encounter any unintended bugs or glitches in the datapack, feel free to comment about it! ☀️
2

Welcome