mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Further Seed Customisation
Allow server admins that really want to to customise the seeds used in world generation even further. By: md_5 <git@md-5.net>
This commit is contained in:
parent
4a1b3a723a
commit
c4d2bdfd85
@ -39,7 +39,7 @@
|
||||
|
||||
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> 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");
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<? extends ChunkGenerator> codec();
|
||||
|
||||
- public ChunkGeneratorStructureState createState(HolderLookup<StructureSet> structureSetRegistry, RandomState noiseConfig, long seed) {
|
||||
- return ChunkGeneratorStructureState.createForNormal(noiseConfig, seed, this.biomeSource, structureSetRegistry);
|
||||
+ public ChunkGeneratorStructureState createState(HolderLookup<StructureSet> holderlookup, RandomState randomstate, long i, org.spigotmc.SpigotWorldConfig conf) { // Spigot
|
||||
+ return ChunkGeneratorStructureState.createForNormal(randomstate, i, this.biomeSource, holderlookup, conf); // Spigot
|
||||
}
|
||||
|
||||
public Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> getTypeNameForDataFixer() {
|
||||
@@ -312,29 +312,29 @@
|
||||
}
|
||||
}
|
||||
|
@ -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<Holder<StructureSet>> possibleStructureSets;
|
||||
|
||||
- public static ChunkGeneratorStructureState createForFlat(RandomState noiseConfig, long seed, BiomeSource biomeSource, Stream<Holder<StructureSet>> structureSets) {
|
||||
- List<Holder<StructureSet>> list = structureSets.filter((holder) -> {
|
||||
- return ChunkGeneratorStructureState.hasBiomesForStructureSet((StructureSet) holder.value(), biomeSource);
|
||||
+ public static ChunkGeneratorStructureState createForFlat(RandomState randomstate, long i, BiomeSource worldchunkmanager, Stream<Holder<StructureSet>> stream, SpigotWorldConfig conf) { // Spigot
|
||||
+ List<Holder<StructureSet>> 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<StructureSet> structureSetRegistry) {
|
||||
- List<Holder<StructureSet>> 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<StructureSet> holderlookup, SpigotWorldConfig conf) { // Spigot
|
||||
+ List<Holder<StructureSet>> 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<Holder<StructureSet>> injectSpigot(List<Holder<StructureSet>> 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<Holder<Biome>> stream = structureSet.structures().stream().flatMap((structureset_a) -> {
|
||||
|
@ -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<StructureSet> structureSetRegistry, RandomState noiseConfig, long seed) {
|
||||
- public ChunkGeneratorStructureState createState(HolderLookup<StructureSet> structureSetRegistry, RandomState noiseConfig, long seed) {
|
||||
+ public ChunkGeneratorStructureState createState(HolderLookup<StructureSet> holderlookup, RandomState randomstate, long i, org.spigotmc.SpigotWorldConfig conf) { // Spigot
|
||||
Stream<Holder<StructureSet>> 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
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user