Package org.geysermc.connector.utils
Class MathUtils
java.lang.Object
org.geysermc.connector.utils.MathUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intceil(float floatNumber)Round the given float to the next whole numberstatic longchunkPositionToLong(int x, int z)Packs a chunk's X and Z coordinates into a singlelong.static doubleconstrain(double num, double min, double max)If number is greater than the max, set it to max, and if number is lower than low, set it to low.static intconstrain(int num, int min, int max)If number is greater than the max, set it to max, and if number is lower than low, set it to low.static ByteconvertByte(Object value)Converts the given object from an int or byte to byte.
-
Field Details
-
SQRT_OF_TWO
public static final double SQRT_OF_TWO
-
-
Constructor Details
-
MathUtils
public MathUtils()
-
-
Method Details
-
ceil
public static int ceil(float floatNumber)Round the given float to the next whole number- Parameters:
floatNumber- Float to round- Returns:
- Rounded number
-
constrain
public static double constrain(double num, double min, double max)If number is greater than the max, set it to max, and if number is lower than low, set it to low.- Parameters:
num- number to calculatemin- the lowest value the number can bemax- the greatest value the number can be- Returns:
- - min if num is lower than min
- max if num is greater than max
- num otherwise
-
constrain
public static int constrain(int num, int min, int max)If number is greater than the max, set it to max, and if number is lower than low, set it to low.- Parameters:
num- number to calculatemin- the lowest value the number can bemax- the greatest value the number can be- Returns:
- - min if num is lower than min
- max if num is greater than max
- num otherwise
-
convertByte
Converts the given object from an int or byte to byte. This is used for NBT data that might be either an int or byte and bedrock only takes it as an byte- Parameters:
value- The value to convert- Returns:
- The converted byte
-
chunkPositionToLong
public static long chunkPositionToLong(int x, int z)Packs a chunk's X and Z coordinates into a singlelong.- Parameters:
x- the X coordinatez- the Z coordinate- Returns:
- the packed coordinates
-