Allow to "initialize" xoshiro with zero seed, and provide "raw" initialization
This commit is contained in:
parent
c40f9a2c57
commit
1dd57065c9
@ -6,7 +6,6 @@ import net.minecraft.util.RandomSource
|
|||||||
import net.minecraft.world.level.levelgen.MarsagliaPolarGaussian
|
import net.minecraft.world.level.levelgen.MarsagliaPolarGaussian
|
||||||
import net.minecraft.world.level.levelgen.PositionalRandomFactory
|
import net.minecraft.world.level.levelgen.PositionalRandomFactory
|
||||||
import net.minecraft.world.level.levelgen.RandomSupport
|
import net.minecraft.world.level.levelgen.RandomSupport
|
||||||
import java.lang.StringBuilder
|
|
||||||
import java.util.random.RandomGenerator
|
import java.util.random.RandomGenerator
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,12 +21,12 @@ class Xoshiro256SSRandom private constructor(
|
|||||||
private val gaussian = MarsagliaPolarGaussian(this)
|
private val gaussian = MarsagliaPolarGaussian(this)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
require(
|
if (s0 or s1 or s2 or s3 == 0L) {
|
||||||
s0 != 0L ||
|
s0 = 0x73CF3D83FFF44FF3L
|
||||||
s1 != 0L ||
|
s1 = 0x6412312B70F3CD37L
|
||||||
s2 != 0L ||
|
s2 = -0X6BB4C4E1327BFDCFL
|
||||||
s3 != 0L
|
s3 = -0X4BE0F5BB5F3F5240L
|
||||||
) { "Xoshiro can't operate with seed being entirely zero" }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(s0: Long, s1: Long, s2: Long, s3: Long) : this(s0, s1, s2, s3, null) {
|
constructor(s0: Long, s1: Long, s2: Long, s3: Long) : this(s0, s1, s2, s3, null) {
|
||||||
@ -129,4 +128,11 @@ class Xoshiro256SSRandom private constructor(
|
|||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun raw(s0: Long, s1: Long, s2: Long, s3: Long): Xoshiro256SSRandom {
|
||||||
|
return Xoshiro256SSRandom(s0, s1, s2, s3, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user