Class GameCycles

java.lang.Object
dev.twilite.game.common.GameCycles

public class GameCycles extends Object
Helpers for converting client cycles to game ticks.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Number of client cycles in a game tick.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    duration(int startCycle, int endCycle)
    Returns the duration between two client cycles in game ticks.
    static int
    elapsed(int startCycle, int endCycle, int currentCycle)
    Returns elapsed game ticks between startCycle and currentCycle, clamped to the supplied end cycle.
    static int
    remaining(int endCycle, int currentCycle)
    Returns remaining game ticks from currentCycle to endCycle.
    static int
    remaining(int startCycle, int endCycle, int currentCycle)
    Returns remaining game ticks from currentCycle to endCycle, clamped to the supplied start cycle.
    static int
    toTicks(int cycles)
    Converts client cycles to game ticks, rounding partial ticks up.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PER_TICK

      public static final int PER_TICK
      Number of client cycles in a game tick.
      See Also:
  • Constructor Details

    • GameCycles

      public GameCycles()
  • Method Details

    • toTicks

      public static int toTicks(int cycles)
      Converts client cycles to game ticks, rounding partial ticks up.
      Returns:
      tick count, or 0 for non-positive cycle counts
    • duration

      public static int duration(int startCycle, int endCycle)
      Returns the duration between two client cycles in game ticks.
    • elapsed

      public static int elapsed(int startCycle, int endCycle, int currentCycle)
      Returns elapsed game ticks between startCycle and currentCycle, clamped to the supplied end cycle.
    • remaining

      public static int remaining(int endCycle, int currentCycle)
      Returns remaining game ticks from currentCycle to endCycle.
    • remaining

      public static int remaining(int startCycle, int endCycle, int currentCycle)
      Returns remaining game ticks from currentCycle to endCycle, clamped to the supplied start cycle.