4545import de .bluecolored .bluenbt .TypeToken ;
4646import lombok .Getter ;
4747import lombok .ToString ;
48+ import org .jetbrains .annotations .Nullable ;
4849
4950import java .io .IOException ;
5051import java .io .InputStream ;
@@ -182,13 +183,19 @@ public static Path resolveDimensionFolder(Path worldFolder, Key dimension) {
182183
183184 public static DimensionType loadDimensionType (Path worldFolder , Key dimension , DataPack dataPack ) throws IOException {
184185 BlueNBT blueNBT = createBlueNBTForDataPack (dataPack );
186+ DimensionSettings dimensionSettings = null ;
187+
185188 WorldGenSettings worldGenSettings = load (WorldGenSettings .class , worldFolder .resolve ("data/minecraft/world_gen_settings.dat" ), blueNBT );
186- DimensionSettings dimensionSettings = worldGenSettings .getData ().getDimensions ().get (dimension .getFormatted ());
189+ if (worldGenSettings != null ) {
190+ dimensionSettings = worldGenSettings .getData ().getDimensions ().get (dimension .getFormatted ());
191+ }
187192
188193 if (dimensionSettings == null ) {
189194 // try loading from the level.dat instead (old world format)
190195 LevelData levelData = load (LevelData .class , worldFolder .resolve ("level.dat" ), blueNBT );
191- dimensionSettings = levelData .getData ().getWorldGenSettings ().getDimensions ().get (dimension .getFormatted ());
196+ if (levelData != null ) {
197+ dimensionSettings = levelData .getData ().getWorldGenSettings ().getDimensions ().get (dimension .getFormatted ());
198+ }
192199 }
193200
194201 if (dimensionSettings != null ) return dimensionSettings .getType ();
@@ -208,7 +215,8 @@ private static BlueNBT createBlueNBTForDataPack(DataPack dataPack) {
208215 return blueNBT ;
209216 }
210217
211- private static <T > T load (Class <T > type , Path path , BlueNBT blueNBT ) throws IOException {
218+ private static <T > @ Nullable T load (Class <T > type , Path path , BlueNBT blueNBT ) throws IOException {
219+ if (!Files .exists (path )) return null ;
212220 try (InputStream fileIn = Compression .GZIP .decompress (Files .newInputStream (path ))) {
213221 return blueNBT .read (fileIn , type );
214222 }
0 commit comments