I was wandering how I can create my own random number generator for reverse engineering mc seeds by setting starting conditions such as time .thank you in advance.
Asked
Active
Viewed 183 times
1 Answers
1
Math.random calls an object of type Random, Source
nextDouble
is called, SourcenextDouble
is implemented like this:
public double nextDouble() {
return (((long)(next(26)) << 27) + next(27)) * DOUBLE_UNIT;
}
DOUBLE_UNIT is private static final double DOUBLE_UNIT = 0x1.0p-53; // 1.0 / (1L << 53) Source.
next
is implemented like this:
protected int next(int bits) {
long oldseed, nextseed;
AtomicLong seed = this.seed;
do {
oldseed = seed.get();
nextseed = (oldseed * multiplier + addend) & mask;
} while (!seed.compareAndSet(oldseed, nextseed));
return (int)(nextseed >>> (48 - bits));
}
As you can see, it's a
linear congruential pseudorandom number generator