mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
429 lines
28 KiB
Diff
429 lines
28 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Apehum <apehumchik@gmail.com>
|
|
Date: Thu, 9 Dec 2021 02:18:17 +0800
|
|
Subject: [PATCH] Matter: Secure Seed
|
|
|
|
TODO - Dreeam:
|
|
Update to BLAKE3
|
|
|
|
Original license: GPLv3
|
|
Original project: https://github.com/plasmoapp/matter
|
|
|
|
Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
|
|
diff --git a/net/minecraft/server/dedicated/DedicatedServerProperties.java b/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
index 5748658abf0b90812005ae9d426df92daf5532f0..4a0eed7d7645ed539857592d233214e9a74499f1 100644
|
|
--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
+++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
|
@@ -114,7 +114,17 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
|
String string = this.get("level-seed", "");
|
|
boolean flag = this.get("generate-structures", true);
|
|
long l = WorldOptions.parseSeed(string).orElse(WorldOptions.randomSeed());
|
|
- this.worldOptions = new WorldOptions(l, flag, false);
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
+ String featureSeedStr = this.get("feature-level-seed", "");
|
|
+ long[] featureSeed = su.plo.matter.Globals.parseSeed(featureSeedStr)
|
|
+ .orElse(su.plo.matter.Globals.createRandomWorldSeed());
|
|
+
|
|
+ this.worldOptions = new WorldOptions(l, featureSeed, flag, false);
|
|
+ } else {
|
|
+ this.worldOptions = new WorldOptions(l, flag, false);
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
this.worldDimensionData = new DedicatedServerProperties.WorldDimensionData(
|
|
this.get("generator-settings", property -> GsonHelper.parse(!property.isEmpty() ? property : "{}"), new JsonObject()),
|
|
this.get("level-type", property -> property.toLowerCase(Locale.ROOT), WorldPresets.NORMAL.location().toString())
|
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
index e67196b815dad6baa823822285cff83848e549ce..ac7b4625ed9ec94ca438b6fedcd3e6bb6414b157 100644
|
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -674,6 +674,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
}
|
|
|
|
public ChunkGenerator getGenerator() {
|
|
+ su.plo.matter.Globals.setupGlobals(level); // Leaf - Matter - Secure Seed
|
|
return this.chunkMap.generator();
|
|
}
|
|
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 9b193bf81cf7f9f45dfa207a826043e083c2f8ba..11e8738b7cf388e0742bfe5e6136365f6ac066f9 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -625,6 +625,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
chunkGenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkGenerator, gen);
|
|
}
|
|
// CraftBukkit end
|
|
+ su.plo.matter.Globals.setupGlobals(this); // Leaf - Matter - Secure Seed
|
|
boolean flag = server.forceSynchronousWrites();
|
|
DataFixer fixerUpper = server.getFixerUpper();
|
|
// Paper - rewrite chunk system
|
|
diff --git a/net/minecraft/world/entity/monster/Slime.java b/net/minecraft/world/entity/monster/Slime.java
|
|
index 9a157a2bdbbeab89dbfcd23be8bdc62c8de4548c..c257a19ff6b15ee6a83e9c946e2b20309ada9b51 100644
|
|
--- a/net/minecraft/world/entity/monster/Slime.java
|
|
+++ b/net/minecraft/world/entity/monster/Slime.java
|
|
@@ -412,7 +412,11 @@ public class Slime extends Mob implements Enemy {
|
|
}
|
|
|
|
ChunkPos chunkPos = new ChunkPos(pos);
|
|
- boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Paper
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
|
+ ? level.getChunk(chunkPos.x, chunkPos.z).isSlimeChunk()
|
|
+ : WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Paper
|
|
+ // Leaf end - Matter - Secure Seed
|
|
// Paper start - Replace rules for Height in Slime Chunks
|
|
final double maxHeightSlimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum;
|
|
if (random.nextInt(10) == 0 && flag && pos.getY() < maxHeightSlimeChunk) {
|
|
diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
index 3b7f0d5fe40bdda65ab859a0c22bf0d369dc0f01..6683df8d0f5a61ab094393f761a3d3a22d6e0455 100644
|
|
--- a/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java
|
|
@@ -87,6 +87,10 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
|
|
public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY);
|
|
// CraftBukkit end
|
|
public final Registry<Biome> biomeRegistry; // CraftBukkit
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ private boolean slimeChunk;
|
|
+ private boolean hasComputedSlimeChunk;
|
|
+ // Leaf end - Matter - Secure Seed
|
|
|
|
// Paper start - rewrite chunk system
|
|
private volatile ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] blockNibbles;
|
|
@@ -191,6 +195,17 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
|
|
return GameEventListenerRegistry.NOOP;
|
|
}
|
|
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ public boolean isSlimeChunk() {
|
|
+ if (!hasComputedSlimeChunk) {
|
|
+ hasComputedSlimeChunk = true;
|
|
+ slimeChunk = su.plo.matter.WorldgenCryptoRandom.seedSlimeChunk(chunkPos.x, chunkPos.z).nextInt(10) == 0;
|
|
+ }
|
|
+
|
|
+ return slimeChunk;
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
+
|
|
public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper
|
|
|
|
@Nullable
|
|
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
index 857aa6e29b57a0a8eea4d7c14971b9dde59bb0d0..23806f5f0c6c4ec9a86a6ea13b89b4f57372e6f1 100644
|
|
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
@@ -342,7 +342,11 @@ public abstract class ChunkGenerator {
|
|
Registry<Structure> registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
|
Map<Integer, List<Structure>> map = registry.stream().collect(Collectors.groupingBy(structure1 -> structure1.step().ordinal()));
|
|
List<FeatureSorter.StepFeatureData> list = this.featuresPerStep.get();
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
|
+ ? new su.plo.matter.WorldgenCryptoRandom(blockPos.getX(), blockPos.getZ(), su.plo.matter.Globals.Salt.UNDEFINED, 0)
|
|
+ : new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
|
+ // Leaf end - Matter - Secure Seed
|
|
long l = worldgenRandom.setDecorationSeed(level.getSeed(), blockPos.getX(), blockPos.getZ());
|
|
Set<Holder<Biome>> set = new ObjectArraySet<>();
|
|
ChunkPos.rangeClosed(sectionPos.chunk(), 1).forEach(chunkPos -> {
|
|
@@ -551,8 +555,15 @@ public abstract class ChunkGenerator {
|
|
} else {
|
|
ArrayList<StructureSet.StructureSelectionEntry> list1 = new ArrayList<>(list.size());
|
|
list1.addAll(list);
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
- worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ WorldgenRandom worldgenRandom;
|
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(pos.x, pos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0);
|
|
+ } else {
|
|
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
int i = 0;
|
|
|
|
for (StructureSet.StructureSelectionEntry structureSelectionEntry1 : list1) {
|
|
diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
index f07a5416e5dc7e9a798a78ce9573a0c42bc59d04..426692d9627f46d708f551bd22ce3c52b2a23b37 100644
|
|
--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
+++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
@@ -205,7 +205,12 @@ public class ChunkGeneratorStructureState {
|
|
List<CompletableFuture<ChunkPos>> list = new ArrayList<>(count);
|
|
int spread = placement.spread();
|
|
HolderSet<Biome> holderSet = placement.preferredBiomes();
|
|
- RandomSource randomSource = RandomSource.create();
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ RandomSource randomSource = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
|
+ ? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.STRONGHOLDS, 0)
|
|
+ : RandomSource.create();
|
|
+ // Leaf end - Matter - Secure Seed
|
|
+ if (!org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
// Paper start - Add missing structure set seed configs
|
|
if (this.conf.strongholdSeed != null && structureSet.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) {
|
|
randomSource.setSeed(this.conf.strongholdSeed);
|
|
@@ -213,6 +218,7 @@ public class ChunkGeneratorStructureState {
|
|
// Paper end - Add missing structure set seed configs
|
|
randomSource.setSeed(this.concentricRingsSeed);
|
|
} // Paper - Add missing structure set seed configs
|
|
+ } // Leaf - Matter - Secure Seed
|
|
double d = randomSource.nextDouble() * Math.PI * 2.0;
|
|
int i = 0;
|
|
int i1 = 0;
|
|
diff --git a/net/minecraft/world/level/chunk/status/ChunkStep.java b/net/minecraft/world/level/chunk/status/ChunkStep.java
|
|
index b8348976e80578d9eff64eea68c04c603fed49ad..bc5c6ea1f1e4f1608a70116f03fb2a58ca3252c3 100644
|
|
--- a/net/minecraft/world/level/chunk/status/ChunkStep.java
|
|
+++ b/net/minecraft/world/level/chunk/status/ChunkStep.java
|
|
@@ -60,6 +60,7 @@ public final class ChunkStep implements ca.spottedleaf.moonrise.patches.chunk_sy
|
|
}
|
|
|
|
public CompletableFuture<ChunkAccess> apply(WorldGenContext worldGenContext, StaticCache2D<GenerationChunkHolder> cache, ChunkAccess chunk) {
|
|
+ su.plo.matter.Globals.setupGlobals(worldGenContext.level()); // Leaf - Matter - Secure Seed
|
|
if (chunk.getPersistedStatus().isBefore(this.targetStatus)) {
|
|
ProfiledDuration profiledDuration = JvmProfiler.INSTANCE
|
|
.onChunkGenerate(chunk.getPos(), worldGenContext.level().dimension(), this.targetStatus.getName());
|
|
diff --git a/net/minecraft/world/level/levelgen/WorldOptions.java b/net/minecraft/world/level/levelgen/WorldOptions.java
|
|
index c92508741439a8d0d833ea02d0104416adb83c92..c05da7cfcd3d97a1716cb305be36ba9c94217b6f 100644
|
|
--- a/net/minecraft/world/level/levelgen/WorldOptions.java
|
|
+++ b/net/minecraft/world/level/levelgen/WorldOptions.java
|
|
@@ -9,8 +9,20 @@ import net.minecraft.util.RandomSource;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
public class WorldOptions {
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ private static final com.google.gson.Gson gson = new com.google.gson.Gson();
|
|
+ private static final boolean isSecureSeedEnabled = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled;
|
|
public static final MapCodec<WorldOptions> CODEC = RecordCodecBuilder.mapCodec(
|
|
- instance -> instance.group(
|
|
+ instance -> isSecureSeedEnabled
|
|
+ ? instance.group(
|
|
+ Codec.LONG.fieldOf("seed").stable().forGetter(WorldOptions::seed),
|
|
+ Codec.STRING.fieldOf("feature_seed").orElse(gson.toJson(su.plo.matter.Globals.createRandomWorldSeed())).stable().forGetter(WorldOptions::featureSeedSerialize),
|
|
+ Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures),
|
|
+ Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldOptions::generateBonusChest),
|
|
+ Codec.STRING.lenientOptionalFieldOf("legacy_custom_options").stable().forGetter(worldOptions -> worldOptions.legacyCustomOptions)
|
|
+ )
|
|
+ .apply(instance, instance.stable(WorldOptions::new))
|
|
+ : instance.group(
|
|
Codec.LONG.fieldOf("seed").stable().forGetter(WorldOptions::seed),
|
|
Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures),
|
|
Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldOptions::generateBonusChest),
|
|
@@ -18,8 +30,14 @@ public class WorldOptions {
|
|
)
|
|
.apply(instance, instance.stable(WorldOptions::new))
|
|
);
|
|
- public static final WorldOptions DEMO_OPTIONS = new WorldOptions("North Carolina".hashCode(), true, true);
|
|
+ // Leaf end - Matter - Secure Seed
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ public static final WorldOptions DEMO_OPTIONS = isSecureSeedEnabled
|
|
+ ? new WorldOptions((long) "North Carolina".hashCode(), su.plo.matter.Globals.createRandomWorldSeed(), true, true)
|
|
+ : new WorldOptions("North Carolina".hashCode(), true, true);
|
|
+ // Leaf end - Matter - Secure Seed
|
|
private final long seed;
|
|
+ private long[] featureSeed = su.plo.matter.Globals.createRandomWorldSeed(); // Leaf - Matter - Secure Seed
|
|
private final boolean generateStructures;
|
|
private final boolean generateBonusChest;
|
|
private final Optional<String> legacyCustomOptions;
|
|
@@ -28,14 +46,35 @@ public class WorldOptions {
|
|
this(seed, generateStructures, generateBonusChest, Optional.empty());
|
|
}
|
|
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ public WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest) {
|
|
+ this(seed, featureSeed, generateStructures, bonusChest, Optional.empty());
|
|
+ }
|
|
+
|
|
+ private WorldOptions(long seed, String featureSeedJson, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
|
+ this(seed, gson.fromJson(featureSeedJson, long[].class), generateStructures, bonusChest, legacyCustomOptions);
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
+
|
|
public static WorldOptions defaultWithRandomSeed() {
|
|
- return new WorldOptions(randomSeed(), true, false);
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ return isSecureSeedEnabled
|
|
+ ? new WorldOptions(randomSeed(), su.plo.matter.Globals.createRandomWorldSeed(), true, false)
|
|
+ : new WorldOptions(randomSeed(), true, false);
|
|
+ // Leaf end - Matter - Secure Seed
|
|
}
|
|
|
|
public static WorldOptions testWorldWithRandomSeed() {
|
|
return new WorldOptions(randomSeed(), false, false);
|
|
}
|
|
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ private WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
|
+ this(seed, generateStructures, bonusChest, legacyCustomOptions);
|
|
+ this.featureSeed = featureSeed;
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
+
|
|
private WorldOptions(long seed, boolean generateStructures, boolean generateBonusChest, Optional<String> legacyCustomOptions) {
|
|
this.seed = seed;
|
|
this.generateStructures = generateStructures;
|
|
@@ -47,6 +86,16 @@ public class WorldOptions {
|
|
return this.seed;
|
|
}
|
|
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ public long[] featureSeed() {
|
|
+ return this.featureSeed;
|
|
+ }
|
|
+
|
|
+ private String featureSeedSerialize() {
|
|
+ return gson.toJson(this.featureSeed);
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
+
|
|
public boolean generateStructures() {
|
|
return this.generateStructures;
|
|
}
|
|
@@ -59,17 +108,25 @@ public class WorldOptions {
|
|
return this.legacyCustomOptions.isPresent();
|
|
}
|
|
|
|
+ // Leaf start - Matter - Secure Seed
|
|
public WorldOptions withBonusChest(boolean generateBonusChest) {
|
|
- return new WorldOptions(this.seed, this.generateStructures, generateBonusChest, this.legacyCustomOptions);
|
|
+ return isSecureSeedEnabled
|
|
+ ? new WorldOptions(this.seed, this.featureSeed, this.generateStructures, generateBonusChest, this.legacyCustomOptions)
|
|
+ : new WorldOptions(this.seed, this.generateStructures, generateBonusChest, this.legacyCustomOptions);
|
|
}
|
|
|
|
public WorldOptions withStructures(boolean generateStructures) {
|
|
- return new WorldOptions(this.seed, generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
|
+ return isSecureSeedEnabled
|
|
+ ? new WorldOptions(this.seed, this.featureSeed, generateStructures, this.generateBonusChest, this.legacyCustomOptions)
|
|
+ : new WorldOptions(this.seed, generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
|
}
|
|
|
|
public WorldOptions withSeed(OptionalLong seed) {
|
|
- return new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
|
+ return isSecureSeedEnabled
|
|
+ ? new WorldOptions(seed.orElse(randomSeed()), su.plo.matter.Globals.createRandomWorldSeed(), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions)
|
|
+ : new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
|
}
|
|
+ // Leaf end - Matter - Secure Seed
|
|
|
|
public static OptionalLong parseSeed(String seed) {
|
|
seed = seed.trim();
|
|
diff --git a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
index 4e72eb49dbf4c70ae7556ba6eb210fcd5ef36aaa..8df6dadfeb2c282bc3c3f521d31f7277caa77790 100644
|
|
--- a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
+++ b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
@@ -41,7 +41,11 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
|
int i1 = geodeConfiguration.maxGenOffset;
|
|
List<Pair<BlockPos, Integer>> list = Lists.newLinkedList();
|
|
int i2 = geodeConfiguration.distributionPoints.sample(randomSource);
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
|
+ ? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.GEODE_FEATURE, 0)
|
|
+ : new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
|
+ // Leaf end - Matter - Secure Seed
|
|
NormalNoise normalNoise = NormalNoise.create(worldgenRandom, -4, 1.0);
|
|
List<BlockPos> list1 = Lists.newLinkedList();
|
|
double d = (double)i2 / geodeConfiguration.outerWallDistance.getMaxValue();
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/Structure.java b/net/minecraft/world/level/levelgen/structure/Structure.java
|
|
index 8328e864c72b7a358d6bb1f33459b8c4df2ecb1a..28281491be6b54de18c49ff0d52e302575d3ad38 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/Structure.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/Structure.java
|
|
@@ -249,6 +249,11 @@ public abstract class Structure {
|
|
}
|
|
|
|
private static WorldgenRandom makeRandom(long seed, ChunkPos chunkPos) {
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
+ return new su.plo.matter.WorldgenCryptoRandom(chunkPos.x, chunkPos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, seed);
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
|
return worldgenRandom;
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
|
index ee0d9dddb36b6879fa113299e24f1aa3b2b151cc..6584c9320361dbbdea1899ab9e43b444de5006a6 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
|
@@ -67,8 +67,15 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
|
public ChunkPos getPotentialStructureChunk(long seed, int regionX, int regionZ) {
|
|
int i = Math.floorDiv(regionX, this.spacing);
|
|
int i1 = Math.floorDiv(regionZ, this.spacing);
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
- worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ WorldgenRandom worldgenRandom;
|
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(i, i1, su.plo.matter.Globals.Salt.POTENTIONAL_FEATURE, this.salt);
|
|
+ } else {
|
|
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
int i2 = this.spacing - this.separation;
|
|
int i3 = this.spreadType.evaluate(worldgenRandom, i2);
|
|
int i4 = this.spreadType.evaluate(worldgenRandom, i2);
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
|
index 1f939b325ec5291b3c4aabc4735c863f9436a6f8..ee60717e39928a9f89ad6c7a9b3b52ac156871e6 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
|
@@ -119,8 +119,16 @@ public abstract class StructurePlacement {
|
|
public abstract StructurePlacementType<?> type();
|
|
|
|
private static boolean probabilityReducer(long levelSeed, int regionX, int regionZ, int salt, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
- worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, salt);
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ WorldgenRandom worldgenRandom;
|
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(regionX, regionZ, su.plo.matter.Globals.Salt.UNDEFINED, salt);
|
|
+ } else {
|
|
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ worldgenRandom.setLargeFeatureWithSalt(levelSeed, salt, regionX, regionZ);
|
|
+ }
|
|
+ // Leaf end - Matter - Secure Seed
|
|
+
|
|
return worldgenRandom.nextFloat() < probability;
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java b/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
|
index 1cfa0fcd28685736fcdce4aef817e4d4cc4061cb..400e5d1c415835a87648ae0d1aa92ac4063ae93c 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
|
@@ -64,7 +64,11 @@ public class JigsawPlacement {
|
|
ChunkGenerator chunkGenerator = context.chunkGenerator();
|
|
StructureTemplateManager structureTemplateManager = context.structureTemplateManager();
|
|
LevelHeightAccessor levelHeightAccessor = context.heightAccessor();
|
|
- WorldgenRandom worldgenRandom = context.random();
|
|
+ // Leaf start - Matter - Secure Seed
|
|
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
|
+ ? new su.plo.matter.WorldgenCryptoRandom(context.chunkPos().x, context.chunkPos().z, su.plo.matter.Globals.Salt.JIGSAW_PLACEMENT, 0)
|
|
+ : context.random();
|
|
+ // Leaf end - Matter - Secure Seed
|
|
Registry<StructureTemplatePool> registry = registryAccess.lookupOrThrow(Registries.TEMPLATE_POOL);
|
|
Rotation random = Rotation.getRandom(worldgenRandom);
|
|
StructureTemplatePool structureTemplatePool = startPool.unwrapKey()
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java b/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
|
index 653c03d214d2e690852adc4d697e2b24c39ea3d0..807881ab3b647bff515df627543b8a2e1cad3c3f 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
|
@@ -10,6 +10,7 @@ import net.minecraft.world.level.levelgen.structure.Structure;
|
|
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
|
import net.minecraft.world.level.levelgen.structure.StructureType;
|
|
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
|
+//import su.plo.matter.WorldgenCryptoRandom; // Leaf - Matter - Secure Seed
|
|
|
|
public class EndCityStructure extends Structure {
|
|
public static final MapCodec<EndCityStructure> CODEC = simpleCodec(EndCityStructure::new);
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java b/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
|
index 5f2118f664c1013b99137c6d34a11c40c2559156..2acee0e8b5b80f7a40346befcafcd011edd37cf9 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
|
@@ -20,6 +20,7 @@ import net.minecraft.world.level.levelgen.WorldgenRandom;
|
|
import net.minecraft.world.level.levelgen.structure.Structure;
|
|
import net.minecraft.world.level.levelgen.structure.StructureType;
|
|
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
|
+//import su.plo.matter.WorldgenCryptoRandom; // Leaf - Matter - Secure Seed
|
|
|
|
public class MineshaftStructure extends Structure {
|
|
public static final MapCodec<MineshaftStructure> CODEC = RecordCodecBuilder.mapCodec(
|