Class AdvancedMath

java.lang.Object
net.frozenblock.lib.math.api.AdvancedMath

public class AdvancedMath extends Object
Adds more math operations.
Since:
4.0
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    combinations(int n, int r)
     
    static double
    cutCos(double value, double offset, boolean inverse)
     
    static int
    factorial(int n)
     
    static double
    getAngleBetweenXZ(@NotNull net.minecraft.world.phys.Vec3 posA, @NotNull net.minecraft.world.phys.Vec3 posB)
     
    static double
    getAngleFromOriginXZ(@NotNull net.minecraft.world.phys.Vec3 pos)
     
    static int
    greatestCommonDivisor(int a, int b)
    Calculates the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.
    static net.minecraft.core.BlockPos
    offset(net.minecraft.core.BlockPos pos, @NotNull net.minecraft.core.Direction dir, int a)
     
    static net.minecraft.core.BlockPos
    offset(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction dir)
     
    static int
    permutations(int n, int r)
     
    static @NotNull net.minecraft.util.RandomSource
     
    static @NotNull net.minecraft.core.Direction
    randomDir(net.minecraft.core.Direction.Axis axis)
     
    static double
     
    static float
    range(float min, float max, float number)
     
    static @NotNull net.minecraft.world.phys.Vec3
    rotateAboutX(@NotNull net.minecraft.world.phys.Vec3 original, double distanceFrom, double angle)
     
    static @NotNull net.minecraft.world.phys.Vec3
    rotateAboutXZ(@NotNull net.minecraft.world.phys.Vec3 original, double distanceFrom, double angle)
     
    static double @Nullable []
    solveQuadraticEquation(double a, double b, double c)
    Solves a quadratic equation of the form ax^2 + bx + c = 0.
    static boolean
    squareBetween(int x, int z, int between1, int between2)
     
    static int
    waterLevelReduce(int value)
     
    static int
     

    Methods inherited from class java.lang.Object

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

    • AdvancedMath

      public AdvancedMath()
  • Method Details

    • random

      @Contract(" -> new") @NotNull public static @NotNull net.minecraft.util.RandomSource random()
    • range

      public static float range(float min, float max, float number)
    • randomPosNeg

      public static double randomPosNeg()
    • squareBetween

      public static boolean squareBetween(int x, int z, int between1, int between2)
    • offset

      public static net.minecraft.core.BlockPos offset(net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.core.Direction dir, int a)
    • offset

      public static net.minecraft.core.BlockPos offset(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction dir)
    • waterToHollowedProperty

      public static int waterToHollowedProperty(int value)
    • waterLevelReduce

      public static int waterLevelReduce(int value)
    • cutCos

      public static double cutCos(double value, double offset, boolean inverse)
    • factorial

      public static int factorial(int n)
    • permutations

      public static int permutations(int n, int r)
    • combinations

      public static int combinations(int n, int r)
    • solveQuadraticEquation

      public static double @Nullable [] solveQuadraticEquation(double a, double b, double c)
      Solves a quadratic equation of the form ax^2 + bx + c = 0.
      Parameters:
      a - the coefficient of x^2 (must be non-zero)
      b - the coefficient of x
      c - the constant term
      Returns:
      an array containing the real roots of the equation, or null if no real roots exist
      Throws:
      IllegalArgumentException - if a is zero
    • greatestCommonDivisor

      public static int greatestCommonDivisor(int a, int b)
      Calculates the greatest common divisor (GCD) of two numbers using the Euclidean algorithm.
      Parameters:
      a - the first number
      b - the second number
      Returns:
      the GCD of a and b
    • randomDir

      @NotNull public static @NotNull net.minecraft.core.Direction randomDir(@NotNull net.minecraft.core.Direction.Axis axis)
      Parameters:
      axis - The axis that should be used to determine a random direction.
      Returns:
      A random Direction on a specific Direction.Axis.
    • rotateAboutXZ

      @NotNull public static @NotNull net.minecraft.world.phys.Vec3 rotateAboutXZ(@NotNull @NotNull net.minecraft.world.phys.Vec3 original, double distanceFrom, double angle)
    • rotateAboutX

      @NotNull public static @NotNull net.minecraft.world.phys.Vec3 rotateAboutX(@NotNull @NotNull net.minecraft.world.phys.Vec3 original, double distanceFrom, double angle)
    • getAngleFromOriginXZ

      @Contract(pure=true) public static double getAngleFromOriginXZ(@NotNull @NotNull net.minecraft.world.phys.Vec3 pos)
    • getAngleBetweenXZ

      public static double getAngleBetweenXZ(@NotNull @NotNull net.minecraft.world.phys.Vec3 posA, @NotNull @NotNull net.minecraft.world.phys.Vec3 posB)