2021-06-16 20:19:33 +02:00
|
|
|
package com.jozufozu.flywheel.util;
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
|
|
|
public class AnimationTickHolder {
|
|
|
|
|
2021-06-30 21:43:54 +02:00
|
|
|
private static int ticks;
|
|
|
|
private static int paused_ticks;
|
|
|
|
|
|
|
|
public static void reset() {
|
|
|
|
ticks = 0;
|
|
|
|
paused_ticks = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void tick() {
|
|
|
|
if (!Minecraft.getInstance()
|
2021-07-15 20:36:24 +02:00
|
|
|
.isPaused()) {
|
2021-06-30 21:43:54 +02:00
|
|
|
ticks = (ticks + 1) % 1_728_000; // wrap around every 24 hours so we maintain enough floating point precision
|
2021-06-30 22:03:02 +02:00
|
|
|
} else {
|
2021-06-30 21:43:54 +02:00
|
|
|
paused_ticks = (paused_ticks + 1) % 1_728_000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getTicks() {
|
|
|
|
return getTicks(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getTicks(boolean includePaused) {
|
|
|
|
return includePaused ? ticks + paused_ticks : ticks;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static float getRenderTime() {
|
|
|
|
return getTicks() + getPartialTicks();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static float getPartialTicks() {
|
|
|
|
Minecraft mc = Minecraft.getInstance();
|
2021-07-15 20:36:24 +02:00
|
|
|
return (mc.isPaused() ? mc.pausePartialTick : mc.getFrameTime());
|
2021-06-30 21:43:54 +02:00
|
|
|
}
|
2021-06-16 20:19:33 +02:00
|
|
|
}
|