Package net.risingworld.api.utils
Class Utils.GeneralUtils
java.lang.Object
net.risingworld.api.utils.Utils.GeneralUtils
- Enclosing class:
Utils
General game related functions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
celsiusToFahrenheit
(float celsius) Converts a celsius temperature to fahrenheit.static int
colorRGBAToInt
(float r, float g, float b, float a) Converts a color (RGBA) to int.static float
fahrenheitToCelsius
(float fahrenheit) Converts a fahrenheit temperature to celsius.static String
getFormattedTimeAndDate
(long timeInMillis) static long
static float
intToColorA
(int color) Converts an int value into an RGBA color and returns the alpha value.static float
intToColorB
(int color) Converts an int value into an RGBA color and returns the blue color value.static float
intToColorG
(int color) Converts an int value into an RGBA color and returns the green color value.static float
intToColorR
(int color) Converts an int value into an RGBA color and returns the red color value.static int
nextRandomColor
(boolean alpha)
-
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
-
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
-
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.
-