Class TickAccumulator
java.lang.Object
net.darkhax.bookshelf.common.api.util.TickAccumulator
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 -
Method Summary
Modifier and TypeMethodDescriptionfloatgetTicks()Get the current amount of ticks.voidreset()Resets the tick accumulator.voidsetTicks(float ticks) Sets the current amount of ticks.voidtick(float amount) Adds an amount of ticks to the accumulator.voidtickDown(net.minecraft.world.level.Level level) Ticks the accumulator down by one tick.voidtickUp(net.minecraft.world.level.Level level) Ticks the accumulator up by one tick.
-
Constructor Details
-
TickAccumulator
public TickAccumulator(float defaultValue) Creates a new tick accumulator.- Parameters:
defaultValue- The amount to reset to whenreset()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.
-