package dev.crucifixbeta.api.utils.math;

import dev.crucifixbeta.CrucifixBeta;
import dev.crucifixbeta.api.utils.Wrapper;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class AnimateUtil implements Wrapper {
   public static float deltaTime() {
      return CrucifixBeta.FPS.getFps() > 5 ? 1.0F / (float)CrucifixBeta.FPS.getFps() : 0.016F;
   }

   public static float fast(float end, float start, float multiple) {
      float var3 = MathUtil.clamp(deltaTime() * multiple, 0.0F, 1.0F);
      return (1.0F - var3) * end + var3 * start;
   }

   public static double animate(double current, double endPoint, double speed) {
      if (speed >= 1.0) {
         return endPoint;
      } else if (speed == 0.0) {
         return current;
      } else {
         boolean var6 = endPoint > current;
         double var7 = Math.max(endPoint, current) - Math.min(endPoint, current);
         if (Math.abs(var7) <= 0.001) {
            return endPoint;
         } else {
            double var9 = var7 * speed;
            return current + (var6 ? var9 : -var9);
         }
      }
   }
}
