From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Fri, 25 Jun 2021 18:23:36 -0400
Subject: [PATCH] Populator seed controls


diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
index 0ea6fedf6e660bc133fd5eb34d3d9bac3e581f32..e298097d2b29cd9a625154ec1a67372c496afd8e 100644
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
@@ -223,6 +223,7 @@ public final class Biome {
         return this.generationSettings;
     }
 
+    private static final java.security.SecureRandom SECURE_RANDOM = new java.security.SecureRandom(); // Purpur
     public void generate(StructureFeatureManager structureAccessor, ChunkGenerator chunkGenerator, WorldGenRegion region, long populationSeed, WorldgenRandom random, BlockPos origin) {
         List<List<Supplier<ConfiguredFeature<?, ?>>>> list = this.generationSettings.features();
         Registry<ConfiguredFeature<?, ?>> registry = region.registryAccess().registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY);
@@ -261,13 +262,20 @@ public final class Biome {
                 }
             }
 
+            // Purpur start
+            long populatorSeed = populationSeed;
+            if (((net.minecraft.server.level.ServerChunkCache) region.getChunkSource()).getLevel().purpurConfig.randomPopulatorSeed) {
+                populatorSeed = SECURE_RANDOM.nextLong();
+            }
+            // Purpur end
+
             if (list.size() > j) {
                 for(Supplier<ConfiguredFeature<?, ?>> supplier2 : list.get(j)) {
                     ConfiguredFeature<?, ?> configuredFeature = supplier2.get();
                     Supplier<String> supplier3 = () -> {
                         return registry.getResourceKey(configuredFeature).map(Object::toString).orElseGet(configuredFeature::toString);
                     };
-                    random.setFeatureSeed(populationSeed, k, j);
+                    random.setFeatureSeed(populatorSeed, k, j); // Purpur
 
                     try {
                         region.setCurrentlyGenerating(supplier3);
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 82ff334a6614f5ed8c07a32ae49998d5585744d8..eecc54aa1c16b29ad6de398b5aacf02c02c953f8 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -2265,4 +2265,9 @@ public class PurpurWorldConfig {
         zombifiedPiglinJockeyTryExistingChickens = getBoolean("mobs.zombified_piglin.jockey.try-existing-chickens", zombifiedPiglinJockeyTryExistingChickens);
         zombifiedPiglinCountAsPlayerKillWhenAngry = getBoolean("mobs.zombified_piglin.count-as-player-kill-when-angry", zombifiedPiglinCountAsPlayerKillWhenAngry);
     }
+
+    public boolean randomPopulatorSeed = false;
+    private void seedSettings() {
+        randomPopulatorSeed = getBoolean("seed.random-populator-seed", randomPopulatorSeed);
+    }
 }
