Interface DayNightCycle
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe length of a full day, in ticks.static final intThe time of day of midnight.static final intThe number of moon phases, one per day.static final intThe time of day night falls.static final intThe time of day of noon.static final intThe last time of day players may sleep, inclusive.static final intThe first time of day players may sleep, inclusive.static final intThe time of day the sun starts rising.static final intThe time of day the sun is fully risen, and the day starts.static final intThe time of day the sun starts setting. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddTime(long ticks) Moves the time forward, or backward with a negative value.default booleancanSleep()Returnstruewhen the time of day allows players to sleep.default doubleReturns the angle of the sun in the sky, as a fraction of a full turn.clock()Returns the key of theminecraft:world_clockdriving this cycle.default longday()Returns the number of full days elapsed.booleanReturnstruewhile the time advances on its own.floatReturns the fraction of tick accumulated when the rate is not a whole number.default booleanisDay()ReturnstrueduringDayPhase.DAY.default booleanisNight()ReturnstrueduringDayPhase.NIGHT.default intReturns the moon phase, from0(full moon) toMOON_PHASES - 1.default DayPhasephase()Returns the part of the day the current time falls in.floatrate()Returns the number of ticks the time advances by per server tick,1by default.voidsetDoDaylightCycle(boolean enabled) Freezes or resumes the time.voidsetRate(float rate) Sets how fast time flows.voidsetTime(long time) Sets the total time and resynchronizes the clients.default doubleReturns the angle of the sun in the sky, in degrees.default longticksUntil(int targetTimeOfDay) Returns the number of ticks until the given time of day comes next, from1toDAY_LENGTH.longtime()Returns the total time, in ticks; it only advances while the cycle runs.default intReturns the time of day, from0toDAY_LENGTH - 1.longworldAge()Returns the number of ticks this world has existed, whatever the cycle does.
-
Field Details
-
DAY_LENGTH
static final int DAY_LENGTHThe length of a full day, in ticks.- Since:
- 0.1.0
- See Also:
-
SUNRISE_END
static final int SUNRISE_ENDThe time of day the sun is fully risen, and the day starts.- Since:
- 0.1.0
- See Also:
-
NOON
static final int NOONThe time of day of noon.- Since:
- 0.1.0
- See Also:
-
SUNSET
static final int SUNSETThe time of day the sun starts setting.- Since:
- 0.1.0
- See Also:
-
NIGHT_START
static final int NIGHT_STARTThe time of day night falls.- Since:
- 0.1.0
- See Also:
-
MIDNIGHT
static final int MIDNIGHTThe time of day of midnight.- Since:
- 0.1.0
- See Also:
-
SUNRISE
static final int SUNRISEThe time of day the sun starts rising.- Since:
- 0.1.0
- See Also:
-
SLEEP_START
static final int SLEEP_STARTThe first time of day players may sleep, inclusive.- Since:
- 0.1.0
- See Also:
-
SLEEP_END
static final int SLEEP_ENDThe last time of day players may sleep, inclusive.- Since:
- 0.1.0
- See Also:
-
MOON_PHASES
static final int MOON_PHASESThe number of moon phases, one per day.- Since:
- 0.1.0
- See Also:
-
-
Method Details
-
clock
Key clock()Returns the key of theminecraft:world_clockdriving this cycle.- Returns:
- the key of the
minecraft:world_clockdriving this cycle - Since:
- 0.1.0
-
worldAge
long worldAge()Returns the number of ticks this world has existed, whatever the cycle does.- Returns:
- the number of ticks this world has existed, whatever the cycle does
- Since:
- 0.1.0
-
time
long time()Returns the total time, in ticks; it only advances while the cycle runs.- Returns:
- the total time, in ticks; it only advances while the cycle runs
- Since:
- 0.1.0
-
setTime
void setTime(long time) Sets the total time and resynchronizes the clients.- Parameters:
time- the new total time, in ticks- Since:
- 0.1.0
-
addTime
default void addTime(long ticks) Moves the time forward, or backward with a negative value.- Parameters:
ticks- the number of ticks to add- Since:
- 0.1.0
-
fractionalTime
-
rate
float rate()Returns the number of ticks the time advances by per server tick,1by default.- Returns:
- the number of ticks the time advances by per server tick,
1by default - Since:
- 0.1.0
-
setRate
void setRate(float rate) Sets how fast time flows.- Parameters:
rate- the number of ticks per server tick; negative values are treated as0- Since:
- 0.1.0
-
doDaylightCycle
boolean doDaylightCycle()Returnstruewhile the time advances on its own.- Returns:
truewhile the time advances on its own- Since:
- 0.1.0
-
setDoDaylightCycle
void setDoDaylightCycle(boolean enabled) Freezes or resumes the time.- Parameters:
enabled-falseto freeze the time- Since:
- 0.1.0
-
timeOfDay
default int timeOfDay()Returns the time of day, from0toDAY_LENGTH - 1.- Returns:
- the time of day, from
0toDAY_LENGTH - 1 - Since:
- 0.1.0
-
day
default long day()Returns the number of full days elapsed.- Returns:
- the number of full days elapsed
- Since:
- 0.1.0
-
moonPhase
default int moonPhase()Returns the moon phase, from0(full moon) toMOON_PHASES - 1.- Returns:
- the moon phase, from
0(full moon) toMOON_PHASES - 1 - Since:
- 0.1.0
-
phase
Returns the part of the day the current time falls in.- Returns:
- the part of the day the current time falls in
- Since:
- 0.1.0
-
isDay
default boolean isDay()ReturnstrueduringDayPhase.DAY.- Returns:
trueduringDayPhase.DAY- Since:
- 0.1.0
-
isNight
default boolean isNight()ReturnstrueduringDayPhase.NIGHT.- Returns:
trueduringDayPhase.NIGHT- Since:
- 0.1.0
-
canSleep
default boolean canSleep()Returnstruewhen the time of day allows players to sleep.- Returns:
truewhen the time of day allows players to sleep- Since:
- 0.1.0
-
ticksUntil
default long ticksUntil(int targetTimeOfDay) Returns the number of ticks until the given time of day comes next, from1toDAY_LENGTH.- Parameters:
targetTimeOfDay- the time of day to wait for- Returns:
- the number of ticks until the given time of day comes next, from
1toDAY_LENGTH - Since:
- 0.1.0
-
skyAngleDegrees
default double skyAngleDegrees()Returns the angle of the sun in the sky, in degrees.- Returns:
- the angle of the sun in the sky, in degrees
- Since:
- 0.1.0
-
celestialAngle
default double celestialAngle()Returns the angle of the sun in the sky, as a fraction of a full turn.- Returns:
- the angle of the sun in the sky, as a fraction of a full turn
- Since:
- 0.1.0
-