Interface MinecraftDayTime
-
Nested Class Summary
Nested Classes -
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 providedTicksobject and returns a new object with the result.Returns aDurationthat 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 ofTicksthat have elapsed since the minecraft epoch.default DurationasWallClockDuration(Engine engine) intday()The day this represents.inthour()The hour this represents.static MinecraftDayTimeAMinecraftDayTimethat represents the Minecraft Epoch, which is 6:00am on Day 1.intminute()The minute this represents.static MinecraftDayTimeof(int day, int hours, int minutes) Creates aMinecraftDayTimethat corresponds to the given units of in-game time.static MinecraftDayTimeCreates aMinecraftDayTimebased on the number ofTickselapsed since the Minecraft epoch (6:00am on Day 1) for the givenEngine.static MinecraftDayTimeofInGameDuration(Engine engine, Duration duration) Creates aMinecraftDayTimebased on the in-game time since the Minecraft epoch (6:00am on Day 1) for the givenEngine.static MinecraftDayTimeofWallClockDuration(Engine engine, Duration duration) Creates aMinecraftDayTimethat represents the world time if the world has been running for the suppliedDurationin 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 providedTicksobject and returns a new object with the result.
-
Method Details
-
minecraftEpoch
AMinecraftDayTimethat represents the Minecraft Epoch, which is 6:00am on Day 1.- Returns:
- The
MinecraftDayTime
-
ofInGameDuration
Creates aMinecraftDayTimebased on the in-game time since the Minecraft epoch (6:00am on Day 1) for the givenEngine.For example, if the supplied
Durationwas 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
Durationdoes not completely align with a validMinecraftDayTime, the nearest valid time will be returned.- Parameters:
engine- TheEngineto use in calculating the day timeduration- The duration since the Minecraft Epoch.- Returns:
- The
MinecraftDayTime - Throws:
IllegalArgumentException- if the duration is negative
-
ofWallClockDuration
Creates aMinecraftDayTimethat represents the world time if the world has been running for the suppliedDurationin real world time under idealised conditions for the givenEngine.For example, if the supplied
Durationwas 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
Durationdoes not completely align with a validMinecraftDayTime, the nearest valid time will be returned.- Parameters:
engine- TheEngineto use in calculating the day timeduration- The wall-clock duration- Returns:
- The
MinecraftDayTime - Throws:
IllegalArgumentException- if the duration is negative
-
of
Creates aMinecraftDayTimethat corresponds to the given units of in-game time.The parameters are subject to the following constraints:
daymust be positive;hoursis in 24-hour time, and so must be between 0 and 23, except on day 1, where it must be between 6 and 23; andminutesmust 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 aMinecraftDayTimebased on the number ofTickselapsed since the Minecraft epoch (6:00am on Day 1) for the givenEngine.For example, if the supplied
TickswasTicks.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- TheEngineto calculate the time for.ticks- TheTickssince 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 providedTicksobject and returns a new object with the result.- Parameters:
ticks- TheTicksto 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 providedTicksobject and returns a new object with the result.- Parameters:
ticks- TheTicksto 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 aDurationthat 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 ofTicksthat have elapsed since the minecraft epoch.- Returns:
- The epoch.
-