From 1fbd87ee05c288049b9a7e0f871892fa6bdf5ccb Mon Sep 17 00:00:00 2001 From: natsurainko Date: Wed, 28 Aug 2024 18:38:39 +0800 Subject: [PATCH] Update MinecraftInstanceExtensions.cs --- .../Instances/MinecraftInstanceExtensions.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Natsurainko.FluentCore/GameManagement/Instances/MinecraftInstanceExtensions.cs b/Natsurainko.FluentCore/GameManagement/Instances/MinecraftInstanceExtensions.cs index 61e46dd..4300e9f 100644 --- a/Natsurainko.FluentCore/GameManagement/Instances/MinecraftInstanceExtensions.cs +++ b/Natsurainko.FluentCore/GameManagement/Instances/MinecraftInstanceExtensions.cs @@ -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 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; @@ -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;