mirror of
https://github.com/SparklyPower/SparklyPaper.git
synced 2025-12-19 15:09:27 +00:00
81 lines
5.0 KiB
Diff
81 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Nassim Jahnke <jahnke.nassim@gmail.com>
|
|
Date: Tue, 31 Aug 2021 17:05:27 +0200
|
|
Subject: [PATCH] Configurable feature seeds
|
|
|
|
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
index 4ae21ba5d04c954592ec4f85d43ff71ec7dadea1..bee97b02227ef198c79c48b43610fb417435a2d2 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -922,6 +922,37 @@ public class PaperWorldConfig {
|
|
return table;
|
|
}
|
|
|
|
+ public it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<net.minecraft.resources.ResourceLocation> featureSeeds = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>();
|
|
+ private void featureSeeds() {
|
|
+ featureSeeds.defaultReturnValue(-1);
|
|
+ final boolean randomise = getBoolean("feature-seeds.generate-random-seeds-for-all", false);
|
|
+ ConfigurationSection section = config.getConfigurationSection("world-settings." + worldName + ".feature-seeds");
|
|
+ if (section == null) {
|
|
+ section = config.getConfigurationSection("world-settings.default.feature-seeds");
|
|
+ }
|
|
+ for (final String key : section.getKeys(false)) {
|
|
+ net.minecraft.resources.ResourceLocation resourceKey = new net.minecraft.resources.ResourceLocation(key);
|
|
+ featureSeeds.put(resourceKey, section.getLong(key));
|
|
+ }
|
|
+ if (randomise) {
|
|
+ final Map<String, Object> randomisedSeeds = new HashMap<>();
|
|
+ final java.util.Random random = new java.util.Random();
|
|
+ for (net.minecraft.resources.ResourceLocation resourceLocation : net.minecraft.server.MinecraftServer.getServer()
|
|
+ .registryAccess().registryOrThrow(net.minecraft.core.Registry.CONFIGURED_FEATURE_REGISTRY).keySet()) {
|
|
+ if (featureSeeds.containsKey(resourceLocation)) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ final long seed = random.nextLong();
|
|
+ randomisedSeeds.put("world-settings." + worldName + ".feature-seeds." + resourceLocation.getPath(), seed);
|
|
+ featureSeeds.put(resourceLocation, seed);
|
|
+ }
|
|
+ if (!randomisedSeeds.isEmpty()) {
|
|
+ config.addDefaults(randomisedSeeds);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
public int getBehaviorTickRate(String typeName, String entityType, int def) {
|
|
return getIntOrDefault(behaviorTickRates, typeName, entityType, def);
|
|
}
|
|
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..b5c6b0bc307aef2835761cfa50413cebfd624795 100644
|
|
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
|
|
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
|
@@ -225,7 +225,7 @@ public final class Biome {
|
|
|
|
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);
|
|
+ Registry<ConfiguredFeature<?, ?>> registry = region.registryAccess().registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY); // Paper - diff on change
|
|
Registry<StructureFeature<?>> registry2 = region.registryAccess().registryOrThrow(Registry.STRUCTURE_FEATURE_REGISTRY);
|
|
int i = GenerationStep.Decoration.values().length;
|
|
|
|
@@ -267,7 +267,16 @@ public final class Biome {
|
|
Supplier<String> supplier3 = () -> {
|
|
return registry.getResourceKey(configuredFeature).map(Object::toString).orElseGet(configuredFeature::toString);
|
|
};
|
|
- random.setFeatureSeed(populationSeed, k, j);
|
|
+ // Paper start - change populationSeed used in random
|
|
+ long featurePopulationSeed = populationSeed;
|
|
+ final ResourceLocation location = registry.getKey(configuredFeature);
|
|
+ final long configFeatureSeed = region.getMinecraftWorld().paperConfig.featureSeeds.getLong(location);
|
|
+ if (configFeatureSeed != -1) {
|
|
+ final ChunkPos center = region.getCenter();
|
|
+ featurePopulationSeed = random.setDecorationSeed(configFeatureSeed, center.getMinBlockX(), center.getMinBlockZ()); // See ChunkGenerator#addVanillaDecorations
|
|
+ }
|
|
+ random.setFeatureSeed(featurePopulationSeed, k, j);
|
|
+ // Paper end
|
|
|
|
try {
|
|
region.setCurrentlyGenerating(supplier3);
|