From 3a08552345236bf6fe9db69323f552fca1348af4 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Mar 2025 21:29:43 +0700 Subject: [PATCH] private the internal state of positional random --- .../kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt | 6 +++--- .../ru/dbotthepony/mc/otm/core/util/LCG64RandomSource.kt | 2 +- .../ru/dbotthepony/mc/otm/core/util/PCG32RandomSource.kt | 2 +- .../ru/dbotthepony/mc/otm/core/util/Xoshiro256Random.kt | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt index c2891df03..16225f78f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/CMWCRandom.kt @@ -5,7 +5,7 @@ import net.minecraft.util.RandomSource import net.minecraft.world.level.levelgen.MarsagliaPolarGaussian import net.minecraft.world.level.levelgen.PositionalRandomFactory import net.minecraft.world.level.levelgen.RandomSupport -import ru.dbotthepony.kommons.random.LCG64Random +import ru.dbotthepony.kommons.random.PCG32Random import java.lang.StringBuilder import java.util.random.RandomGenerator @@ -23,7 +23,7 @@ class CMWCRandom(seed: Long = RandomSupport.generateUniqueSeed()) : RandomGenera } override fun setSeed(seed: Long) { - val rng = LCG64Random(seed) + val rng = PCG32Random(seed) // init state with regular LCG produced values for (i in 1 until state.size) { @@ -92,7 +92,7 @@ class CMWCRandom(seed: Long = RandomSupport.generateUniqueSeed()) : RandomGenera return Positional(nextLong()) } - class Positional(val seed: Long) : PositionalRandomFactory { + class Positional(private val seed: Long) : PositionalRandomFactory { override fun at(x: Int, y: Int, z: Int): RandomSource { return CMWCRandom(Mth.getSeed(x, y, z).xor(seed)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/LCG64RandomSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/LCG64RandomSource.kt index 60f07343c..849e38e87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/LCG64RandomSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/LCG64RandomSource.kt @@ -39,7 +39,7 @@ class LCG64RandomSource(seed: Long = RandomSupport.generateUniqueSeed()) : LCG64 return Positional(nextLong()) } - class Positional(val seed: Long) : PositionalRandomFactory { + class Positional(private val seed: Long) : PositionalRandomFactory { override fun at(x: Int, y: Int, z: Int): RandomSource { return LCG64RandomSource(Mth.getSeed(x, y, z).xor(seed)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/PCG32RandomSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/PCG32RandomSource.kt index 7b721c195..ae2f74205 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/PCG32RandomSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/PCG32RandomSource.kt @@ -31,7 +31,7 @@ class PCG32RandomSource(seed: Long = RandomSupport.generateUniqueSeed()) : PCG32 return Positional(nextLong()) } - class Positional(val seed: Long) : PositionalRandomFactory { + class Positional(private val seed: Long) : PositionalRandomFactory { override fun at(x: Int, y: Int, z: Int): RandomSource { return PCG32RandomSource(Mth.getSeed(x, y, z).xor(seed)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Xoshiro256Random.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Xoshiro256Random.kt index 5d1e2ee28..133762f55 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Xoshiro256Random.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/Xoshiro256Random.kt @@ -55,10 +55,10 @@ class Xoshiro256Random : Xoshiro256StarStarRandom, IRandomSourceGenerator { } class Positional( - val s0: Long, - val s1: Long, - val s2: Long, - val s3: Long, + private val s0: Long, + private val s1: Long, + private val s2: Long, + private val s3: Long, ) : PositionalRandomFactory { override fun at(x: Int, y: Int, z: Int): RandomSource { val rng = LCG64RandomSource(Mth.getSeed(x, y, z))