Class MinecraftTime

java.lang.Object
org.incendo.cloud.minecraft.modded.data.MinecraftTime

public final class MinecraftTime extends Object
An element of in-game time.

The basic unit is 1 tick, which aims to be 50ms

  • Method Details

    • of

      public static @NonNull MinecraftTime of(long ticks)
      Get the time instance for the specified number of ticks.
      Parameters:
      ticks - the number of ticks
      Returns:
      a time holder
    • of

      public static @NonNull MinecraftTime of(long amount, @NonNull TemporalUnit unit)
      Given an amount of time in another unit, create a game time holding the number of ticks expected to pass in that time.
      Parameters:
      amount - the amount of time
      unit - the unit
      Returns:
      a time holder
    • of

      public static @NonNull MinecraftTime of(long amount, @NonNull TimeUnit unit)
      Given an amount of time in another unit, create a game time holding the number of ticks expected to pass in that time.
      Parameters:
      amount - the amount of time
      unit - the unit
      Returns:
      a time holder
    • ticks

      public int ticks()
      Get the number of in-game ticks represented by this time.

      This time will be truncated to the maximum value of an integer. See ticksLong() for the full contents.

      Returns:
      the time in ticks
    • ticksLong

      public long ticksLong()
      Get the number of in-game ticks represented by this time.
      Returns:
      the time in ticks
    • convertTo

      public long convertTo(@NonNull TemporalUnit unit)
      Convert this to another time unit.
      Parameters:
      unit - the target unit
      Returns:
      the target duration, as represented by the provided unit
    • convertTo

      public long convertTo(@NonNull TimeUnit unit)
      Convert this to another time unit.
      Parameters:
      unit - the target unit
      Returns:
      the target duration, as represented by the provided unit
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object