QuickMath/src/main/java/io/gitlab/jfronny/quickmeth/MathUtil.java

38 lines
1.1 KiB
Java
Raw Normal View History

2020-08-06 23:55:17 +02:00
package io.gitlab.jfronny.quickmeth;
2020-08-07 09:58:35 +02:00
import net.minecraft.util.math.MathHelper;
2020-08-06 23:55:17 +02:00
2021-05-19 15:12:49 +02:00
public class MathUtil {
2021-10-16 17:28:07 +02:00
public static double boxedInvert(double min, double max, double value) {
2020-08-07 00:18:24 +02:00
return max - value + min;
}
2021-10-16 17:28:07 +02:00
public static double boxedInvert(double value) {
return boxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value);
2020-08-07 09:58:35 +02:00
}
2021-10-16 17:28:07 +02:00
public static float boxedInvert(float min, float max, float value) {
2020-08-07 09:58:35 +02:00
return max - value + min;
}
2021-10-16 17:28:07 +02:00
public static float boxedInvert(float value) {
return boxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value);
2020-08-07 00:18:24 +02:00
}
2021-05-29 15:54:38 +02:00
2021-10-16 17:28:07 +02:00
public static long boxedInvert(long min, long max, long value) {
2021-05-29 15:54:38 +02:00
return max - value + min;
}
2021-10-16 17:28:07 +02:00
public static long boxedInvert(long value) {
return boxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value);
2021-05-29 15:54:38 +02:00
}
2021-10-16 17:28:07 +02:00
public static int boxedInvert(int min, int max, int value) {
2021-05-29 15:54:38 +02:00
return max - value + min;
}
2021-10-16 17:28:07 +02:00
public static int boxedInvert(int value) {
return boxedInvert(MathHelper.floor(value), MathHelper.ceil(value), value);
2021-05-29 15:54:38 +02:00
}
2020-08-06 23:55:17 +02:00
}