diff --git a/gradle.properties b/gradle.properties index 9072bcb..fd25b82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,7 +34,7 @@ mod_name=Better Random # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=BSD 2 Clause # The mod version. See https://semver.org/ -mod_version=1.3.4 +mod_version=1.3.5 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/ru/dbotthepony/mc/prng/GJRAND64RandomSource.java b/src/main/java/ru/dbotthepony/mc/prng/GJRAND64RandomSource.java index 532d195..5b71a75 100644 --- a/src/main/java/ru/dbotthepony/mc/prng/GJRAND64RandomSource.java +++ b/src/main/java/ru/dbotthepony/mc/prng/GJRAND64RandomSource.java @@ -17,9 +17,7 @@ public class GJRAND64RandomSource implements RandomGenerator, RandomSource { Codec.LONG.fieldOf("s0").forGetter(o -> o.s0), Codec.LONG.fieldOf("s1").forGetter(o -> o.s1), Codec.LONG.fieldOf("s2").forGetter(o -> o.s2), - Codec.LONG.fieldOf("s3").forGetter(o -> o.s3), - Codec.DOUBLE.fieldOf("nextNextGaussian").forGetter(o -> o.nextNextGaussian), - Codec.BOOL.fieldOf("haveNextNextGaussian").forGetter(o -> o.haveNextNextGaussian) + Codec.LONG.fieldOf("s3").forGetter(o -> o.s3) ).apply(it, GJRAND64RandomSource::new); }); @@ -27,23 +25,17 @@ public class GJRAND64RandomSource implements RandomGenerator, RandomSource { private long s1; private long s2; private long s3; - private double nextNextGaussian; - private boolean haveNextNextGaussian; private GJRAND64RandomSource( long s0, long s1, long s2, - long s3, - double nextNextGaussian, - boolean haveNextNextGaussian + long s3 ) { this.s0 = s0; this.s1 = s1; this.s2 = s2; this.s3 = s3; - this.nextNextGaussian = nextNextGaussian; - this.haveNextNextGaussian = haveNextNextGaussian; } public GJRAND64RandomSource() { @@ -105,7 +97,6 @@ public class GJRAND64RandomSource implements RandomGenerator, RandomSource { @Override public void setSeed(long l) { reinitialize(l); - haveNextNextGaussian = false; } @Override @@ -140,24 +131,7 @@ public class GJRAND64RandomSource implements RandomGenerator, RandomSource { @Override public double nextGaussian() { - if (this.haveNextNextGaussian) { - this.haveNextNextGaussian = false; - return this.nextNextGaussian; - } else { - double d0; - double d1; - double d2; - do { - d0 = 2.0 * nextDouble() - 1.0; - d1 = 2.0 * nextDouble() - 1.0; - d2 = Mth.square(d0) + Mth.square(d1); - } while (d2 >= 1.0 || d2 == 0.0); - - double d3 = Math.sqrt(-2.0 * Math.log(d2) / d2); - this.nextNextGaussian = d1 * d3; - this.haveNextNextGaussian = true; - return d0 * d3; - } + return RandomGenerator.super.nextGaussian(); } @Override