From 2855aaffb538f5dae1fcbbbd051bfb4e3a5951c8 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 1 Nov 2018 14:58:08 +0000 Subject: + Added new Radioactive ore. + Added Custom Nuclear Texture Set. % More material work. $ Fixed issue allowing Multiblocks to have > 1 Control Core Hatch. $ Fixed Broken Ore texture for ENRICHED TextureSet. $ Fixed a few fluid recipes broken in the refactor. --- src/Java/gtPlusPlus/core/util/math/MathUtils.java | 270 ++++++++++++++++++---- 1 file changed, 228 insertions(+), 42 deletions(-) (limited to 'src/Java/gtPlusPlus/core/util/math') diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 48d56b3aa8..40ac23a1b8 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -127,7 +127,7 @@ public class MathUtils { public static double findPercentage(final double current, final double max){ return Math.round(((current / max) * 100) * 100.00) / 100.00; } - + public static int findPercentageOfInt(long input, float percentage){ return (int)(input*(percentage/100.0f)); } @@ -185,20 +185,20 @@ public class MathUtils { } return result; } - - + + //Smooth Rounding Function - /** - * Returns a long. - * The returned number is d rounded to the nearest flat long. - * Supports Doubles as input. - * - * @param current Current value. - * @return long Rounded value. - */ - public static long roundToClosestLong(final double d) { - return (long) (Math.round(d * 2) / 2.0); - } + /** + * Returns a long. + * The returned number is d rounded to the nearest flat long. + * Supports Doubles as input. + * + * @param current Current value. + * @return long Rounded value. + */ + public static long roundToClosestLong(final double d) { + return (long) (Math.round(d * 2) / 2.0); + } /** @@ -360,11 +360,11 @@ public class MathUtils { public static byte safeByte(long number){ return number>Byte.MAX_VALUE ? Byte.MAX_VALUE :(byte)number; } - + public static short safeShort(long number){ return number>Short.MAX_VALUE ? Short.MAX_VALUE :(short)number; } - + public static int safeInt(long number, int margin){ return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number; } @@ -381,65 +381,74 @@ public class MathUtils { mLargeChanceArray[g] = mValues[mValueSelection]; } return mLargeChanceArray[randInt(0, mLargeChanceArray.length-1)]; - + } - - + + /* * Averages */ - - public static byte getByteAverage(AutoMap aDataSet) { + + public static byte getByteAverage(AutoMap aDataSet) { byte[] aNewSet = new byte[aDataSet.size()]; for (int u=0;u aDataSet) { short[] aNewSet = new short[aDataSet.size()]; for (int u=0;u aDataSet) { int[] aNewSet = new int[aDataSet.size()]; for (int u=0;u aDataSet) { float[] aNewSet = new float[aDataSet.size()]; for (int u=0;u aDataSet) { long[] aNewSet = new long[aDataSet.size()]; for (int u=0;u aDataSet) { double[] aNewSet = new double[aDataSet.size()]; for (int u=0;u 0) { + return -aPositive; + } + else if (aPositive < 0) { + return +aPositive; + } + else { + return 0; + } + } + + public static V safeCast(Object aNumberType) { + long a1; + double a2; + a1 = Long.parseLong(aNumberType.toString()); + a2 = Double.parseDouble(aNumberType.toString()); + + if ((aNumberType.getClass() == byte.class) || (aNumberType instanceof Byte)){ + if (a1 >= Byte.MIN_VALUE && a1 <= Byte.MAX_VALUE) { + String s = ""+a1; + Byte s1 = Byte.valueOf(s); + return (V) s1; + } + } + else if ((aNumberType.getClass() == short.class) || (aNumberType instanceof Short)){ + if (a1 >= Short.MIN_VALUE && a1 <= Short.MAX_VALUE) { + String s = ""+a1; + Short s1 = Short.valueOf(s); + return (V) s1; + + } + } + else if ((aNumberType.getClass() == int.class) || (aNumberType instanceof Integer)){ + if (a1 >= Integer.MIN_VALUE && a1 <= Integer.MAX_VALUE) { + String s = ""+a1; + Integer s1 = Integer.valueOf(s); + return (V) s1; + + } + } + else if ((aNumberType.getClass() == long.class) || (aNumberType instanceof Long)){ + if (a1 >= Long.MIN_VALUE && a1 <= Long.MAX_VALUE) { + String s = ""+a1; + Long s1 = Long.valueOf(s); + return (V) s1; + } + } + else if ((aNumberType.getClass() == float.class) || (aNumberType instanceof Float)){ + if (a2 >= Float.MIN_VALUE && a2 <= Float.MAX_VALUE) { + String s = ""+a1; + Float s1 = Float.valueOf(s); + return (V) s1; + + } + } + else if ((aNumberType.getClass() == double.class) || (aNumberType instanceof Double)){ + if (a2 >= Double.MIN_VALUE && a2 <= Double.MAX_VALUE) { + String s = ""+a1; + Double s1 = Double.valueOf(s); + return (V) s1; + + } + } + + Integer o = 0; + return (V) o; + + } + + public static byte getSafeByte(Byte b) { + Byte a = safeCast(b); + return a.byteValue(); + } + + public static short getSafeShort(Short b) { + Short a = safeCast(b); + return a.shortValue(); + } + + public static int getSafeInt(Integer b) { + Integer a = safeCast(b); + return a.intValue(); + } + + public static long getSafeLong(Long b) { + Long a = safeCast(b); + return a.longValue(); + } + + public static float getSafeFloat(Float b) { + Float a = safeCast(b); + return a.floatValue(); + } + + public static double getSafeDouble(Double b) { + Double a = safeCast(b); + return a.doubleValue(); + } + + + public static long safeCast_IntToLong(int o) { + long i = o; + return i; + } + + public static int safeCast_LongToInt(long o) { + if (o > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } + else { + int i = (int) o; + return i; + } + } + + public static short safeCast_IntToShort(int o) { + if (o > Short.MAX_VALUE) { + return Short.MAX_VALUE; + } + else { + short i = (short) o; + return i; + } + } + + public static int safeCast_ShortToInt(short o) { + int i = (int) o; + return i; + } + + public static byte safeCast_ShortToByte(short o) { + if (o > Byte.MAX_VALUE) { + return Byte.MAX_VALUE; + } + else { + byte i = (byte) o; + return i; + } + } + + public static short safeCast_ByteToshort(byte o) { + short i = (short) o; + return i; + } + } -- cgit