Compare commits
4 Commits
436606abf4
...
755d15fc0b
Author | SHA1 | Date | |
---|---|---|---|
755d15fc0b | |||
9ffee79687 | |||
3a08552345 | |||
32fe6e754c |
@ -22,7 +22,7 @@ mixin_version=0.8.5
|
|||||||
neogradle.subsystems.parchment.minecraftVersion=1.21.1
|
neogradle.subsystems.parchment.minecraftVersion=1.21.1
|
||||||
neogradle.subsystems.parchment.mappingsVersion=2024.11.17
|
neogradle.subsystems.parchment.mappingsVersion=2024.11.17
|
||||||
|
|
||||||
kommons_version=3.3.2
|
kommons_version=3.5.2
|
||||||
caffeine_cache_version=3.1.5
|
caffeine_cache_version=3.1.5
|
||||||
|
|
||||||
jei_version=19.16.4.171
|
jei_version=19.16.4.171
|
||||||
|
@ -34,7 +34,7 @@ import ru.dbotthepony.mc.otm.datagen.items.MatteryItemModelProvider
|
|||||||
import ru.dbotthepony.mc.otm.datagen.lang.AddEnglishLanguage
|
import ru.dbotthepony.mc.otm.datagen.lang.AddEnglishLanguage
|
||||||
import ru.dbotthepony.mc.otm.datagen.models.MatteryBlockModelProvider
|
import ru.dbotthepony.mc.otm.datagen.models.MatteryBlockModelProvider
|
||||||
import ru.dbotthepony.mc.otm.core.registryName
|
import ru.dbotthepony.mc.otm.core.registryName
|
||||||
import ru.dbotthepony.mc.otm.core.util.PCG32RandomSource
|
import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource
|
||||||
import ru.dbotthepony.mc.otm.data.FlywheelMaterialDataProvider
|
import ru.dbotthepony.mc.otm.data.FlywheelMaterialDataProvider
|
||||||
import ru.dbotthepony.mc.otm.datagen.advancements.addAdvancements
|
import ru.dbotthepony.mc.otm.datagen.advancements.addAdvancements
|
||||||
import ru.dbotthepony.mc.otm.datagen.advancements.addAndroidAdvancements
|
import ru.dbotthepony.mc.otm.datagen.advancements.addAndroidAdvancements
|
||||||
@ -71,7 +71,7 @@ object DataGen {
|
|||||||
|
|
||||||
// for things which need to be random (e.g. UUIDs),
|
// for things which need to be random (e.g. UUIDs),
|
||||||
// so builds continue to be reproducible
|
// so builds continue to be reproducible
|
||||||
val random = PCG32RandomSource(822393994030754753L)
|
val random = GJRAND64RandomSource(822393940230754753L, -2728812999467395658L)
|
||||||
|
|
||||||
var blockModelProvider: MatteryBlockModelProvider by WriteOnce()
|
var blockModelProvider: MatteryBlockModelProvider by WriteOnce()
|
||||||
private set
|
private set
|
||||||
|
@ -5,11 +5,11 @@ import net.minecraft.world.level.Level;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import ru.dbotthepony.mc.otm.core.IMatteryLevel;
|
import ru.dbotthepony.mc.otm.core.IMatteryLevel;
|
||||||
import ru.dbotthepony.mc.otm.core.util.PCG32RandomSource;
|
import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource;
|
||||||
|
|
||||||
@Mixin(Level.class)
|
@Mixin(Level.class)
|
||||||
public abstract class LevelMixin implements IMatteryLevel {
|
public abstract class LevelMixin implements IMatteryLevel {
|
||||||
public final RandomSource otm_random = new PCG32RandomSource();
|
public final RandomSource otm_random = new GJRAND64RandomSource();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull RandomSource getOtmRandom() {
|
public @NotNull RandomSource getOtmRandom() {
|
||||||
|
@ -21,16 +21,16 @@ import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage
|
|||||||
import ru.dbotthepony.mc.otm.client.minecraft
|
import ru.dbotthepony.mc.otm.client.minecraft
|
||||||
import ru.dbotthepony.mc.otm.core.collect.WeakHashSet
|
import ru.dbotthepony.mc.otm.core.collect.WeakHashSet
|
||||||
import ru.dbotthepony.mc.otm.core.util.AtomicallyInvalidatedLazy
|
import ru.dbotthepony.mc.otm.core.util.AtomicallyInvalidatedLazy
|
||||||
|
import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource
|
||||||
import ru.dbotthepony.mc.otm.core.util.IConditionalTickable
|
import ru.dbotthepony.mc.otm.core.util.IConditionalTickable
|
||||||
import ru.dbotthepony.mc.otm.core.util.ITickable
|
import ru.dbotthepony.mc.otm.core.util.ITickable
|
||||||
import ru.dbotthepony.mc.otm.core.util.PCG32RandomSource
|
|
||||||
import ru.dbotthepony.mc.otm.core.util.TickList
|
import ru.dbotthepony.mc.otm.core.util.TickList
|
||||||
import ru.dbotthepony.mc.otm.graph.GraphNodeList
|
import ru.dbotthepony.mc.otm.graph.GraphNodeList
|
||||||
import java.lang.ref.Cleaner
|
import java.lang.ref.Cleaner
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
private val threadLocalRandom = ThreadLocal.withInitial { PCG32RandomSource() }
|
private val threadLocalRandom = ThreadLocal.withInitial { GJRAND64RandomSource() }
|
||||||
internal val THREAD_LOCAL_RANDOM: RandomSource
|
internal val THREAD_LOCAL_RANDOM: RandomSource
|
||||||
get() = threadLocalRandom.get()
|
get() = threadLocalRandom.get()
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ 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 ru.dbotthepony.kommons.random.LCG64Random
|
import ru.dbotthepony.kommons.random.PCG32Random
|
||||||
import java.lang.StringBuilder
|
import java.lang.StringBuilder
|
||||||
import java.util.random.RandomGenerator
|
import java.util.random.RandomGenerator
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ class CMWCRandom(seed: Long = RandomSupport.generateUniqueSeed()) : RandomGenera
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun setSeed(seed: Long) {
|
override fun setSeed(seed: Long) {
|
||||||
val rng = LCG64Random(seed)
|
val rng = PCG32Random(seed)
|
||||||
|
|
||||||
// init state with regular LCG produced values
|
// init state with regular LCG produced values
|
||||||
for (i in 1 until state.size) {
|
for (i in 1 until state.size) {
|
||||||
@ -92,7 +92,7 @@ class CMWCRandom(seed: Long = RandomSupport.generateUniqueSeed()) : RandomGenera
|
|||||||
return Positional(nextLong())
|
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 {
|
override fun at(x: Int, y: Int, z: Int): RandomSource {
|
||||||
return CMWCRandom(Mth.getSeed(x, y, z).xor(seed))
|
return CMWCRandom(Mth.getSeed(x, y, z).xor(seed))
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.core.util
|
||||||
|
|
||||||
|
import net.minecraft.util.Mth
|
||||||
|
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.GJRAND64Random
|
||||||
|
import java.lang.StringBuilder
|
||||||
|
|
||||||
|
class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator {
|
||||||
|
private val gaussian = MarsagliaPolarGaussian(this)
|
||||||
|
|
||||||
|
constructor() : super(RandomSupport.generateUniqueSeed(), RandomSupport.generateUniqueSeed())
|
||||||
|
constructor(seed: Long) : super(seed)
|
||||||
|
constructor(seed0: Long, seed1: Long) : super(seed0, seed1)
|
||||||
|
|
||||||
|
override fun nextInt(): Int {
|
||||||
|
return nextLong().ushr(32).toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun nextGaussian(): Double {
|
||||||
|
return gaussian.nextGaussian()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fork(): RandomSource {
|
||||||
|
return GJRAND64RandomSource(nextLong(), nextLong())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun forkPositional(): PositionalRandomFactory {
|
||||||
|
return Positional(nextLong(), nextLong())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setSeed(seed: Long) {
|
||||||
|
reinitialize(seed)
|
||||||
|
gaussian.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Positional(private val seed0: Long, private val seed1: Long) : PositionalRandomFactory {
|
||||||
|
override fun at(x: Int, y: Int, z: Int): RandomSource {
|
||||||
|
val seed = Mth.getSeed(x, y, z)
|
||||||
|
return GJRAND64RandomSource(seed0.xor(seed.rotateLeft(32)), seed1.xor(seed))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fromHashOf(name: String): RandomSource {
|
||||||
|
return GJRAND64RandomSource(name.hashCode().toLong().xor(seed0), seed1)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fromSeed(seed: Long): RandomSource {
|
||||||
|
return GJRAND64RandomSource(seed)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun parityConfigString(builder: StringBuilder) {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -39,7 +39,7 @@ class LCG64RandomSource(seed: Long = RandomSupport.generateUniqueSeed()) : LCG64
|
|||||||
return Positional(nextLong())
|
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 {
|
override fun at(x: Int, y: Int, z: Int): RandomSource {
|
||||||
return LCG64RandomSource(Mth.getSeed(x, y, z).xor(seed))
|
return LCG64RandomSource(Mth.getSeed(x, y, z).xor(seed))
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class PCG32RandomSource(seed: Long = RandomSupport.generateUniqueSeed()) : PCG32
|
|||||||
return Positional(nextLong())
|
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 {
|
override fun at(x: Int, y: Int, z: Int): RandomSource {
|
||||||
return PCG32RandomSource(Mth.getSeed(x, y, z).xor(seed))
|
return PCG32RandomSource(Mth.getSeed(x, y, z).xor(seed))
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,10 @@ class Xoshiro256Random : Xoshiro256StarStarRandom, IRandomSourceGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Positional(
|
class Positional(
|
||||||
val s0: Long,
|
private val s0: Long,
|
||||||
val s1: Long,
|
private val s1: Long,
|
||||||
val s2: Long,
|
private val s2: Long,
|
||||||
val s3: Long,
|
private val s3: Long,
|
||||||
) : PositionalRandomFactory {
|
) : PositionalRandomFactory {
|
||||||
override fun at(x: Int, y: Int, z: Int): RandomSource {
|
override fun at(x: Int, y: Int, z: Int): RandomSource {
|
||||||
val rng = LCG64RandomSource(Mth.getSeed(x, y, z))
|
val rng = LCG64RandomSource(Mth.getSeed(x, y, z))
|
||||||
|
@ -44,7 +44,6 @@ import ru.dbotthepony.mc.otm.core.math.set
|
|||||||
import ru.dbotthepony.mc.otm.core.math.writeDecimal
|
import ru.dbotthepony.mc.otm.core.math.writeDecimal
|
||||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||||
import ru.dbotthepony.mc.otm.core.nextUUID
|
import ru.dbotthepony.mc.otm.core.nextUUID
|
||||||
import ru.dbotthepony.mc.otm.core.util.PCG32RandomSource
|
|
||||||
import ru.dbotthepony.mc.otm.core.util.formatPower
|
import ru.dbotthepony.mc.otm.core.util.formatPower
|
||||||
import ru.dbotthepony.mc.otm.isClientThread
|
import ru.dbotthepony.mc.otm.isClientThread
|
||||||
import ru.dbotthepony.mc.otm.isServerThread
|
import ru.dbotthepony.mc.otm.isServerThread
|
||||||
|
Loading…
Reference in New Issue
Block a user