Package net.minestom.server.utils.time
Class Tick
java.lang.Object
net.minestom.server.utils.time.Tick
- All Implemented Interfaces:
TemporalUnit
A TemporalUnit that represents one tick.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<R extends Temporal>
RaddTo(R temporal, long amount) longstatic Durationclient(long ticks) Creates a duration from an amount of client-side ticks.intfromDuration(Duration duration) Gets the number of whole ticks that occur in the provided duration.intGets the whole number of these ticks that occur in one second.booleanbooleanbooleanstatic Durationserver(long ticks) Creates a duration from an amount of ticks.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.time.temporal.TemporalUnit
isSupportedBy, toString
-
Field Details
-
SERVER_TICKS
A TemporalUnit representing the server tick. This is defined usingMinecraftServer.TICK_MS. -
CLIENT_TICKS
A TemporalUnit representing the client tick. This is always equal to 50ms.
-
-
Method Details
-
server
Creates a duration from an amount of ticks.- Parameters:
ticks- the amount of ticks- Returns:
- the duration
-
client
Creates a duration from an amount of client-side ticks.- Parameters:
ticks- the amount of ticks- Returns:
- the duration
-
fromDuration
Gets the number of whole ticks that occur in the provided duration. Note that this method returns anintas this is the unit that Minecraft stores ticks in.- Parameters:
duration- the duration- Returns:
- the number of whole ticks in this duration
- Throws:
ArithmeticException- if the duration is zero or an overflow occurs
-
getTicksPerSecond
public int getTicksPerSecond()Gets the whole number of these ticks that occur in one second.- Returns:
- the number
-
getDuration
- Specified by:
getDurationin interfaceTemporalUnit
-
isDurationEstimated
public boolean isDurationEstimated()- Specified by:
isDurationEstimatedin interfaceTemporalUnit
-
isDateBased
public boolean isDateBased()- Specified by:
isDateBasedin interfaceTemporalUnit
-
isTimeBased
public boolean isTimeBased()- Specified by:
isTimeBasedin interfaceTemporalUnit
-
addTo
- Specified by:
addToin interfaceTemporalUnit
-
between
- Specified by:
betweenin interfaceTemporalUnit
-