Class Funcs
java.lang.Object
io.github.emcw.utils.Funcs
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic intcalcArea(int[] X, int[] Z) static intcalcArea(int[] X, int[] Z, int numPoints, int @NotNull ... divisor) collectAsMap(@NotNull Stream<Map.Entry<String, T>> stream) static <T> List<T> collectList(Stream<T> stream, Boolean unique) static doubleeuclidean(int x1, int x2, int z1, int z2) Calculates the straight-line distance between two locations, ignoring any obstacles or other factors.static doubleCalculates the distance between two instances ofPoint2Dusing Euclidean geometry.static intmanhattan(int x1, int z1, int x2, int z2) Calculates the Manhattan (sometimes referred to as "taxi-cab") distance between two locations, which is the sum of the absolute differences of their X and Z coordinates.static intCalculates the distance between two instances ofPoint2Dusing Taxi-cab geometry.static intmidrange(int[] ints) Applies the Midrange Formula to the input array, the result is then rounded to the nearest full integer.static <T> @NotNull Stream<T> parallelStreamArr(T[] arr) static <T> List<T> removeListDuplicates(@NotNull List<T> list) static introundToNearest16(double value) static introundToNearest16(int value) static booleanstatic UUIDstringToFullUUID(@NotNull String uuidStr) Ensures aUUIDis full (with hyphens) by inserting them at known points in the string.
If the given string is 36 characters (full uuid), it will use that one without inserting.static booleanwithinRadius(int num, int[] args) static booleanwithinRadius(Integer sourceCoord, Integer targetCoord, Integer radius)  
- 
Constructor Details
- 
Funcs
public Funcs() 
 - 
 - 
Method Details
- 
collectAsMap
 - 
calcArea
public static int calcArea(int[] X, int[] Z)  - 
calcArea
public static int calcArea(int[] X, int[] Z, int numPoints, int @NotNull ... divisor)  - 
roundToNearest16
public static int roundToNearest16(int value)  - 
roundToNearest16
public static int roundToNearest16(double value)  - 
midrange
public static int midrange(int[] ints) Applies the Midrange Formula to the input array, the result is then rounded to the nearest full integer.- Parameters:
 ints- The input array of integers.- Returns:
 - The resulting int (rounded).
 
 - 
euclidean
Calculates the distance between two instances ofPoint2Dusing Euclidean geometry. Note that the order of parameters here does not matter, the distance will be the same.
See the underlying euclidean method for further info.- See Also:
 
 - 
euclidean
public static double euclidean(int x1, int x2, int z1, int z2) Calculates the straight-line distance between two locations, ignoring any obstacles or other factors. This allows for diagonal paths that may not be viable in reality, the result is best only in theory.
In Minecraft, this method is preferred in many cases over Manhattan distance. You can visit here to look at examples of when to use one over the other.- Parameters:
 x1- The X coordinate (left/right) of the first location.x2- The position on the X axis (left/right) of the second location.z1- The Z coordinate (up/down) of the first location.z2- The position on the Z axis (up/down) of the second location.- Returns:
 - The distance as a highly precise number.
 
 - 
manhattan
 - 
manhattan
public static int manhattan(int x1, int z1, int x2, int z2) Calculates the Manhattan (sometimes referred to as "taxi-cab") distance between two locations, which is the sum of the absolute differences of their X and Z coordinates.
This method only considers horizontal and vertical movements, not diagonal. This is usually the method to use when we want the result in blocks and precision is not required.- Parameters:
 x1- The position on the X axis (left/right) of the first location.z1- The position on the Z axis (up/down) of the first location.x2- The position on the X axis (left/right) of the second location.z2- The position on the Z axis (up/down) of the second location.- See Also:
 
 - 
removeListDuplicates
 - 
collectList
 - 
parallelStreamArr
 - 
strArrHas
 - 
withinRadius
@Contract(pure=true) public static boolean withinRadius(int num, int[] args)  - 
withinRadius
 - 
stringToFullUUID
public static UUID stringToFullUUID(@NotNull @NotNull String uuidStr) throws IllegalArgumentException Ensures aUUIDis full (with hyphens) by inserting them at known points in the string.
If the given string is 36 characters (full uuid), it will use that one without inserting.- Parameters:
 uuidStr- A trimmed or full UUID in string representation.- Returns:
 - A new 
UUIDwith hyphens inserted if not already. - Throws:
 IllegalArgumentException
 
 -