diff --git a/src/main/java/ganymedes01/etfuturum/core/utils/Utils.java b/src/main/java/ganymedes01/etfuturum/core/utils/Utils.java index 765c6f06..730762a7 100644 --- a/src/main/java/ganymedes01/etfuturum/core/utils/Utils.java +++ b/src/main/java/ganymedes01/etfuturum/core/utils/Utils.java @@ -243,7 +243,7 @@ public static double atan2(double p_181159_0_, double p_181159_2_) { p_181159_0_ = d1; } - double d9 = fastInvSqrt(d0); + double d9 = invSqrt(d0); p_181159_2_ = p_181159_2_ * d9; p_181159_0_ = p_181159_0_ * d9; double d2 = FRAC_BIAS + p_181159_0_; @@ -270,13 +270,12 @@ public static double atan2(double p_181159_0_, double p_181159_2_) { return d8; } - public static double fastInvSqrt(double p_181161_0_) { - double d0 = 0.5D * p_181161_0_; - long i = Double.doubleToRawLongBits(p_181161_0_); - i = 6910469410427058090L - (i >> 1); - p_181161_0_ = Double.longBitsToDouble(i); - p_181161_0_ *= 1.5D - d0 * p_181161_0_ * p_181161_0_; - return p_181161_0_; + public static float invSqrt(float num) { + return 1 / (float) Math.sqrt(num); + } + + public static double invSqrt(double num) { + return 1 / Math.sqrt(num); } public static double perlinFade(double value) { @@ -348,24 +347,6 @@ public static long lfloor(double value) { return value < (double) l ? l - 1L : l; } - public static float fastInverseSqrt(float x) { - float f = 0.5F * x; - int i = Float.floatToIntBits(x); - i = 1597463007 - (i >> 1); - x = Float.intBitsToFloat(i); - x *= 1.5F - f * x * x; - return x; - } - - public static double fastInverseSqrt(double x) { - double d = 0.5D * x; - long l = Double.doubleToRawLongBits(x); - l = 6910469410427058090L - (l >> 1); - x = Double.longBitsToDouble(l); - x *= 1.5D - d * x * x; - return x; - } - public static T getRandom(List list, Random rand) { return list.get(rand.nextInt(list.size())); } diff --git a/src/main/java/ganymedes01/etfuturum/world/generate/feature/WorldGenGeode.java b/src/main/java/ganymedes01/etfuturum/world/generate/feature/WorldGenGeode.java index 0126884d..2e01f9e9 100644 --- a/src/main/java/ganymedes01/etfuturum/world/generate/feature/WorldGenGeode.java +++ b/src/main/java/ganymedes01/etfuturum/world/generate/feature/WorldGenGeode.java @@ -182,13 +182,13 @@ public boolean generate(World world, Random random, int x, int y, int z) { Iterator> var40; Pair pair; - for (var40 = list.iterator(); var40.hasNext(); currentLayerSqrt += Utils.fastInverseSqrt(blockPos3.getSquaredDistance(pair.getLeft()) + (double) pair.getRight()) + t) { + for (var40 = list.iterator(); var40.hasNext(); currentLayerSqrt += Utils.invSqrt(blockPos3.getSquaredDistance(pair.getLeft()) + (double) pair.getRight()) + t) { pair = var40.next(); } //Almost deleted this code for being unused, but the variable in the for loop is vital to later parts of the code. BlockPos blockPos4; Iterator var41; - for (var41 = list2.iterator(); var41.hasNext(); v += Utils.fastInverseSqrt(blockPos3.getSquaredDistance(blockPos4) + (double) crackPointOffset) + t) { + for (var41 = list2.iterator(); var41.hasNext(); v += Utils.invSqrt(blockPos3.getSquaredDistance(blockPos4) + (double) crackPointOffset) + t) { blockPos4 = var41.next(); } //Almost deleted this code for being unused, but the variable in the for loop is vital to later parts of the code. } while (currentLayerSqrt < outerLayerSqrt);