Skip to content

Commit

Permalink
Fix[MDCL]: handle null assetIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduytran0 committed Apr 15, 2024
1 parent 7a09762 commit 0a87c96
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Natives/MinecraftResourceDownloadTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ - (void)downloadVersionMetadata:(NSDictionary *)version success:(void (^)())succ

- (void)downloadAssetMetadataWithSuccess:(void (^)())success {
NSDictionary *assetIndex = self.metadata[@"assetIndex"];
if (!assetIndex) {
success();
return;
}
NSString *path = [NSString stringWithFormat:@"%s/assets/indexes/%@.json", getenv("POJAV_GAME_DIR"), assetIndex[@"id"]];
NSString *url = assetIndex[@"url"];
NSString *sha = url.stringByDeletingLastPathComponent.lastPathComponent;
Expand Down Expand Up @@ -177,6 +181,9 @@ - (NSArray *)downloadClientLibraries {
- (NSArray *)downloadClientAssets {
NSMutableArray *tasks = [NSMutableArray new];
NSDictionary *assets = self.metadata[@"assetIndexObj"];
if (!assets) {
return @[];
}
for (NSString *name in assets[@"objects"]) {
NSString *hash = assets[@"objects"][name][@"hash"];
NSString *pathname = [NSString stringWithFormat:@"%@/%@", [hash substringToIndex:2], hash];
Expand Down

0 comments on commit 0a87c96

Please sign in to comment.