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 recordWrapper around theRandomSourcefor normalRandominstances -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.util.RandomSourceStatic random instance if random numbers without specific seed are desired. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatgetPlaneDistance(int x1, int z1, int x2, int z2) Returns the distance between x1, z1 and x2, z2static doublerandomNumberInRange(double min, double max) Returns a pseudo random number in range of min and max (inclusive).static floatrandomNumberInRange(float min, float max) Returns a pseudo random number in range of min and max (inclusive).static intrandomNumberInRange(int min, int max) Returns a pseudo random number in range of min and max (inclusive).static doublerandomNumberInRange(net.minecraft.util.RandomSource random, double min, double max) Returns a pseudo random number in range of min and max (inclusive).static floatrandomNumberInRange(net.minecraft.util.RandomSource random, float min, float max) Returns a pseudo random number in range of min and max (inclusive).static intrandomNumberInRange(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.Vec3rotateVectorAroundYCC(net.minecraft.world.phys.Vec3 vec, double angle) Rotate a vector counter clock wise around the y axis.static net.minecraft.world.phys.Vec3rotateVectorCC(net.minecraft.world.phys.Vec3 vec, net.minecraft.world.phys.Vec3 axis, double angle) Rotate a vector counter clock wise around an axis.static doublevalueInRange(double min, double max, double value) Returns a value between min and maxstatic floatvalueInRange(float min, float max, float value) Returns a value between min and maxstatic intvalueInRange(int min, int max, int value) Returns a value between min and maxstatic longvalueInRange(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 thisRANDOMinstance- 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 thisRANDOMinstance- 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 thisRANDOMinstance- 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
-