From 68325f5385666a89fef93b08b4572390be38029e Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sun, 23 Jan 2022 06:26:22 -0800 Subject: [PATCH] Add configurable stronghold seed (#7334) --- build-data/paper.at | 3 + .../Add-config-for-stronghold-seed.patch | 57 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 patches/server/Add-config-for-stronghold-seed.patch diff --git a/build-data/paper.at b/build-data/paper.at index 00a8a2baed..fde71792e4 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -298,3 +298,6 @@ public net.minecraft.world.entity.player.Player checkRidingStatistics(DDD)V # Fix NotePlayEvent public org.bukkit.craftbukkit.block.data.CraftBlockData toNMS(Ljava/lang/Enum;Ljava/lang/Class;)Ljava/lang/Enum; + +# Stronghold seed configuration +public-f net.minecraft.world.level.chunk.ChunkGenerator strongholdSeed diff --git a/patches/server/Add-config-for-stronghold-seed.patch b/patches/server/Add-config-for-stronghold-seed.patch new file mode 100644 index 0000000000..e1b85bc332 --- /dev/null +++ b/patches/server/Add-config-for-stronghold-seed.patch @@ -0,0 +1,57 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Thu, 13 Jan 2022 23:05:53 -0800 +Subject: [PATCH] Add config for stronghold seed + + +diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java ++++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +@@ -0,0 +0,0 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource { + skipExistingChunks = event.shouldFindUnexplored(); + structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(event.getType().getName()); + // Paper end ++ this.updateStructureSettings(world, this.settings); // Spigot // Paper - move up to include strongholds + if (structureFeature == StructureFeature.STRONGHOLD) { + this.generateStrongholds(); + BlockPos blockposition1 = null; +@@ -0,0 +0,0 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource { + + return blockposition1; + } else { +- this.updateStructureSettings(world, this.settings); // Spigot + StructureFeatureConfiguration structuresettingsfeature = this.settings.getConfig(structureFeature); + ImmutableMultimap, ResourceKey> immutablemultimap = this.settings.structures(structureFeature); + +@@ -0,0 +0,0 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource { + java.util.Map, StructureFeatureConfiguration> original = settings.structureConfig(); + java.util.Map, StructureFeatureConfiguration> updated = new java.util.HashMap<>(); + org.spigotmc.SpigotWorldConfig conf = world.spigotConfig; ++ this.strongholdSeed = Objects.requireNonNullElse(conf.strongholdSeed, this.strongholdSeed); // Paper + + for (java.util.Map.Entry, StructureFeatureConfiguration> entry : original.entrySet()) { + String name = Registry.STRUCTURE_FEATURE.getKey(entry.getKey()).getPath(); +diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java ++++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java +@@ -0,0 +0,0 @@ public class SpigotWorldConfig + public int mansionSeed; + public int fossilSeed; + public int portalSeed; ++ public Long strongholdSeed; // Paper + private void initWorldGenSeeds() + { + this.villageSeed = this.getInt( "seed-village", 10387312 ); +@@ -0,0 +0,0 @@ public class SpigotWorldConfig + this.mansionSeed = this.getInt( "seed-mansion", 10387319 ); + this.fossilSeed = this.getInt( "seed-fossil", 14357921 ); + this.portalSeed = this.getInt( "seed-portal", 34222645 ); ++ // Paper start ++ final String strongholdSeedString = this.getString("seed-stronghold", "default"); ++ this.strongholdSeed = org.apache.commons.lang3.math.NumberUtils.isParsable(strongholdSeedString) ? Long.parseLong(strongholdSeedString) : null; ++ // Paper end + this.log( "Custom Map Seeds: Village: " + this.villageSeed + " Desert: " + this.desertSeed + " Igloo: " + this.iglooSeed + " Jungle: " + this.jungleSeed + " Swamp: " + this.swampSeed + " Monument: " + this.monumentSeed + + " Ocean: " + this.oceanSeed + " Shipwreck: " + this.shipwreckSeed + " End City: " + this.endCitySeed + " Slime: " + this.slimeSeed + " Bastion: " + this.bastionSeed + " Fortress: " + this.fortressSeed + " Mansion: " + this.mansionSeed + " Fossil: " + this.fossilSeed + " Portal: " + this.portalSeed ); + }