Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

WorldStem worldStem;
try {
@@ -169,17 +_,31 @@
@@ -169,17 +_,39 @@
executor -> WorldLoader.load(
worldLoadConfig,
context -> {
Expand All @@ -163,6 +163,14 @@
LevelDataAndDimensions worldData = LevelStorageSource.getLevelDataAndDimensions(
- access, levelDataTag, context.dataConfiguration(), datapackDimensions, context.datapackWorldgen()
+ access, levelDataTag, context.dataConfiguration(), datapackDimensions, context.datapackWorldgen(), net.minecraft.world.level.Level.OVERWORLD // Paper
+ // Paper start - Recover missing world gen settings
+ ,() -> {
+ final DedicatedServerProperties properties = settings.getProperties();
+ return new WorldGenSettings(
+ properties.worldOptions, properties.createDimensions(context.datapackWorldgen())
+ );
+ }
+ // Paper end - Recover missing world gen settings
);
return new WorldLoader.DataLoadOutput<>(
worldData.worldDataAndGenSettings(), worldData.dimensions().dimensionsRegistryAccess()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
--- a/net/minecraft/world/level/storage/LevelStorageSource.java
+++ b/net/minecraft/world/level/storage/LevelStorageSource.java
@@ -145,13 +_,14 @@
@@ -145,21 +_,48 @@
final WorldDataConfiguration dataConfiguration,
final Registry<LevelStem> datapackDimensions,
final HolderLookup.Provider registryAccess
- ) {
+ , final ResourceKey<Level> dimension // Paper - pass dimension
) {
+ ) {
+ // Paper start - Recover missing overworld world gen settings
+ return getLevelDataAndDimensions(worldAccess, levelDataTag, dataConfiguration, datapackDimensions, registryAccess, dimension, () -> {
+ // Preserve dimension settings if we got them from the datapack
+ WorldDimensions defaultDimensions = datapackDimensions.containsKey(LevelStem.OVERWORLD)
+ ? new WorldDimensions(datapackDimensions)
+ : net.minecraft.world.level.levelgen.presets.WorldPresets.createNormalWorldDimensions(registryAccess);
+ return new WorldGenSettings(WorldOptions.defaultWithRandomSeed(), defaultDimensions);
+ });
+ }
+
+ public static LevelDataAndDimensions getLevelDataAndDimensions(
+ final LevelStorageSource.LevelStorageAccess worldAccess,
+ final Dynamic<?> levelDataTag,
+ final WorldDataConfiguration dataConfiguration,
+ final Registry<LevelStem> datapackDimensions,
+ final HolderLookup.Provider registryAccess,
+ final ResourceKey<Level> dimension,
+ final java.util.function.Supplier<WorldGenSettings> worldGenSettingsFactory
+ ) {
+ // Paper end - Recover missing overworld world gen settings
if (DataFixers.getFileFixer().requiresFileFixing(NbtUtils.getDataVersion(levelDataTag))) {
throw new IllegalStateException("Cannot get level data without file fixing first");
}
Expand All @@ -16,6 +37,24 @@
.mapOrElse(
Function.identity(),
error -> {
- LOGGER.error(
- "Unable to read or access the world gen settings file! Falling back to the default settings with a random world seed. {}",
- error.message()
+ // Paper start - Recover missing overworld world gen settings
+ Path dataLocation = WorldGenSettings.TYPE.id().withSuffix(".dat").resolveAgainst(worldAccess.getDimensionPath(dimension).resolve(LevelResource.DATA.id()));
+ if (!Files.notExists(dataLocation, java.nio.file.LinkOption.NOFOLLOW_LINKS)) {
+ throw new IllegalStateException("Unable to read or access the world gen settings file " + dataLocation + ". " + error.message());
+ }
+ LOGGER.warn(
+ "World gen settings file is missing! Recreating settings from server.properties: {}",
+ dataLocation
);
- return new WorldGenSettings(WorldOptions.defaultWithRandomSeed(), new WorldDimensions(datapackDimensions));
+ return worldGenSettingsFactory.get();
+ // Paper end - Recover missing overworld world gen settings
}
);
LevelSettings settings = LevelSettings.parse(dataTag, dataConfiguration);
@@ -170,9 +_,9 @@
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void loadInitialWorld(final LevelStem stem, final boolean hasWorldData)
return;
}

final WorldGenSettings worldGenSettings = !hasWorldData
final WorldGenSettings worldGenSettings = loading.info().dimensionKey() == Level.OVERWORLD || !hasWorldData
? this.server.getWorldGenSettings()
: loadWorldGenSettings(
this.server.storageSource,
Expand Down
Loading