Attach CMWC random to Level class, as alternative random to be used in OTM
This commit is contained in:
parent
32ef2911fa
commit
bc2c531e1f
18
src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java
Normal file
18
src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.util.RandomSource;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import ru.dbotthepony.mc.otm.core.IMatteryWorld;
|
||||||
|
import ru.dbotthepony.mc.otm.core.util.CMWCRandom;
|
||||||
|
|
||||||
|
@Mixin(Level.class)
|
||||||
|
public abstract class LevelMixin implements IMatteryWorld {
|
||||||
|
public final RandomSource otm_random = new CMWCRandom();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull RandomSource getOtmRandom() {
|
||||||
|
return otm_random;
|
||||||
|
}
|
||||||
|
}
|
16
src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryWorld.kt
Normal file
16
src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryWorld.kt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.core
|
||||||
|
|
||||||
|
import net.minecraft.util.RandomSource
|
||||||
|
import net.minecraft.world.level.Level
|
||||||
|
|
||||||
|
interface IMatteryWorld {
|
||||||
|
/**
|
||||||
|
* OTM provided [RandomSource], which has better statistical parameters
|
||||||
|
*
|
||||||
|
* Original Minecraft use LCG, which may show bad behavior when repeatedly sampled *a lot*,
|
||||||
|
* which is what [Level]'s random is used for. OTM provided PRNG should behave better in this scenario.
|
||||||
|
*/
|
||||||
|
val otmRandom: RandomSource
|
||||||
|
}
|
||||||
|
|
||||||
|
val Level.otmRandom: RandomSource get() = (this as IMatteryWorld).otmRandom
|
@ -18,7 +18,8 @@
|
|||||||
"HopperBlockEntityMixin",
|
"HopperBlockEntityMixin",
|
||||||
"DispenserBlockEntityMixin",
|
"DispenserBlockEntityMixin",
|
||||||
"GuiGraphicsMixin",
|
"GuiGraphicsMixin",
|
||||||
"BlockStateBaseMixin"
|
"BlockStateBaseMixin",
|
||||||
|
"LevelMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"MixinGameRenderer",
|
"MixinGameRenderer",
|
||||||
|
Loading…
Reference in New Issue
Block a user