|
5 | 5 | import io.papermc.paper.world.saveddata.PaperWorldMetadata; |
6 | 6 | import io.papermc.paper.world.saveddata.PaperWorldPDC; |
7 | 7 | import java.io.IOException; |
| 8 | +import java.nio.file.Files; |
8 | 9 | import java.util.Locale; |
9 | 10 | import java.util.UUID; |
| 11 | +import net.minecraft.core.Registry; |
10 | 12 | import net.minecraft.core.registries.Registries; |
11 | 13 | import net.minecraft.resources.ResourceKey; |
12 | 14 | import net.minecraft.server.Main; |
@@ -118,15 +120,15 @@ public static LoadedWorldData loadWorldData( |
118 | 120 | } |
119 | 121 |
|
120 | 122 | public void loadInitialWorlds() { |
121 | | - final var levelStemRegistry = this.server.registryAccess().lookupOrThrow(Registries.LEVEL_STEM); |
122 | | - final boolean hasWorldData = this.server.storageSource.hasWorldData(); |
| 123 | + final Registry<LevelStem> levelStemRegistry = this.server.registryAccess().lookupOrThrow(Registries.LEVEL_STEM); |
123 | 124 | final LevelStem overworldStem = requireNonNull(levelStemRegistry.getValue(LevelStem.OVERWORLD), "Overworld stem missing"); |
| 125 | + final boolean hasWorldData = this.hasDimensionData(overworldStem); |
124 | 126 | this.loadInitialWorld(overworldStem, hasWorldData); |
125 | 127 | for (final LevelStem stem : levelStemRegistry) { |
126 | 128 | if (stem == overworldStem) { |
127 | 129 | continue; |
128 | 130 | } |
129 | | - this.loadInitialWorld(stem, hasWorldData); |
| 131 | + this.loadInitialWorld(stem, this.hasDimensionData(stem)); |
130 | 132 | } |
131 | 133 |
|
132 | 134 | // ((DedicatedServer) this.server).forceDifficulty(); |
@@ -164,6 +166,12 @@ private void loadInitialWorld(final LevelStem stem, final boolean hasWorldData) |
164 | 166 | this.server.createLevel(stem, loading, worldDataAndGenSettings); |
165 | 167 | } |
166 | 168 |
|
| 169 | + private boolean hasDimensionData(final LevelStem stem) { |
| 170 | + final ResourceKey<LevelStem> stemKey = this.server.registryAccess().lookupOrThrow(Registries.LEVEL_STEM).getResourceKey(stem).orElseThrow(); |
| 171 | + final ResourceKey<Level> dimensionKey = Registries.levelStemToLevel(stemKey); |
| 172 | + return Files.isDirectory(this.server.storageSource.getDimensionPath(dimensionKey)); |
| 173 | + } |
| 174 | + |
167 | 175 | public static WorldGenSettings loadWorldGenSettings( |
168 | 176 | final LevelStorageSource.LevelStorageAccess access, final net.minecraft.core.HolderLookup.Provider registryAccess, final ResourceKey<Level> dimension |
169 | 177 | ) { |
|
0 commit comments