diff --git a/src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java b/src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java index ac4d4e141..7ef475bbd 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java +++ b/src/main/java/ru/dbotthepony/mc/otm/mixin/LevelMixin.java @@ -9,10 +9,13 @@ import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource; @Mixin(Level.class) public abstract class LevelMixin implements IMatteryLevel { - public final RandomSource otm_random = new GJRAND64RandomSource(); + private RandomSource otm_random; @Override public @NotNull RandomSource getOtmRandom() { + if (otm_random == null) + otm_random = new GJRAND64RandomSource(); + return otm_random; } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt index dba505e23..cf0ad7e10 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/IMatteryLevel.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.core import net.minecraft.util.RandomSource import net.minecraft.world.level.Level +import net.neoforged.fml.ModList interface IMatteryLevel { /** @@ -13,4 +14,8 @@ interface IMatteryLevel { val otmRandom: RandomSource } -val Level.otmRandom: RandomSource get() = (this as IMatteryLevel).otmRandom +private val isBetterRandomLoaded by lazy { + ModList.get().isLoaded("better_random") +} + +val Level.otmRandom: RandomSource get() = if (isBetterRandomLoaded) random else (this as IMatteryLevel).otmRandom