Class TickAccumulator

java.lang.Object
net.darkhax.bookshelf.common.api.util.TickAccumulator

public class TickAccumulator extends Object
While the current tick rate is synced between the client and server, some things like tile entities continue to tick at the base 20tps on the client. This tick accumulator allows ticks to be accumulates as normal the server, but will scale client ticks to roughly the correct amount.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TickAccumulator(float defaultValue)
    Creates a new tick accumulator.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Get the current amount of ticks.
    void
    Resets the tick accumulator.
    void
    setTicks(float ticks)
    Sets the current amount of ticks.
    void
    tick(float amount)
    Adds an amount of ticks to the accumulator.
    void
    tickDown(net.minecraft.world.level.Level level)
    Ticks the accumulator down by one tick.
    void
    tickUp(net.minecraft.world.level.Level level)
    Ticks the accumulator up by one tick.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TickAccumulator

      public TickAccumulator(float defaultValue)
      Creates a new tick accumulator.
      Parameters:
      defaultValue - The amount to reset to when reset() is used.
  • Method Details

    • tickUp

      public void tickUp(net.minecraft.world.level.Level level)
      Ticks the accumulator up by one tick.
      Parameters:
      level - The current game level.
    • tickDown

      public void tickDown(net.minecraft.world.level.Level level)
      Ticks the accumulator down by one tick.
      Parameters:
      level - The current game level.
    • tick

      public void tick(float amount)
      Adds an amount of ticks to the accumulator.
      Parameters:
      amount - The amount of ticks to add.
    • getTicks

      public float getTicks()
      Get the current amount of ticks.
      Returns:
      The current amount of ticks.
    • setTicks

      public void setTicks(float ticks)
      Sets the current amount of ticks.
      Parameters:
      ticks - The new tick count.
    • reset

      public void reset()
      Resets the tick accumulator.