Package com.minecolonies.api.util
Class MathUtils
java.lang.Object
com.minecolonies.api.util.MathUtils
Useful math stuff to use statically.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intclamp(int value, int min, int max) Clamped a value between a lower and upper bound.static doublesquare(double number) Returns the square product of a number.static doubletwoDimDistance(@NotNull net.minecraft.core.BlockPos position, @NotNull net.minecraft.core.BlockPos target) Calculates the distance between two points without considering the y-value.
-
Field Details
-
RANDOM
Static random for global use.
-
-
Method Details
-
square
public static double square(double number) Returns the square product of a number.- Parameters:
number- Number to square.- Returns:
- Answer of calculation.
-
twoDimDistance
public static double twoDimDistance(@NotNull @NotNull net.minecraft.core.BlockPos position, @NotNull @NotNull net.minecraft.core.BlockPos target) Calculates the distance between two points without considering the y-value.- Parameters:
position- the start position.target- the end position.- Returns:
- the distance.
-
clamp
public static int clamp(int value, int min, int max) Clamped a value between a lower and upper bound.- Parameters:
value- the input value to clamp.min- the lower bound.max- the upper bound.- Returns:
- the value, clamped between the lower and upper bound.
-