Class Tick

java.lang.Object
net.minestom.server.utils.time.Tick
All Implemented Interfaces:
TemporalUnit

public final class Tick extends Object implements TemporalUnit
A TemporalUnit that represents one tick.
  • Field Details

    • SERVER_TICKS

      public static Tick SERVER_TICKS
      A TemporalUnit representing the server tick. This is defined using MinecraftServer.TICK_MS.
    • CLIENT_TICKS

      public static Tick CLIENT_TICKS
      A TemporalUnit representing the client tick. This is always equal to 50ms.
  • Method Details

    • server

      public static Duration server(long ticks)
      Creates a duration from an amount of ticks.
      Parameters:
      ticks - the amount of ticks
      Returns:
      the duration
    • client

      public static Duration client(long ticks)
      Creates a duration from an amount of client-side ticks.
      Parameters:
      ticks - the amount of ticks
      Returns:
      the duration
    • fromDuration

      public int fromDuration(Duration duration)
      Gets the number of whole ticks that occur in the provided duration. Note that this method returns an int 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

      public Duration getDuration()
      Specified by:
      getDuration in interface TemporalUnit
    • isDurationEstimated

      public boolean isDurationEstimated()
      Specified by:
      isDurationEstimated in interface TemporalUnit
    • isDateBased

      public boolean isDateBased()
      Specified by:
      isDateBased in interface TemporalUnit
    • isTimeBased

      public boolean isTimeBased()
      Specified by:
      isTimeBased in interface TemporalUnit
    • addTo

      public <R extends Temporal> R addTo(R temporal, long amount)
      Specified by:
      addTo in interface TemporalUnit
    • between

      public long between(Temporal start, Temporal end)
      Specified by:
      between in interface TemporalUnit