Xoroshiro128PlusPlus .java

net.minecraft.world.level.levelgen.Xoroshiro128PlusPlus (class, 36 lines): members: seedHi, seedLo, nextLong, CODEC. imports: Util.

net.minecraft.world.level.levelgenclass36 linescommon1.0 KB

API Surface (1)

long nextLong()

Fields & Constants (3)

CODEC
seedLo
seedHi

Code Graph: Dependencies (2)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

Xoroshiro128PlusPlus.java36 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen;
2
3
import com.mojang.serialization.Codec;
4
import java.util.stream.LongStream;
5
import net.minecraft.util.Util;
6
7
public class Xoroshiro128PlusPlus {
8
	private long seedLo;
9
	private long seedHi;
10
	public static final Codec<Xoroshiro128PlusPlus> CODEC = Codec.LONG_STREAM
11
		.comapFlatMap(seed -> Util.fixedSize(seed, 2).map(longs -> new Xoroshiro128PlusPlus(longs[0], longs[1])), r -> LongStream.of(r.seedLo, r.seedHi));
12
13
	public Xoroshiro128PlusPlus(final RandomSupport.Seed128bit seed) {
14
		this(seed.seedLo(), seed.seedHi());
15
	}
16
17
	public Xoroshiro128PlusPlus(final long seedLo, final long seedHi) {
18
		this.seedLo = seedLo;
19
		this.seedHi = seedHi;
20
		if ((this.seedLo | this.seedHi) == 0L) {
21
			this.seedLo = -7046029254386353131L;
22
			this.seedHi = 7640891576956012809L;
23
		}
24
	}
25
26
	public long nextLong() {
27
		long s0 = this.seedLo;
28
		long s1 = this.seedHi;
29
		long result = Long.rotateLeft(s0 + s1, 17) + s0;
30
		s1 ^= s0;
31
		this.seedLo = Long.rotateLeft(s0, 49) ^ s1 ^ s1 << 21;
32
		this.seedHi = Long.rotateLeft(s1, 28);
33
		return result;
34
	}
35
}
36

Decompiled Minecraft 26.3 source of Xoroshiro128PlusPlus (net/minecraft/world/level/levelgen/Xoroshiro128PlusPlus.java) with Mojang official mappings, stored verbatim on the site.