Interface MinecraftDayTime
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(int days, int hour, int minute) Adds the time given by the arguments and returns a new object with the result.Adds the time given by the providedTicks
object and returns a new object with the result.Returns aDuration
that represents in-game time from the minecraft epoch (so, for Day 2 at 12:30pm will return a duration of 1 day, 6 hours and 30 minutes).asTicks()
Returns the number ofTicks
that have elapsed since the minecraft epoch.default Duration
asWallClockDuration
(Engine engine) int
day()
The day this represents.int
hour()
The hour this represents.static MinecraftDayTime
AMinecraftDayTime
that represents the Minecraft Epoch, which is 6:00am on Day 1.int
minute()
The minute this represents.static MinecraftDayTime
of
(int day, int hours, int minutes) Creates aMinecraftDayTime
that corresponds to the given units of in-game time.static MinecraftDayTime
Creates aMinecraftDayTime
based on the number ofTicks
elapsed since the Minecraft epoch (6:00am on Day 1) for the givenEngine
.static MinecraftDayTime
ofInGameDuration
(Engine engine, Duration duration) Creates aMinecraftDayTime
based on the in-game time since the Minecraft epoch (6:00am on Day 1) for the givenEngine
.static MinecraftDayTime
ofWallClockDuration
(Engine engine, Duration duration) Creates aMinecraftDayTime
that represents the world time if the world has been running for the suppliedDuration
in real world time under idealised conditions for the givenEngine
.subtract
(int days, int hour, int minute) Subtracts the time given by the arguments and returns a new object with the result.Subtracts the time given by the providedTicks
object and returns a new object with the result.
-
Method Details
-
minecraftEpoch
AMinecraftDayTime
that represents the Minecraft Epoch, which is 6:00am on Day 1.- Returns:
- The
MinecraftDayTime
-
ofInGameDuration
Creates aMinecraftDayTime
based on the in-game time since the Minecraft epoch (6:00am on Day 1) for the givenEngine
.For example, if the supplied
Duration
was 1 day, 3 hours and 40 minutes, this would correspond to an in game time of 9:40am on Day 2.In the case where the supplied
Duration
does not completely align with a validMinecraftDayTime
, the nearest valid time will be returned.- Parameters:
engine
- TheEngine
to use in calculating the day timeduration
- The duration since the Minecraft Epoch.- Returns:
- The
MinecraftDayTime
- Throws:
IllegalArgumentException
- if the duration is negative
-
ofWallClockDuration
Creates aMinecraftDayTime
that represents the world time if the world has been running for the suppliedDuration
in real world time under idealised conditions for the givenEngine
.For example, if the supplied
Duration
was 1 day, 3 hours and 40 minutes and each Minecraft day lasts 20 minutes in the vanilla game, this would correspond to 6:00am on day 84 (1 day, 3 hours and 40 minutes is 1660 minutes, which is 83 20-minute chunks).In the case where the supplied
Duration
does not completely align with a validMinecraftDayTime
, the nearest valid time will be returned.- Parameters:
engine
- TheEngine
to use in calculating the day timeduration
- The wall-clock duration- Returns:
- The
MinecraftDayTime
- Throws:
IllegalArgumentException
- if the duration is negative
-
of
Creates aMinecraftDayTime
that corresponds to the given units of in-game time.The parameters are subject to the following constraints:
day
must be positive;hours
is in 24-hour time, and so must be between 0 and 23, except on day 1, where it must be between 6 and 23; andminutes
must be between 0 and 59.
In the case where the supplied time does not completely align with a valid
MinecraftDayTime
, the nearest valid time will be returned.- Parameters:
day
- The day to set. Must be positive.hours
- The hour to set in 24 hour time.minutes
- The minute to set.- Returns:
- The
MinecraftDayTime
. - Throws:
IllegalArgumentException
- if any of the listed constraints are violated.
-
of
Creates aMinecraftDayTime
based on the number ofTicks
elapsed since the Minecraft epoch (6:00am on Day 1) for the givenEngine
.For example, if the supplied
Ticks
wasTicks.of(18000)
on the vanilla server, this would correspond to an in game time of 12:00am on Day 2 (18 hours after Minecraft epoch).- Parameters:
engine
- TheEngine
to calculate the time for.ticks
- TheTicks
since the Minecraft Epoch.- Returns:
- The
MinecraftDayTime
- Throws:
IllegalArgumentException
- if the tick count is negative
-
day
int day()The day this represents.- Returns:
- The day
-
hour
int hour()The hour this represents.- Returns:
- The hour.
-
minute
int minute()The minute this represents.- Returns:
- The minute.
-
add
Adds the time given by the providedTicks
object and returns a new object with the result.- Parameters:
ticks
- TheTicks
to add.- Returns:
- A new
MinecraftDayTime
-
add
Adds the time given by the arguments and returns a new object with the result.- Parameters:
days
- The number of days to advancehour
- The number of hours to advance (between 0 and 23)minute
- The number of minutes to advance (between 0 and 59)- Returns:
- A new
MinecraftDayTime
- Throws:
IllegalArgumentException
- if any of the arguments are negative.
-
subtract
Subtracts the time given by the providedTicks
object and returns a new object with the result.- Parameters:
ticks
- TheTicks
to subtract.- Returns:
- A new
MinecraftDayTime
- Throws:
IllegalArgumentException
- if the result would be a negative time.
-
subtract
Subtracts the time given by the arguments and returns a new object with the result.- Parameters:
days
- The number of days to advancehour
- The number of hours to advance (between 0 and 23)minute
- The number of minutes to advance (between 0 and 59)- Returns:
- A new
MinecraftDayTime
- Throws:
IllegalArgumentException
- if any of the arguments are negative or the result would be a negative time.
-
asInGameDuration
Duration asInGameDuration()Returns aDuration
that represents in-game time from the minecraft epoch (so, for Day 2 at 12:30pm will return a duration of 1 day, 6 hours and 30 minutes).- Returns:
- A
Duration
-
asWallClockDuration
-
asTicks
Ticks asTicks()Returns the number ofTicks
that have elapsed since the minecraft epoch.- Returns:
- The epoch.
-