ooprs!!1
This commit is contained in:
parent
9836fa0088
commit
60cbe70041
@ -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.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=BSD 2 Clause
|
mod_license=BSD 2 Clause
|
||||||
# The mod version. See https://semver.org/
|
# 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.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
@ -73,10 +73,25 @@ public class GJRAND64RandomSource implements RandomGenerator, RandomSource {
|
|||||||
s3 = 0L;
|
s3 = 0L;
|
||||||
|
|
||||||
for (int i = 0; i < 14; i++) {
|
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
|
@Override
|
||||||
public @NotNull RandomSource fork() {
|
public @NotNull RandomSource fork() {
|
||||||
return new GJRAND64RandomSource(nextLong(), nextLong());
|
return new GJRAND64RandomSource(nextLong(), nextLong());
|
||||||
@ -147,18 +162,7 @@ public class GJRAND64RandomSource implements RandomGenerator, RandomSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long nextLong() {
|
public long nextLong() {
|
||||||
s1 += s2;
|
return round();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Positional implements PositionalRandomFactory {
|
public static class Positional implements PositionalRandomFactory {
|
||||||
|
@ -31,7 +31,7 @@ public class SynchronizedGJRAND64RandomSource extends GJRAND64RandomSource {
|
|||||||
@Override
|
@Override
|
||||||
public long nextLong() {
|
public long nextLong() {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
long result = super.nextLong();
|
long result = super.round();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user