Package info.u_team.u_team_core.util
Class MathUtil
java.lang.Object
info.u_team.u_team_core.util.MathUtil
Utility methods for math
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Wrapper around theRandomSource
for normalRandom
instances -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.util.RandomSource
Static random instance if random numbers without specific seed are desired. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic float
getPlaneDistance
(int x1, int z1, int x2, int z2) Returns the distance between x1, z1 and x2, z2static double
randomNumberInRange
(double min, double max) Returns a pseudo random number in range of min and max (inclusive).static float
randomNumberInRange
(float min, float max) Returns a pseudo random number in range of min and max (inclusive).static int
randomNumberInRange
(int min, int max) Returns a pseudo random number in range of min and max (inclusive).static double
randomNumberInRange
(net.minecraft.util.RandomSource random, double min, double max) Returns a pseudo random number in range of min and max (inclusive).static float
randomNumberInRange
(net.minecraft.util.RandomSource random, float min, float max) Returns a pseudo random number in range of min and max (inclusive).static int
randomNumberInRange
(net.minecraft.util.RandomSource random, int min, int max) Returns a pseudo random number in range of min and max (inclusive).static net.minecraft.world.phys.Vec3
rotateVectorAroundYCC
(net.minecraft.world.phys.Vec3 vec, double angle) Rotate a vector counter clock wise around the y axis.static net.minecraft.world.phys.Vec3
rotateVectorCC
(net.minecraft.world.phys.Vec3 vec, net.minecraft.world.phys.Vec3 axis, double angle) Rotate a vector counter clock wise around an axis.static double
valueInRange
(double min, double max, double value) Returns a value between min and maxstatic float
valueInRange
(float min, float max, float value) Returns a value between min and maxstatic int
valueInRange
(int min, int max, int value) Returns a value between min and maxstatic long
valueInRange
(long min, long max, long value) Returns a value between min and max
-
Field Details
-
RANDOM
public static final net.minecraft.util.RandomSource RANDOMStatic random instance if random numbers without specific seed are desired.
-
-
Constructor Details
-
MathUtil
public MathUtil()
-
-
Method Details
-
rotateVectorAroundYCC
public static net.minecraft.world.phys.Vec3 rotateVectorAroundYCC(net.minecraft.world.phys.Vec3 vec, double angle) Rotate a vector counter clock wise around the y axis.- Parameters:
vec
- Vector to rotateangle
- Rotation angle- Returns:
- Rotated vector
-
rotateVectorCC
public static net.minecraft.world.phys.Vec3 rotateVectorCC(net.minecraft.world.phys.Vec3 vec, net.minecraft.world.phys.Vec3 axis, double angle) Rotate a vector counter clock wise around an axis.- Parameters:
vec
- Vector to rotateaxis
- Rotation axisangle
- Rotation angle- Returns:
- Rotated vector
-
randomNumberInRange
public static int randomNumberInRange(int min, int max) Returns a pseudo random number in range of min and max (inclusive). Use thisRANDOM
instance- Parameters:
min
- Minimal value (inclusive)max
- Maximal value (inclusive)- Returns:
- Return a random value between min and max
-
randomNumberInRange
public static int randomNumberInRange(net.minecraft.util.RandomSource random, int min, int max) Returns a pseudo random number in range of min and max (inclusive).- Parameters:
random
- The random instancemin
- Minimal value (inclusive)max
- Maximal value (inclusive)- Returns:
- Return a random value between min and max
-
randomNumberInRange
public static float randomNumberInRange(float min, float max) Returns a pseudo random number in range of min and max (inclusive). Use thisRANDOM
instance- Parameters:
min
- Minimal value (inclusive)max
- Maximal value (inclusive)- Returns:
- Return a random value between min and max
-
randomNumberInRange
public static float randomNumberInRange(net.minecraft.util.RandomSource random, float min, float max) Returns a pseudo random number in range of min and max (inclusive).- Parameters:
random
- The random instancemin
- Minimal value (inclusive)max
- Maximal value (inclusive)- Returns:
- Return a random value between min and max
-
randomNumberInRange
public static double randomNumberInRange(double min, double max) Returns a pseudo random number in range of min and max (inclusive). Use thisRANDOM
instance- Parameters:
min
- Minimal value (inclusive)max
- Maximal value (inclusive)- Returns:
- Return a random value between min and max
-
randomNumberInRange
public static double randomNumberInRange(net.minecraft.util.RandomSource random, double min, double max) Returns a pseudo random number in range of min and max (inclusive).- Parameters:
random
- The random instancemin
- Minimal value (inclusive)max
- Maximal value (inclusive)- Returns:
- Return a random value between min and max
-
valueInRange
public static int valueInRange(int min, int max, int value) Returns a value between min and max- Parameters:
min
- Minimal value (inclusive)max
- Maximal value (inclusive)value
- Value that should be in range- Returns:
- Return a value between min and max
-
valueInRange
public static long valueInRange(long min, long max, long value) Returns a value between min and max- Parameters:
min
- Minimal value (inclusive)max
- Maximal value (inclusive)value
- Value that should be in range- Returns:
- Return a value between min and max
-
valueInRange
public static float valueInRange(float min, float max, float value) Returns a value between min and max- Parameters:
min
- Minimal value (inclusive)max
- Maximal value (inclusive)value
- Value that should be in range- Returns:
- Return a value between min and max
-
valueInRange
public static double valueInRange(double min, double max, double value) Returns a value between min and max- Parameters:
min
- Minimal value (inclusive)max
- Maximal value (inclusive)value
- Value that should be in range- Returns:
- Return a value between min and max
-
getPlaneDistance
public static float getPlaneDistance(int x1, int z1, int x2, int z2) Returns the distance between x1, z1 and x2, z2- Parameters:
x1
- First x coordinatez1
- First z coordinatex2
- Second x coordinatez2
- Second z coordinate- Returns:
- The distance between these two coordinates
-