diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch index 8f4f6b63a8..30f24dfdff 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -39,7 +39,7 @@ public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier persistentStateManagerFactory, int viewDistance, boolean dsync) { super(new RegionStorageInfo(session.getLevelId(), world.dimension(), "chunk"), session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); -@@ -170,7 +195,13 @@ +@@ -170,13 +195,19 @@ RegistryAccess iregistrycustom = world.registryAccess(); long j = world.getSeed(); @@ -54,6 +54,13 @@ this.randomState = RandomState.create((NoiseGeneratorSettings) chunkgeneratorabstract.generatorSettings().value(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); } else { this.randomState = RandomState.create(NoiseGeneratorSettings.dummy(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); + } + +- this.chunkGeneratorState = chunkGenerator.createState(iregistrycustom.lookupOrThrow(Registries.STRUCTURE_SET), this.randomState, j); ++ this.chunkGeneratorState = chunkGenerator.createState(iregistrycustom.lookupOrThrow(Registries.STRUCTURE_SET), this.randomState, j, world.spigotConfig); // Spigot + this.mainThreadExecutor = mainThreadExecutor; + ConsecutiveExecutor consecutiveexecutor = new ConsecutiveExecutor(executor, "worldgen"); + @@ -325,7 +356,7 @@ throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch index ae69b0dcf3..e1bfe627b3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch @@ -68,12 +68,12 @@ + slimes.add(converted); + } + // CraftBukkit end - } ++ } + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { + super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause + return; -+ } + } + for (LivingEntity living : slimes) { + this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason + } @@ -85,3 +85,12 @@ } @Override +@@ -300,7 +342,7 @@ + } + + ChunkPos chunkcoordintpair = new ChunkPos(pos); +- boolean flag = WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), 987234911L).nextInt(10) == 0; ++ boolean flag = WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot + + if (random.nextInt(10) == 0 && flag && pos.getY() < 40) { + return checkMobSpawnRules(type, world, spawnReason, pos, random); diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index a751fc65b0..b32d5dad2d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -1,5 +1,16 @@ --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java +@@ -108,8 +108,8 @@ + + protected abstract MapCodec codec(); + +- public ChunkGeneratorStructureState createState(HolderLookup structureSetRegistry, RandomState noiseConfig, long seed) { +- return ChunkGeneratorStructureState.createForNormal(noiseConfig, seed, this.biomeSource, structureSetRegistry); ++ public ChunkGeneratorStructureState createState(HolderLookup holderlookup, RandomState randomstate, long i, org.spigotmc.SpigotWorldConfig conf) { // Spigot ++ return ChunkGeneratorStructureState.createForNormal(randomstate, i, this.biomeSource, holderlookup, conf); // Spigot + } + + public Optional>> getTypeNameForDataFixer() { @@ -312,29 +312,29 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch index ac75ddd5c3..f023cd3e0d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java.patch @@ -5,3 +5,105 @@ package net.minecraft.world.level.chunk; import com.google.common.base.Stopwatch; +@@ -33,6 +34,11 @@ + import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement; + import org.slf4j.Logger; + ++// Spigot start ++import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement; ++import org.spigotmc.SpigotWorldConfig; ++// Spigot end ++ + public class ChunkGeneratorStructureState { + + private static final Logger LOGGER = LogUtils.getLogger(); +@@ -45,21 +51,81 @@ + private boolean hasGeneratedPositions; + private final List> possibleStructureSets; + +- public static ChunkGeneratorStructureState createForFlat(RandomState noiseConfig, long seed, BiomeSource biomeSource, Stream> structureSets) { +- List> list = structureSets.filter((holder) -> { +- return ChunkGeneratorStructureState.hasBiomesForStructureSet((StructureSet) holder.value(), biomeSource); ++ public static ChunkGeneratorStructureState createForFlat(RandomState randomstate, long i, BiomeSource worldchunkmanager, Stream> stream, SpigotWorldConfig conf) { // Spigot ++ List> list = stream.filter((holder) -> { ++ return ChunkGeneratorStructureState.hasBiomesForStructureSet((StructureSet) holder.value(), worldchunkmanager); + }).toList(); + +- return new ChunkGeneratorStructureState(noiseConfig, biomeSource, seed, 0L, list); ++ return new ChunkGeneratorStructureState(randomstate, worldchunkmanager, i, 0L, ChunkGeneratorStructureState.injectSpigot(list, conf)); // Spigot + } + +- public static ChunkGeneratorStructureState createForNormal(RandomState noiseConfig, long seed, BiomeSource biomeSource, HolderLookup structureSetRegistry) { +- List> list = (List) structureSetRegistry.listElements().filter((holder_c) -> { +- return ChunkGeneratorStructureState.hasBiomesForStructureSet((StructureSet) holder_c.value(), biomeSource); ++ public static ChunkGeneratorStructureState createForNormal(RandomState randomstate, long i, BiomeSource worldchunkmanager, HolderLookup holderlookup, SpigotWorldConfig conf) { // Spigot ++ List> list = (List) holderlookup.listElements().filter((holder_c) -> { ++ return ChunkGeneratorStructureState.hasBiomesForStructureSet((StructureSet) holder_c.value(), worldchunkmanager); + }).collect(Collectors.toUnmodifiableList()); + +- return new ChunkGeneratorStructureState(noiseConfig, biomeSource, seed, seed, list); ++ return new ChunkGeneratorStructureState(randomstate, worldchunkmanager, i, i, ChunkGeneratorStructureState.injectSpigot(list, conf)); // Spigot ++ } ++ ++ // Spigot start ++ private static List> injectSpigot(List> list, SpigotWorldConfig conf) { ++ return list.stream().map((holder) -> { ++ StructureSet structureset = holder.value(); ++ if (structureset.placement() instanceof RandomSpreadStructurePlacement randomConfig) { ++ String name = holder.unwrapKey().orElseThrow().location().getPath(); ++ int seed = randomConfig.salt; ++ ++ switch (name) { ++ case "desert_pyramids": ++ seed = conf.desertSeed; ++ break; ++ case "end_cities": ++ seed = conf.endCitySeed; ++ break; ++ case "nether_complexes": ++ seed = conf.netherSeed; ++ break; ++ case "igloos": ++ seed = conf.iglooSeed; ++ break; ++ case "jungle_temples": ++ seed = conf.jungleSeed; ++ break; ++ case "woodland_mansions": ++ seed = conf.mansionSeed; ++ break; ++ case "ocean_monuments": ++ seed = conf.monumentSeed; ++ break; ++ case "nether_fossils": ++ seed = conf.fossilSeed; ++ break; ++ case "ocean_ruins": ++ seed = conf.oceanSeed; ++ break; ++ case "pillager_outposts": ++ seed = conf.outpostSeed; ++ break; ++ case "ruined_portals": ++ seed = conf.portalSeed; ++ break; ++ case "shipwrecks": ++ seed = conf.shipwreckSeed; ++ break; ++ case "swamp_huts": ++ seed = conf.swampSeed; ++ break; ++ case "villages": ++ seed = conf.villageSeed; ++ break; ++ } ++ ++ structureset = new StructureSet(structureset.structures(), new RandomSpreadStructurePlacement(randomConfig.locateOffset, randomConfig.frequencyReductionMethod, randomConfig.frequency, seed, randomConfig.exclusionZone, randomConfig.spacing(), randomConfig.separation(), randomConfig.spreadType())); ++ } ++ return Holder.direct(structureset); ++ }).collect(Collectors.toUnmodifiableList()); + } ++ // Spigot end + + private static boolean hasBiomesForStructureSet(StructureSet structureSet, BiomeSource biomeSource) { + Stream> stream = structureSet.structures().stream().flatMap((structureset_a) -> { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/FlatLevelSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/FlatLevelSource.java.patch index 88a2591889..da8a1b29d5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/FlatLevelSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/FlatLevelSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/FlatLevelSource.java +++ b/net/minecraft/world/level/levelgen/FlatLevelSource.java -@@ -34,13 +34,19 @@ +@@ -34,22 +34,28 @@ private final FlatLevelGeneratorSettings settings; public FlatLevelSource(FlatLevelGeneratorSettings config) { @@ -22,5 +22,17 @@ + } + @Override - public ChunkGeneratorStructureState createState(HolderLookup structureSetRegistry, RandomState noiseConfig, long seed) { +- public ChunkGeneratorStructureState createState(HolderLookup structureSetRegistry, RandomState noiseConfig, long seed) { ++ public ChunkGeneratorStructureState createState(HolderLookup holderlookup, RandomState randomstate, long i, org.spigotmc.SpigotWorldConfig conf) { // Spigot Stream> stream = (Stream) this.settings.structureOverrides().map(HolderSet::stream).orElseGet(() -> { +- return structureSetRegistry.listElements().map((holder_c) -> { ++ return holderlookup.listElements().map((holder_c) -> { + return holder_c; + }); + }); + +- return ChunkGeneratorStructureState.createForFlat(noiseConfig, seed, this.biomeSource, stream); ++ return ChunkGeneratorStructureState.createForFlat(randomstate, i, this.biomeSource, stream, conf); // Spigot + } + + @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 5e8b503104..19f165b855 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -218,7 +218,7 @@ public class CraftChunk implements Chunk { @Override public boolean isSlimeChunk() { // 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk - return WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), 987234911L).nextInt(10) == 0; + return WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), this.worldServer.spigotConfig.slimeSeed).nextInt(10) == 0; } @Override diff --git a/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java b/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java index b871982be6..e8cde07257 100644 --- a/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -294,4 +294,40 @@ public class SpigotWorldConfig { this.endPortalSoundRadius = this.getInt( "end-portal-sound-radius", 0 ); } + + public int villageSeed; + public int desertSeed; + public int iglooSeed; + public int jungleSeed; + public int swampSeed; + public int monumentSeed; + public int oceanSeed; + public int outpostSeed; + public int shipwreckSeed; + public int slimeSeed; + public int endCitySeed; + public int netherSeed; + public int mansionSeed; + public int fossilSeed; + public int portalSeed; + private void initWorldGenSeeds() + { + this.villageSeed = this.getInt( "seed-village", 10387312 ); + this.desertSeed = this.getInt( "seed-desert", 14357617 ); + this.iglooSeed = this.getInt( "seed-igloo", 14357618 ); + this.jungleSeed = this.getInt( "seed-jungle", 14357619 ); + this.swampSeed = this.getInt( "seed-swamp", 14357620 ); + this.monumentSeed = this.getInt( "seed-monument", 10387313 ); + this.shipwreckSeed = this.getInt( "seed-shipwreck", 165745295 ); + this.oceanSeed = this.getInt( "seed-ocean", 14357621 ); + this.outpostSeed = this.getInt( "seed-outpost", 165745296 ); + this.endCitySeed = this.getInt( "seed-endcity", 10387313 ); + this.slimeSeed = this.getInt( "seed-slime", 987234911 ); + this.netherSeed = this.getInt( "seed-nether", 30084232 ); + this.mansionSeed = this.getInt( "seed-mansion", 10387319 ); + this.fossilSeed = this.getInt( "seed-fossil", 14357921 ); + this.portalSeed = this.getInt( "seed-portal", 34222645 ); + 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 + " Nether: " + this.netherSeed + " Mansion: " + this.mansionSeed + " Fossil: " + this.fossilSeed + " Portal: " + this.portalSeed ); + } }