A Minecraft Data Pack library that lets you get the real life date & time ingame. For inquiries, please contact @silicatYT on Discord.
TimeLib automatically keeps track of the date & time for you. For that to work, you first need to configure the settings to your personal taste. To access the settings, click the message that appears in chat after reloading or manually running /function timelib:util/settings
.
Command Block Offset
(value): This setting specifies the time difference between the UTC timezone and your system time. Example: If your system clock is 1 hour behind compared to the UTC timezone, the setting's value would have to be set to -1.Timezone Offset
(value): This setting specifies the time difference between your system time and your desired timezone. Example: If your desired timezone is 2 hours ahead of your system clock, the setting's value would have to be set to 2.Realtime Tracking
[Singleplayer | Multiplayer]: This setting controls whether TimeLib should work in Singleplayer or not. If your world can be played in both Singleplayer and Multiplayer, it is advised to select the former option.
Singleplayer
is selected, the time will stay in sync even after pausing & unpausing. This comes at a small performance cost.Multiplayer
is selected, these checks will not be performed. This results in slightly better performance.Daylight Savings Time Checks
[Off | Hourly]: This setting controls whether TimeLib automatically detects and adjusts for time shifts caused by daylight savings time.
Off
is selected, daylight savings time will only be checked for every time the function timelib:util/update
is run, either manually or by other functions in the Data Pack (e.g. on reload or when changing settings).Hourly
is selected, daylight savings time will be checked for every hour. This comes at a very small performance cost. The correct time will be displayed 2 ingame ticks after the hour changes.The values for Year, Month, Day, Week Day, Hour, Minute, Second & the Unix Timestamp are all stored inside the player TimeLib
, with each value having its own scoreboard objective:
TimeLib.Year, TimeLib.Month, TimeLib.Day, TimeLib.WeekDay, TimeLib.Hour, TimeLib.Minute, TimeLib.Second & TimeLib.UnixTime
Additionally, string versions of the Day, WeekDay and Month are stored in the timelib:date
storage.
Every time the date changes (or TimeLib updates the time), the function tag #timelib:time_updated
is executed.
Note: Any output is automatically adjusted for the timezone specified in the first two settings.
TimeLib
of the player #TimeLib.Input
as the input./function timelib:util/get_date
.#TimeLib.Output
's TimeLib.XXX
scores, as well as the timelib:output
data storage.TimeLib combines the with Base64 encoded Unix Timestamp found within player heads with the daytime found within command block outputs to get the current date & time. To achieve tick accuracy, TimeLib checks a repeating command block's time output every tick to see when it changes. At that point it uses several calculations & the macros introduced in 1.20.2 to schedule functions to run when the next second, minute, hour and day passes. This means that once time is synced, almost no further commands are needed.
Further logic and calculations are necessary to support edge cases such as daylight savings time, Singleplayer support, what should happen if the Unix Timestamp from the player head is from a different day etc. We hope that with this library, nobody will have to deal with these troubles anymore.
From CMDred:
/tick
is NOT supported. Time desyncs with /tick rate
or /tick sprint
, and the Daylight Savings Time Checks
setting breaks entirely. Time always has to be manually updated after using this command./function timelib:util/update
, when changing settings or when the world is reloaded/restarted), the new time will only display 2 ticks after.29999983 29999983
, there may be collision.As per the MIT License, you are allowed to redistribute, modify and use TimeLib as long as we are credited for the original work.
Copyright © 2024 Smithed
Not an official Minecraft product. Not approved by or associated with Mojang Studios