Added needed gui utils

This commit is contained in:
bigguy345 committed 2025-12-19 12:10:31 +02:00
1 parent cd4174713a
commit ebd005c2df
3 files changed
+304

No files matched your search

@@ -1,6 +1,15 @@
package noppes.npcs.util;
public class ValueUtil {
public static float lerp(float start, float end, float delta) {
return start + delta * (end - start);
}
public static double lerp(double start, double end, double delta) {
return start + delta * (end - start);
}
public static float clamp(float given, float min, float max) {
if (given < min)
return min;
@@ -48,4 +57,16 @@ public class ValueUtil {
return max;
return given;
}
public static String format(double value) {
return (value % 1 == 0) ? String.format("%.0f", value) : String.format("%.2f", value);
}
public static String format(String precision, float value) {
return (value % 1 == 0) ? String.format("%.0f", value) : String.format(precision, value);
}
public static String format(String precision, double value) {
return (value % 1 == 0) ? String.format("%.0f", value) : String.format(precision, value);
}
}