Class MathUtils

java.lang.Object
com.minecolonies.api.util.MathUtils

public final class MathUtils extends Object
Useful math stuff to use statically.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Random
    Static random for global use.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    clamp(int value, int min, int max)
    Clamped a value between a lower and upper bound.
    static double
    square(double number)
    Returns the square product of a number.
    static double
    twoDimDistance(@NotNull net.minecraft.core.BlockPos position, @NotNull net.minecraft.core.BlockPos target)
    Calculates the distance between two points without considering the y-value.

    Methods inherited from class java.lang.Object

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

    • RANDOM

      public static final Random RANDOM
      Static random for global use.
  • Method Details

    • square

      public static double square(double number)
      Returns the square product of a number.
      Parameters:
      number - Number to square.
      Returns:
      Answer of calculation.
    • twoDimDistance

      public static double twoDimDistance(@NotNull @NotNull net.minecraft.core.BlockPos position, @NotNull @NotNull net.minecraft.core.BlockPos target)
      Calculates the distance between two points without considering the y-value.
      Parameters:
      position - the start position.
      target - the end position.
      Returns:
      the distance.
    • clamp

      public static int clamp(int value, int min, int max)
      Clamped a value between a lower and upper bound.
      Parameters:
      value - the input value to clamp.
      min - the lower bound.
      max - the upper bound.
      Returns:
      the value, clamped between the lower and upper bound.