0

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.

Dkaloger
  • 71
  • 1
  • 4
  • "*How does Math.Random in Java create random numbers*" - [Why not take a look at the source code](http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/tip/src/share/classes/java/util/Random.java)? – Turing85 Aug 11 '20 at 16:09

1 Answers1

1
  1. Math.random calls an object of type Random, Source

  2. nextDouble is called, Source

  3. nextDouble is implemented like this:

public double nextDouble() {
   return (((long)(next(26)) << 27) + next(27)) * DOUBLE_UNIT;
}

Source

DOUBLE_UNIT is private static final double DOUBLE_UNIT = 0x1.0p-53; // 1.0 / (1L << 53) Source.

  1. 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));
}

Source

As you can see, it's a

linear congruential pseudorandom number generator