AEUGH
This commit is contained in:
parent
2b757d5658
commit
9836fa0088
@ -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.3.1
|
mod_version=1.3.2
|
||||||
# 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,15 +1,26 @@
|
|||||||
package ru.dbotthepony.mc.prng.mixin;
|
package ru.dbotthepony.mc.prng.mixin;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
|
import net.minecraft.world.level.storage.WritableLevelData;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
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.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import ru.dbotthepony.mc.prng.BetterRandom;
|
import ru.dbotthepony.mc.prng.BetterRandom;
|
||||||
|
import ru.dbotthepony.mc.prng.GJRAND64RandomSource;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@Mixin(value = Level.class, priority = 10000) // ensure this mixin is applied over other "regular" mixins
|
@Mixin(value = Level.class, priority = 10000) // ensure this mixin is applied over other "regular" mixins
|
||||||
public abstract class LevelMixin {
|
public abstract class LevelMixin {
|
||||||
@ -17,6 +28,8 @@ public abstract class LevelMixin {
|
|||||||
@Final
|
@Final
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
|
||||||
|
// does not work with C2ME, Mixin crashes
|
||||||
|
/*
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "<init>",
|
method = "<init>",
|
||||||
at = @At(
|
at = @At(
|
||||||
@ -27,6 +40,31 @@ public abstract class LevelMixin {
|
|||||||
public RandomSource ensureBetterRandom() {
|
public RandomSource ensureBetterRandom() {
|
||||||
return BetterRandom.createWorldRandom(() -> thread);
|
return BetterRandom.createWorldRandom(() -> thread);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public RandomSource random;
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "<init>(Lnet/minecraft/world/level/storage/WritableLevelData;Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/core/RegistryAccess;Lnet/minecraft/core/Holder;Ljava/util/function/Supplier;ZZJI)V",
|
||||||
|
at = @At("TAIL")
|
||||||
|
)
|
||||||
|
public void constructorMix(
|
||||||
|
WritableLevelData levelData,
|
||||||
|
ResourceKey<Level> dimension,
|
||||||
|
RegistryAccess registryAccess,
|
||||||
|
Holder<DimensionType> dimensionTypeRegistration,
|
||||||
|
Supplier<ProfilerFiller> profiler,
|
||||||
|
boolean isClientSide,
|
||||||
|
boolean isDebug,
|
||||||
|
long biomeZoomSeed,
|
||||||
|
int maxChainedNeighborUpdates,
|
||||||
|
CallbackInfo info
|
||||||
|
) {
|
||||||
|
if (!(this.random instanceof GJRAND64RandomSource))
|
||||||
|
this.random = BetterRandom.createWorldRandom(() -> thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public BlockPos getBlockRandomPos(int x, int y, int z, int yMask) {
|
public BlockPos getBlockRandomPos(int x, int y, int z, int yMask) {
|
||||||
|
@ -11,3 +11,7 @@ public net.minecraft.world.level.levelgen.LegacyRandomSource seed
|
|||||||
public net.minecraft.world.level.levelgen.XoroshiroRandomSource randomNumberGenerator
|
public net.minecraft.world.level.levelgen.XoroshiroRandomSource randomNumberGenerator
|
||||||
public net.minecraft.world.level.levelgen.Xoroshiro128PlusPlus seedLo
|
public net.minecraft.world.level.levelgen.Xoroshiro128PlusPlus seedLo
|
||||||
public net.minecraft.world.level.levelgen.Xoroshiro128PlusPlus seedHi
|
public net.minecraft.world.level.levelgen.Xoroshiro128PlusPlus seedHi
|
||||||
|
|
||||||
|
# This will cause minor slowdown when ZGC or ShenandoahGC is used, but at least it won't crash
|
||||||
|
# with C2ME installed
|
||||||
|
public-f net.minecraft.world.level.Level random
|
||||||
|
Loading…
Reference in New Issue
Block a user