Skip to content

Commit

Permalink
fix loading old worlds (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaMatrix authored Mar 30, 2021
1 parent c7c8389 commit dc16fef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ public static void init() {
.create();
}

public static ResourceLocation defaultStorageFormatProviderName(ResourceLocation fallback) {
public static ResourceLocation defaultStorageFormatProviderName(String fallback) {
ResourceLocation[] providersThatCanBeDefault = REGISTRY.getValuesCollection().stream()
.filter(StorageFormatProviderBase::canBeDefault)
.map(StorageFormatProviderBase::getRegistryName)
.toArray(ResourceLocation[]::new);
return providersThatCanBeDefault.length == 1 ? providersThatCanBeDefault[0] : fallback;
return providersThatCanBeDefault.length == 1 ? providersThatCanBeDefault[0] :
fallback.isEmpty() ? DEFAULT : new ResourceLocation(fallback);
}

public ResourceLocation registryName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public WorldSavedCubicChunksData(String name, boolean isCC, int minHeight, int m
this.maxHeight = maxHeight;
isCubicChunks = true;
compatibilityGeneratorType = new ResourceLocation(CubicChunksConfig.compatibilityGeneratorType);
storageFormat = StorageFormatProviderBase.defaultStorageFormatProviderName(new ResourceLocation(CubicChunksConfig.storageFormat));
storageFormat = StorageFormatProviderBase.defaultStorageFormatProviderName(CubicChunksConfig.storageFormat);
}
}

Expand All @@ -65,7 +65,7 @@ public void readFromNBT(NBTTagCompound nbt) {
if(nbt.hasKey("storageFormat"))
storageFormat = new ResourceLocation(nbt.getString("storageFormat"));
else
storageFormat = StorageFormatProviderBase.defaultStorageFormatProviderName(new ResourceLocation(CubicChunksConfig.storageFormat));
storageFormat = StorageFormatProviderBase.defaultStorageFormatProviderName(CubicChunksConfig.storageFormat);
}

@Override
Expand Down

0 comments on commit dc16fef

Please sign in to comment.