Replace WorldgenRandom prng with gjrand
This commit is contained in:
parent
161df68b38
commit
6daa32ddb7
@ -34,7 +34,7 @@ mod_name=Better Random
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=BSD 2 Clause
|
mod_license=BSD 2 Clause
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.1.0
|
mod_version=1.2.0
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package ru.dbotthepony.mc.prng;
|
package ru.dbotthepony.mc.prng;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
|
|
||||||
@Mod(BetterRandom.MOD_ID)
|
@Mod(BetterRandom.MOD_ID)
|
||||||
|
@ -3,11 +3,33 @@ package ru.dbotthepony.mc.prng.mixin;
|
|||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||||
|
import net.minecraft.world.level.levelgen.XoroshiroRandomSource;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import ru.dbotthepony.mc.prng.GJRAND64RandomSource;
|
||||||
|
|
||||||
@Mixin(WorldgenRandom.class)
|
@Mixin(WorldgenRandom.class)
|
||||||
public abstract class WorldgenRandomMixin {
|
public abstract class WorldgenRandomMixin {
|
||||||
|
@Shadow
|
||||||
|
protected RandomSource randomSource;
|
||||||
|
|
||||||
|
// quite lazy solution because if someone genuinely want to get lcg they wont be able to
|
||||||
|
@Inject(
|
||||||
|
method = "<init>(Lnet/minecraft/util/RandomSource;)V",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
public void constructorMix(RandomSource randomSource, CallbackInfo info) {
|
||||||
|
if (randomSource instanceof LegacyRandomSource rng) {
|
||||||
|
this.randomSource = new GJRAND64RandomSource(rng.seed.get());
|
||||||
|
} else if (randomSource instanceof XoroshiroRandomSource rng) {
|
||||||
|
this.randomSource = new GJRAND64RandomSource(rng.randomNumberGenerator.seedHi, rng.randomNumberGenerator.seedLo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public static RandomSource seedSlimeChunk(int chunkX, int chunkZ, long levelSeed, long salt) {
|
public static RandomSource seedSlimeChunk(int chunkX, int chunkZ, long levelSeed, long salt) {
|
||||||
return new LegacyRandomSource(
|
return new LegacyRandomSource(
|
||||||
|
@ -5,3 +5,9 @@ protected net.minecraft.world.RandomSequences includeWorldSeed
|
|||||||
protected net.minecraft.world.RandomSequences includeSequenceId
|
protected net.minecraft.world.RandomSequences includeSequenceId
|
||||||
public net.minecraft.world.RandomSequences$DirtyMarkingRandomSource
|
public net.minecraft.world.RandomSequences$DirtyMarkingRandomSource
|
||||||
public net.minecraft.world.RandomSequences$DirtyMarkingRandomSource <init>(Lnet/minecraft/world/RandomSequences;Lnet/minecraft/util/RandomSource;)V
|
public net.minecraft.world.RandomSequences$DirtyMarkingRandomSource <init>(Lnet/minecraft/world/RandomSequences;Lnet/minecraft/util/RandomSource;)V
|
||||||
|
|
||||||
|
protected-f net.minecraft.world.level.levelgen.WorldgenRandom randomSource
|
||||||
|
public net.minecraft.world.level.levelgen.LegacyRandomSource seed
|
||||||
|
public net.minecraft.world.level.levelgen.XoroshiroRandomSource randomNumberGenerator
|
||||||
|
public net.minecraft.world.level.levelgen.Xoroshiro128PlusPlus seedLo
|
||||||
|
public net.minecraft.world.level.levelgen.Xoroshiro128PlusPlus seedHi
|
||||||
|
Loading…
Reference in New Issue
Block a user