Contents
- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- getResourceType()
- getSecondsPerTick(World)
- tick(float, Store)
- getMoonPhase()
- setMoonPhase(int, ComponentAccessor)
- updateMoonPhase(World, ComponentAccessor)
- isMoonPhaseWithinRange(World, int, int)
- setGameTime0(Instant)
- getGameTime()
- getGameDateTime()
- getSunlightFactor()
- setGameTime(Instant, World, ComponentAccessor)
- setDayTime(double, World, ComponentAccessor)
- startDayTimeInterpolation(double, double, boolean, boolean, World, ComponentAccessor)
- isInterpolating()
- cancelInterpolation()
- broadcastTimePacket(ComponentAccessor)
- sendTimePackets(PlayerRef)
- isDayTimeWithinRange(double, double)
- updateTimePacket(UpdateTime)
- updateTimeSettingsPacket(UpdateTimeSettings, World)
- isScaledDayTimeWithinRange(double, double)
- isYearWithinRange(double, double)
- getCurrentHour()
- getDayProgress()
- dayProgressToInstant(double)
- getSunDirection()
- instantToInstantData(Instant)
- instantDataToInstant(InstantData)
- clone()
- toString()
Class WorldTimeResource
java.lang.Object
com.hypixel.hytale.server.core.modules.time.WorldTimeResource
- All Implemented Interfaces:
Resource<EntityStore>, Cloneable
An entity store resource that contains and processes the current world time.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final floatstatic final intstatic final intstatic final Instantstatic final longstatic final intstatic final intstatic final floatThe lerp amount used when applying the safe angle for shadow mappingstatic final floatstatic final intstatic final booleanstatic final Instantstatic final ZoneOffsetFields inherited from interface Resource
EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidBroadcasts the current time data to all players within the given entity store.voidCancels any in-progress day-time interpolation, leaving the time at its current value.clone()dayProgressToInstant(double dayProgress) Resolves the absoluteInstantfor the given day progress (0.0-1.0) within the current day, without mutating world time.intfloatintstatic ResourceType<EntityStore, WorldTimeResource> static doublegetSecondsPerTick(World world) org.joml.Vector3dCalled to calculate and fetch the sun direction based on the time of the given world.doublestatic InstantinstantDataToInstant(InstantData instantData) Called to convert and fetch theInstantof the providedInstantDatainstance.static InstantDatainstantToInstantData(Instant instant) Called to convert and fetch theInstantDataof the providedInstantinstance.booleanisDayTimeWithinRange(double minTime, double maxTime) Determines if world time is between start and end time.booleanbooleanisMoonPhaseWithinRange(World world, int minMoonPhase, int maxMoonPhase) Determines whether the current moon phase is within the given range.booleanisScaledDayTimeWithinRange(double minTime, double maxTime) Determines if world time scaled relative to daylight portion is within the interval. 0 - 6 represents the hours between midnight and sunrise. 6 - 12 represents the hours between sunrise and midday. 12 - 18 represents the hours between midday and sunset. 18 - 24 represents the hours between sunset and midnight.booleanisYearWithinRange(double minTime, double maxTime) Determines whether the current year progress of the game time is within the given range.voidsendTimePackets(PlayerRef playerRef) Sends the current time settings and packet to the given player.voidsetDayTime(double dayTime, World world, ComponentAccessor<EntityStore> store) Called to set the current day time of the world.voidsetGameTime(Instant gameTime, World world, ComponentAccessor<EntityStore> store) Called to set the current game time of the world.voidsetGameTime0(Instant gameTime) Called to set the game time to the given instantvoidsetMoonPhase(int moonPhase, ComponentAccessor<EntityStore> componentAccessor) Called to set the moon phase of the world.voidstartDayTimeInterpolation(double targetDayProgress, double durationSeconds, boolean forward, boolean pauseOnComplete, World world, ComponentAccessor<EntityStore> store) Begins interpolating the game time from its current value totargetDayProgress(0.0-1.0, where 0.5 is noon) overdurationSecondsof real time, advanced eachtick(float, Store).voidtick(float dt, Store<EntityStore> store) Called to tick and update the logic of this world time resource instance.toString()voidupdateMoonPhase(World world, ComponentAccessor<EntityStore> componentAccessor) Called to update the current moon phase of the world.voidupdateTimePacket(UpdateTime currentTimePacket) Called to update theUpdateTimepacket with the latest game time data.static UpdateTimeSettingsupdateTimeSettingsPacket(UpdateTimeSettings settings, World world) Called to update and return the currentUpdateTimeSettingspacket with the latest gameplay config information.
-
Field Details
-
NANOS_PER_DAY
public static final long NANOS_PER_DAY -
SECONDS_PER_DAY
public static final int SECONDS_PER_DAY -
HOURS_PER_DAY
public static final int HOURS_PER_DAY -
DAYS_PER_YEAR
public static final int DAYS_PER_YEAR -
ZERO_YEAR
-
MAX_TIME
-
ZONE_OFFSET
-
SUN_HEIGHT
public static final float SUN_HEIGHT- See Also:
-
USE_SHADOW_MAPPING_SAFE_ANGLE
public static final boolean USE_SHADOW_MAPPING_SAFE_ANGLE- See Also:
-
DAYTIME_PORTION_PERCENTAGE
public static final float DAYTIME_PORTION_PERCENTAGE- See Also:
-
DAYTIME_SECONDS
public static final int DAYTIME_SECONDS -
NIGHTTIME_SECONDS
public static final int NIGHTTIME_SECONDS -
SUNRISE_SECONDS
public static final int SUNRISE_SECONDS -
SHADOW_MAPPING_SAFE_ANGLE_LERP
public static final float SHADOW_MAPPING_SAFE_ANGLE_LERPThe lerp amount used when applying the safe angle for shadow mapping- See Also:
-
-
Constructor Details
-
WorldTimeResource
public WorldTimeResource()
-
-
Method Details
-
getResourceType
-
getSecondsPerTick
-
tick
Called to tick and update the logic of this world time resource instance.- Parameters:
dt- The delta time of the current tick.store- TheStore<EntityStore>for component access.
-
getMoonPhase
public int getMoonPhase()- Returns:
- the current moon phase of this world.
-
setMoonPhase
Called to set the moon phase of the world.- Parameters:
moonPhase- The moon phase to set.componentAccessor- TheComponentAccessor<EntityStore>for component access.
-
updateMoonPhase
public void updateMoonPhase(@Nonnull World world, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Called to update the current moon phase of the world.- Parameters:
world- The provided world to update the moon phase for.componentAccessor- TheComponentAccessor<EntityStore>for component access.
-
isMoonPhaseWithinRange
Determines whether the current moon phase is within the given range.- Parameters:
world- The world associated with this world time resource.minMoonPhase- The start of the moon phase range.maxMoonPhase- The end of the moon phase range.- Returns:
trueif the phase is within the given range,falseotherwise.
-
setGameTime0
Called to set the game time to the given instant- Parameters:
gameTime- The game time instant to set.
-
getGameTime
- Returns:
- the current game time instant of the world.
-
getGameDateTime
- Returns:
- the current game time, as a local date time, of the world.
-
getSunlightFactor
public double getSunlightFactor()- Returns:
- the current sunlight factor of the world.
-
setGameTime
public void setGameTime(@Nonnull Instant gameTime, @Nonnull World world, @Nonnull ComponentAccessor<EntityStore> store) Called to set the current game time of the world.- Parameters:
gameTime- The game time instant to set.world- The world to set the game time of.store- The entity store associated with the world.
-
setDayTime
public void setDayTime(double dayTime, @Nonnull World world, @Nonnull ComponentAccessor<EntityStore> store) Called to set the current day time of the world.- Parameters:
dayTime- The day time to be set.world- The world to set the day time of.store- The entity store associated with the world.
-
startDayTimeInterpolation
public void startDayTimeInterpolation(double targetDayProgress, double durationSeconds, boolean forward, boolean pauseOnComplete, @Nonnull World world, @Nonnull ComponentAccessor<EntityStore> store) Begins interpolating the game time from its current value totargetDayProgress(0.0-1.0, where 0.5 is noon) overdurationSecondsof real time, advanced eachtick(float, Store). A duration of 0 or less applies the target instantly.forwardchooses the direction the time sweeps to reach the target, so a transition can run e.g. 13:00 -> 06:00 backward rather than the long way around. WhenpauseOnCompleteis set, time is paused once the target is reached. UnlikesetDayTime(double, World, ComponentAccessor), this does not force forward-only movement. -
isInterpolating
public boolean isInterpolating()- Returns:
- whether a day-time interpolation is currently in progress.
-
cancelInterpolation
public void cancelInterpolation()Cancels any in-progress day-time interpolation, leaving the time at its current value. -
broadcastTimePacket
Broadcasts the current time data to all players within the given entity store.- Parameters:
store- The entity store to broadcast the time data to each player of.
-
sendTimePackets
-
isDayTimeWithinRange
public boolean isDayTimeWithinRange(double minTime, double maxTime) Determines if world time is between start and end time. The start and end time need to be between [0, 1]: (time in hours / 24f)- Parameters:
minTime- The start of the time range.maxTime- The end of the time range.- Returns:
trueif the current day time is within the provided range,falseotherwise.
-
updateTimePacket
Called to update theUpdateTimepacket with the latest game time data.- Parameters:
currentTimePacket- TheUpdateTimepacket to populate.
-
updateTimeSettingsPacket
@Nonnull public static UpdateTimeSettings updateTimeSettingsPacket(@Nonnull UpdateTimeSettings settings, @Nonnull World world) Called to update and return the currentUpdateTimeSettingspacket with the latest gameplay config information.- Parameters:
settings- TheUpdateTimeSettingspacket to populate.world- The world to read the time configuration from.- Returns:
- the updated
UpdateTimeSettingspacket.
-
isScaledDayTimeWithinRange
public boolean isScaledDayTimeWithinRange(double minTime, double maxTime) Determines if world time scaled relative to daylight portion is within the interval. 0 - 6 represents the hours between midnight and sunrise. 6 - 12 represents the hours between sunrise and midday. 12 - 18 represents the hours between midday and sunset. 18 - 24 represents the hours between sunset and midnight. These values are normalised for minTime and maxTime to be between 0 and 1.- Parameters:
minTime- The start of the time range.maxTime- The end of the time range.- Returns:
trueif the scaled day time is within the given range,falseotherwise.
-
isYearWithinRange
public boolean isYearWithinRange(double minTime, double maxTime) Determines whether the current year progress of the game time is within the given range.- Parameters:
minTime- The start of the time range.maxTime- The end of the time range.- Returns:
trueif the year is within the given range,falseotherwise.
-
getCurrentHour
public int getCurrentHour()- Returns:
- the current hour of the world time.
-
getDayProgress
public float getDayProgress()- Returns:
- the current day progress of the world time.
-
dayProgressToInstant
-
getSunDirection
@Nonnull public org.joml.Vector3d getSunDirection()Called to calculate and fetch the sun direction based on the time of the given world.- Returns:
- the
Vector3dinstance representing the sun direction.
-
instantToInstantData
Called to convert and fetch theInstantDataof the providedInstantinstance.- Parameters:
instant- TheInstantinstance to convert into anInstantDatainstance.- Returns:
- the converted
InstantDatainstance.
-
instantDataToInstant
Called to convert and fetch theInstantof the providedInstantDatainstance.- Parameters:
instantData- TheInstantDatainstance to convert into anInstantinstance.- Returns:
- the converted
Instantinstance.
-
clone
- Specified by:
clonein interfaceResource<EntityStore>- Returns:
- a clone instance of the original resource instance.
-
toString
-