Class Utils.GeneralUtils

java.lang.Object
net.risingworld.api.utils.Utils.GeneralUtils
Enclosing class:
Utils

public abstract static class Utils.GeneralUtils extends Object
General game related functions.
  • Constructor Details

    • GeneralUtils

      public GeneralUtils()
  • Method Details

    • colorRGBAToInt

      public static int colorRGBAToInt(float r, float g, float b, float a)
      Converts a color (RGBA) to int.
      Parameters:
      r - the red value (0-1)
      g - the green value (0-1)
      b - the blue value (0-1)
      a - the alpha value (0-1)
      Returns:
      an int representing the RGBA color.
      Example: Convert an RGBA color to an int and vice versa
      1//Example: orange color (R: 1.0f, G: 0.5f, B: 0.0f, A: 1.0f)
      2int color = Utils.GeneralUtils.colorRGBAToInt(1.0f, 0.5f, 0.0f, 1.0f);
      3System.out.println("Int color: " + color);
      4float red = Utils.GeneralUtils.intToColorR(color);
      5float green = Utils.GeneralUtils.intToColorG(color);
      6float blue = Utils.GeneralUtils.intToColorB(color);
      7float alpha = Utils.GeneralUtils.intToColorA(color);
      8System.out.println("Color: " + red + " " + green + " " + blue + " " + alpha);
    • intToColorR

      public static float intToColorR(int color)
      Converts an int value into an RGBA color and returns the red color value.
      Parameters:
      color - the int color value.
      Returns:
      the red color value.
    • intToColorG

      public static float intToColorG(int color)
      Converts an int value into an RGBA color and returns the green color value.
      Parameters:
      color - the int color value.
      Returns:
      the green color value.
    • intToColorB

      public static float intToColorB(int color)
      Converts an int value into an RGBA color and returns the blue color value.
      Parameters:
      color - the int color value.
      Returns:
      the blue color value.
    • intToColorA

      public static float intToColorA(int color)
      Converts an int value into an RGBA color and returns the alpha value.
      Parameters:
      color - the int color value.
      Returns:
      the alpha value.
    • nextRandomColor

      public static int nextRandomColor(boolean alpha)
    • getFormattedTimeAndDate

      public static String getFormattedTimeAndDate(long timeInMillis)
    • getUnixTimestamp

      public static long getUnixTimestamp()
    • celsiusToFahrenheit

      public static float celsiusToFahrenheit(float celsius)
      Converts a celsius temperature to fahrenheit.
      Parameters:
      celsius - the temperature in celsius.
      Returns:
      the temperature in fahrenheit.
    • fahrenheitToCelsius

      public static float fahrenheitToCelsius(float fahrenheit)
      Converts a fahrenheit temperature to celsius.
      Parameters:
      fahrenheit - the temperature in fahrenheit.
      Returns:
      the temperature in celsius.