package dev.crucifixbeta.core.impl;

import java.util.ArrayDeque;
import java.util.Deque;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class FPSManager {
   private final Deque<Long> records = new ArrayDeque<>();

   public void record() {
      this.records.addLast(System.currentTimeMillis());
   }

   public int getFps() {
      long var1 = System.currentTimeMillis();

      while (!this.records.isEmpty() && this.records.peekFirst() + 1000L < var1) {
         this.records.pollFirst();
      }

      return this.records.size();
   }
}
