Skip to content

Commit

Permalink
Update MinecraftInstanceExtensions.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
natsurainko committed Aug 28, 2024
1 parent 2b0c020 commit 1fbd87e
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,25 @@ public static void Delete(this MinecraftInstance instance)
public static GameStorageInfo GetStatistics(this MinecraftInstance instance)
{
var (libs, nativeLibs) = instance.GetRequiredLibraries();
var assetIndex = instance.GetAssetIndex();
var assets = instance.GetRequiredAssets();
MinecraftAssetIndex? assetIndex = null;
IEnumerable<MinecraftAsset> assets = [];

if (instance is ModifiedMinecraftInstance { HasInheritance : true } modifiedMinecraftInstance)
{
if (File.Exists(modifiedMinecraftInstance.InheritedMinecraftInstance.AssetIndexJsonPath))
{
assetIndex = modifiedMinecraftInstance.InheritedMinecraftInstance.GetAssetIndex();
assets = modifiedMinecraftInstance.InheritedMinecraftInstance.GetRequiredAssets();
}
}
else
{
if (File.Exists(instance.AssetIndexJsonPath))
{
assetIndex = instance.GetAssetIndex();
assets = instance.GetRequiredAssets();
}
}

long size = 0;
int assetCount = 0;
Expand All @@ -99,7 +116,8 @@ public static GameStorageInfo GetStatistics(this MinecraftInstance instance)
}
}

size += new FileInfo(assetIndex.FullPath).Length;
if (assetIndex != null)
size += new FileInfo(assetIndex.FullPath).Length;

if (File.Exists(instance.ClientJarPath))
size += new FileInfo(instance.ClientJarPath).Length;
Expand Down

0 comments on commit 1fbd87e

Please sign in to comment.