Files
Lophine/lophine-server/minecraft-patches/features/0054-Add-secure-seed-V2-with-Blake3.patch
T
Helvetica Volubi 3a8f64da64 Update Folia
2026-08-12 03:49:09 +08:00

71 lines
5.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Libalpm64 <libalpm@proton.me>
Date: Mon, 2 Mar 2026 00:00:00 +0000
Subject: [PATCH] Add secure seed V2 with Blake3
diff --git a/net/minecraft/world/level/levelgen/RandomState.java b/net/minecraft/world/level/levelgen/RandomState.java
index 7b74440fbbe79c018ad59d24b99da0c6d4a9d007..208d4b93ee47083bd9069aec710c6db27044203c 100644
--- a/net/minecraft/world/level/levelgen/RandomState.java
+++ b/net/minecraft/world/level/levelgen/RandomState.java
@@ -33,10 +33,28 @@ public final class RandomState {
}
private RandomState(final NoiseGeneratorSettings settings, final HolderGetter<NormalNoise.NoiseParameters> noises, final long seed) {
- this.random = settings.getRandomSource().newInstance(seed).forkPositional();
+ // this.random = settings.getRandomSource().newInstance(seed).forkPositional(); // Luminol - Add secure seed V2 with Blake3
+ // Luminol start - Add secure seed V2 with Blake3
+ final long[] secureWorldSeed = (me.earthme.luminol.config.modules.function.SecureSeedConfig.enabled && me.earthme.luminol.config.modules.function.SecureSeedConfig.version == 2)
+ ? su.plo.matter.HashingV2.expandLevelSeedTo1024Bits(seed)
+ : null;
+
+ long terrainSeed = (me.earthme.luminol.config.modules.function.SecureSeedConfig.enabled && me.earthme.luminol.config.modules.function.SecureSeedConfig.version == 2)
+ ? su.plo.matter.HashingV2.getTerrainSeed(secureWorldSeed, su.plo.matter.HashingV2.TerrainType.BASE_TERRAIN)
+ : seed;
+ long aquiferSeed = (me.earthme.luminol.config.modules.function.SecureSeedConfig.enabled && me.earthme.luminol.config.modules.function.SecureSeedConfig.version == 2)
+ ? su.plo.matter.HashingV2.getTerrainSeed(secureWorldSeed, su.plo.matter.HashingV2.TerrainType.AQUIFER)
+ : seed;
+ long oreSeed = (me.earthme.luminol.config.modules.function.SecureSeedConfig.enabled && me.earthme.luminol.config.modules.function.SecureSeedConfig.version == 2)
+ ? su.plo.matter.HashingV2.getTerrainSeed(secureWorldSeed, su.plo.matter.HashingV2.TerrainType.ORE)
+ : seed;
+ // Luminol end
+ this.random = settings.getRandomSource().newInstance(terrainSeed).forkPositional(); // Luminol - Add secure seed V2 with Blake3
this.noises = noises;
- this.aquiferRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("aquifer")).forkPositional();
- this.oreRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("ore")).forkPositional();
+ //this.aquiferRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("aquifer")).forkPositional(); // Luminol - Add secure seed V2 with Blake3
+ //this.oreRandom = this.random.fromHashOf(Identifier.withDefaultNamespace("ore")).forkPositional(); // Luminol - Add secure seed V2 with Blake3
+ this.aquiferRandom = settings.getRandomSource().newInstance(aquiferSeed).forkPositional(); // Luminol - Add secure seed V2 with Blake3
+ this.oreRandom = settings.getRandomSource().newInstance(oreSeed).forkPositional(); // Luminol - Add secure seed V2 with Blake3
this.noiseIntances = new ConcurrentHashMap<>();
this.positionalRandoms = new ConcurrentHashMap<>();
this.surfaceSystem = new SurfaceSystem(this, settings.defaultBlock(), settings.seaLevel(), this.random);
@@ -46,6 +64,12 @@ public final class RandomState {
private final Map<DensityFunction, DensityFunction> wrapped = new HashMap<>();
private RandomSource newLegacyInstance(final long seedOffset) {
+ // Luminol start - Add secure seed V2 with Blake3
+ if (me.earthme.luminol.config.modules.function.SecureSeedConfig.enabled && me.earthme.luminol.config.modules.function.SecureSeedConfig.version == 2) {
+ long climateSeed = su.plo.matter.HashingV2.getTerrainSeed(secureWorldSeed, su.plo.matter.HashingV2.TerrainType.CLIMATE);
+ return new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.UNDEFINED, climateSeed + seed);
+ }
+ // Luminol end
return new LegacyRandomSource(seed + seedOffset);
}
@@ -71,7 +95,13 @@ public final class RandomState {
: RandomState.this.random.fromHashOf(Identifier.withDefaultNamespace("terrain"));
return noise.withNewRandom(terrainRandom);
} else {
- return function instanceof DensityFunctions.EndIslandDensityFunction ? new DensityFunctions.EndIslandDensityFunction(seed) : function;
+ return function instanceof DensityFunctions.EndIslandDensityFunction //? new DensityFunctions.EndIslandDensityFunction(seed)// Luminol - Add secure seed V2 with Blake3
+ // Luminol start - Add secure seed V2 with Blake3
+ ? new DensityFunctions.EndIslandDensityFunction((me.earthme.luminol.config.modules.function.SecureSeedConfig.enabled && me.earthme.luminol.config.modules.function.SecureSeedConfig.version == 2)
+ ? su.plo.matter.HashingV2.getTerrainSeed(secureWorldSeed, su.plo.matter.HashingV2.TerrainType.SURFACE)
+ : seed)
+ // Luminol end
+ : function;
}
}