Class MathUtil

java.lang.Object
info.u_team.u_team_core.util.MathUtil

public class MathUtil extends Object
Utility methods for math
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Wrapper around the RandomSource for normal Random instances
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.util.RandomSource
    Static random instance if random numbers without specific seed are desired.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    getPlaneDistance(int x1, int z1, int x2, int z2)
    Returns the distance between x1, z1 and x2, z2
    static 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 max
    static float
    valueInRange(float min, float max, float value)
    Returns a value between min and max
    static int
    valueInRange(int min, int max, int value)
    Returns a value between min and max
    static long
    valueInRange(long min, long max, long value)
    Returns a value between min and max

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • RANDOM

      public static final net.minecraft.util.RandomSource RANDOM
      Static 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 rotate
      angle - 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 rotate
      axis - Rotation axis
      angle - 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 this RANDOM 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 instance
      min - 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 this RANDOM 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 instance
      min - 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 this RANDOM 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 instance
      min - 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 coordinate
      z1 - First z coordinate
      x2 - Second x coordinate
      z2 - Second z coordinate
      Returns:
      The distance between these two coordinates