Time System
Scope note: This page only describes behavior that is visible in the decompiled server code.
The time system is implemented as a core plugin module under com.hypixel.hytale.server.core.modules.time.
Module wiring
Section titled “Module wiring”com.hypixel.hytale.server.core.modules.time.TimeModule registers two resources on the EntityStore:
WorldTimeResource(world “game time” and day/night/moon data)TimeResource(anInstant nowupdated by tick delta)
And installs systems:
WorldTimeSystems.Init/WorldTimeSystems.TickingTimeSystemTimePacketSystem- Plus the
timecommand (TimeCommand).
WorldTimeResource (world game time)
Section titled “WorldTimeResource (world game time)”com.hypixel.hytale.server.core.modules.time.WorldTimeResource is the primary world-time model.
Stored state
Section titled “Stored state”Instant gameTimeLocalDateTime _gameTimeLocalDateTime(UTC)int currentHourdouble sunlightFactordouble scaledTimeint moonPhase- Cached packets:
UpdateTime currentTimePacketUpdateTimeSettings currentSettings/tempSettings
Day/night mapping is configurable
Section titled “Day/night mapping is configurable”The resource maps real tick delta (dt) into game time using per-world durations:
World.getDaytimeDurationSeconds()World.getNighttimeDurationSeconds()
Internally it treats a “solar day” as:
DAYTIME_PORTION_PERCENTAGE = 0.6DAYTIME_SECONDS = SECONDS_PER_DAY * 0.6NIGHTTIME_SECONDS = SECONDS_PER_DAY * 0.4
The algorithm computes how far to advance gameTime based on whether the current second-of-day is inside the daytime window (starting at SUNRISE_SECONDS = NIGHTTIME_SECONDS / 2) and applies a day-rate vs night-rate.
Pausing
Section titled “Pausing”If world.getWorldConfig().isGameTimePaused() is true:
WorldTimeResource.tick(...)returns early (no advancement)TimePacketSystemalso returns early (no periodic broadcast)
Moon phases
Section titled “Moon phases”Moon phase depends on:
world.getGameplayConfig().getWorldConfig().getTotalMoonPhases()currentDay = _gameTimeLocalDateTime.getDayOfYear()currentHour(day progress)
When the phase changes, setMoonPhase(...) invokes MoonPhaseChangeEvent through the store’s ComponentAccessor.
Packets
Section titled “Packets”WorldTimeResource produces two packet types:
UpdateTime: containsInstantDatawith seconds + nanos.UpdateTimeSettings: contains daytime/nighttime durations, total moon phases, and pause state.
sendTimePackets(PlayerRef) sends both settings and current time to a player.
TimePacketSystem (periodic broadcast)
Section titled “TimePacketSystem (periodic broadcast)”com.hypixel.hytale.server.core.modules.time.TimePacketSystem extends DelayedSystem<EntityStore> with a fixed interval:
BROADCAST_INTERVAL = 1.0f
Every interval, if time is not paused, it calls:
worldTimeResource.broadcastTimePacket(store)
TimeResource (“Now”)
Section titled “TimeResource (“Now”)”com.hypixel.hytale.server.core.modules.time.TimeResource stores:
Instant nowfloat timeDilationModifier(default1.0f)
TimeSystem.tick(dt, ...) adds dt to now as nanoseconds.
Time dilation
Section titled “Time dilation”World.setTimeDilation(float, ComponentAccessor<EntityStore>):
- Validates the range (
<= 0.01or> 4.0throws). - Updates
TimeResource.timeDilationModifier. - Broadcasts a
SetTimeDilationpacket to all players in the world.
(Usage of the dilation modifier in other systems is not covered here; this page only documents what is directly visible in the time module and World.)
Commands
Section titled “Commands”com.hypixel.hytale.server.core.modules.time.commands.TimeCommand provides:
time(alias:daytime) info output (includes moon phase)time set <hours>wherehoursis validated to[0, WorldTimeResource.HOURS_PER_DAY]- Period shortcuts:
Dawn,Midday,Dusk,Midnight(also aliases likeday,morning,noon,night) time pause(aliasstop) delegates toWorldConfigPauseTimeCommand.pauseTime(...)time dilation <float>delegates toWorld.setTimeDilation(...)
Practical mod patterns (code-backed)
Section titled “Practical mod patterns (code-backed)”Read world time in a system/command
Section titled “Read world time in a system/command”The core time command uses:
WorldTimeResource wtr = store.getResource(WorldTimeResource.getResourceType());Instant t = wtr.getGameTime();Set day time
Section titled “Set day time”WorldTimeResource.setDayTime(double dayTime, World world, Store<EntityStore> store) expects dayTime in [0, 1] and will broadcast the time update.
Related classes
Section titled “Related classes”com.hypixel.hytale.server.core.modules.time.TimeModulecom.hypixel.hytale.server.core.modules.time.WorldTimeResourcecom.hypixel.hytale.server.core.modules.time.TimeResourcecom.hypixel.hytale.server.core.modules.time.TimeSystemcom.hypixel.hytale.server.core.modules.time.TimePacketSystemcom.hypixel.hytale.server.core.modules.time.commands.TimeCommand- Packets:
UpdateTime,UpdateTimeSettings,SetTimeDilation