Removed "render ticks" tick type. Instead, animations and frames can define a tick speed measured in milliseconds. Animations/frames using MC tick type will be 50ms (1000ms/20), and render ticks 20ms.

This commit is contained in:
luisc committed 2024-03-23 23:34:01 -05:00
1 parent de909472b3
commit 799631eece
11 files changed
+97 -95

No files matched your search

@@ -23,6 +23,7 @@ import net.minecraft.stats.Achievement;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Timer;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
@@ -59,6 +60,7 @@ import noppes.npcs.config.ConfigMain;
import noppes.npcs.config.StringCache;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.*;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.*;
import noppes.npcs.entity.data.ModelData;
@@ -80,7 +82,34 @@ public class ClientProxy extends CommonProxy {
public static FontContainer Font;
private static Timer animationTimer = new Timer(1000);
private static long totalTicks;
public void load() {
Thread thread = (new Thread("Animation Thread") { public void run() {
while (true) {
if (!Minecraft.getMinecraft().isGamePaused()) {
animationTimer.updateTimer();
}
try {
for (int i = 0; i < animationTimer.elapsedTicks; ++i) {
for (Animation animation : ClientCacheHandler.playingAnimations) {
if (animation.parent.isActive() && totalTicks % animation.currentFrame().tickDuration() == 0) {
animation.increaseTime();
}
}
totalTicks++;
}
totalTicks %= 60 * 60 * 1000;
ClientCacheHandler.playingAnimations.removeIf(animation ->
animation.parent.animation != animation || !animation.parent.isActive());
} catch (Exception ignored) {}
}
}});
thread.setDaemon(true);
thread.start();
Font = new FontContainer(ConfigClient.FontType, ConfigClient.FontSize);
createFolders();
CustomNpcs.Channel.register(new PacketHandlerClient());