Don't create own random provider if Better Random is present
This commit is contained in:
parent
08ae897c6f
commit
6c0265582a
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user