diff --git a/gradle.properties b/gradle.properties index 3ebbe27..dd317ad 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.2 +mod_version=1.3.3 # 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 c91f48c..532d195 100644 --- a/src/main/java/ru/dbotthepony/mc/prng/GJRAND64RandomSource.java +++ b/src/main/java/ru/dbotthepony/mc/prng/GJRAND64RandomSource.java @@ -73,10 +73,25 @@ public class GJRAND64RandomSource implements RandomGenerator, RandomSource { s3 = 0L; for (int i = 0; i < 14; i++) { - nextLong(); + round(); } } + protected final long round() { + s1 += s2; + s0 = Long.rotateLeft(s0, 32); + s2 ^= s1; + s3 += 0x55aa96a5L; + s0 += s1; + s2 = Long.rotateLeft(s2, 23); + s1 ^= s0; + s0 += s2; + s1 = Long.rotateLeft(s1, 19); + s2 += s0; + s1 += s3; + return s0; + } + @Override public @NotNull RandomSource fork() { return new GJRAND64RandomSource(nextLong(), nextLong()); @@ -147,18 +162,7 @@ public class GJRAND64RandomSource implements RandomGenerator, RandomSource { @Override public long nextLong() { - s1 += s2; - s0 = Long.rotateLeft(s0, 32); - s2 ^= s1; - s3 += 0x55aa96a5L; - s0 += s1; - s2 = Long.rotateLeft(s2, 23); - s1 ^= s0; - s0 += s2; - s1 = Long.rotateLeft(s1, 19); - s2 += s0; - s1 += s3; - return s0; + return round(); } public static class Positional implements PositionalRandomFactory { diff --git a/src/main/java/ru/dbotthepony/mc/prng/SynchronizedGJRAND64RandomSource.java b/src/main/java/ru/dbotthepony/mc/prng/SynchronizedGJRAND64RandomSource.java index d075e79..6644c20 100644 --- a/src/main/java/ru/dbotthepony/mc/prng/SynchronizedGJRAND64RandomSource.java +++ b/src/main/java/ru/dbotthepony/mc/prng/SynchronizedGJRAND64RandomSource.java @@ -31,7 +31,7 @@ public class SynchronizedGJRAND64RandomSource extends GJRAND64RandomSource { @Override public long nextLong() { lock.lock(); - long result = super.nextLong(); + long result = super.round(); lock.unlock(); return result; }