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
-
Method Summary
Modifier and TypeMethodDescription<R extends Temporal>
RaddTo
(R temporal, long amount) long
static Duration
client
(long ticks) Creates a duration from an amount of client-side ticks.int
fromDuration
(Duration duration) Gets the number of whole ticks that occur in the provided duration.int
Gets the whole number of these ticks that occur in one second.boolean
boolean
boolean
static Duration
server
(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, wait
Methods 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 anint
as 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:
getDuration
in interfaceTemporalUnit
-
isDurationEstimated
public boolean isDurationEstimated()- Specified by:
isDurationEstimated
in interfaceTemporalUnit
-
isDateBased
public boolean isDateBased()- Specified by:
isDateBased
in interfaceTemporalUnit
-
isTimeBased
public boolean isTimeBased()- Specified by:
isTimeBased
in interfaceTemporalUnit
-
addTo
- Specified by:
addTo
in interfaceTemporalUnit
-
between
- Specified by:
between
in interfaceTemporalUnit
-