aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/math
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2017-03-18 12:09:58 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2017-03-18 12:09:58 +1000
commit435eec1dfe0aec63d22875fb2189e69d2b1fa999 (patch)
tree10861db62cde2482869b75ded13df3e3c4eba9cb /src/Java/gtPlusPlus/core/util/math
parent776f96df847e2337549d4298d51015aff4d0c0d9 (diff)
downloadGT5-Unofficial-435eec1dfe0aec63d22875fb2189e69d2b1fa999.tar.gz
GT5-Unofficial-435eec1dfe0aec63d22875fb2189e69d2b1fa999.tar.bz2
GT5-Unofficial-435eec1dfe0aec63d22875fb2189e69d2b1fa999.zip
+ Added a delay to the mod update message upon login, so it's easier to see.
+ Added more Smoke and visual FX to the Primed Mining Explosives explosion. % Tweaked Primed Mining Explosive Renderer. + Added a randFloat to MathUtils.java.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/math')
-rw-r--r--src/Java/gtPlusPlus/core/util/math/MathUtils.java37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java
index 3c04266f38..7ed15ec27b 100644
--- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java
+++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java
@@ -4,6 +4,7 @@ import java.util.Map;
import java.util.Random;
import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.xmod.gregtech.api.objects.XSTR;
public class MathUtils {
@@ -20,7 +21,7 @@ public class MathUtils {
public static int randInt(final int min, final int max) {
// Usually this can be a field rather than a method variable
- final Random rand = new Random();
+ final Random rand = new XSTR();
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
@@ -47,7 +48,7 @@ public class MathUtils {
*/
public static long randLong(final long min, final long max) {
// Usually this can be a field rather than a method variable
- final Random rand = new Random();
+ final Random rand = new XSTR();
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
@@ -78,7 +79,7 @@ public class MathUtils {
*/
public static double randDouble(final double min, final double max) {
// Usually this can be a field rather than a method variable
- final Random rand = new Random();
+ final Random rand = new XSTR();
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
@@ -95,6 +96,36 @@ public class MathUtils {
} while (((bits-val)+(n-1)) < 0L);
return val;
}
+
+ /**
+ * Returns a psuedo-random number between min and max, inclusive.
+ * The difference between min and max can be at most
+ * Float.MAX_VALUE - 1.
+ *
+ * @param min Minimim value
+ * @param max Maximim value. Must be greater than min.
+ * @return Float between min and max, inclusive.
+ * @see java.util.Random#nextFloat(float)
+ */
+ public static float randFloat(final float min, final float max) {
+ // Usually this can be a field rather than a method variable
+ final Random rand = new XSTR();
+
+ // nextInt is normally exclusive of the top value,
+ // so add 1 to make it inclusive
+ final float randomNum = MathUtils.nextFloat(rand,(max - min) + 1) + min;
+ return randomNum;
+ }
+
+ private static float nextFloat(final Random rng, final float n) {
+ // error checking and 2^x checking removed for simplicity.
+ float bits, val;
+ do {
+ bits = (rng.nextLong() << 1) >>> 1;
+ val = bits % n;
+ } while (((bits-val)+(n-1)) < 0L);
+ return val;
+ }
/**