Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Plain Craft Launcher 2/Modules/Minecraft/ModModpack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static LoaderCombo<string> ModpackInstall(string file, string instanceNam

// 获取整合包种类与关键 Json
var packType = -1;
ZipArchiveEntry nestedModpackEntry = null;
do
{
try
Expand Down Expand Up @@ -117,12 +118,18 @@ public static LoaderCombo<string> ModpackInstall(string file, string instanceNam
break;
} // HMCL 整合包

if (archive.GetEntry("modpack.zip") is not null || archive.GetEntry("modpack.mrpack") is not null)
if (archive.GetEntry("modpack.zip") is not null)
{
packType = 9;
break;
} // 带启动器的压缩包

nestedModpackEntry = archive.GetEntry("modpack.mrpack");
if (nestedModpackEntry is not null)
{
break;
}

// 从一级目录判断整合包类型
var exitTry = false;
foreach (var Entry in archive.Entries)
Expand Down Expand Up @@ -178,12 +185,19 @@ public static LoaderCombo<string> ModpackInstall(string file, string instanceNam
break;
} // HMCL 整合包

if (fullNames[1] == "modpack.zip" || fullNames[1] == "modpack.mrpack")
if (fullNames[1] == "modpack.zip")
{
packType = 9;
exitTry = true;
break;
} // 带启动器的压缩包

if (fullNames[1] == "modpack.mrpack")
{
nestedModpackEntry = Entry;
exitTry = true;
break;
}
}

if (exitTry) break;
Expand All @@ -199,6 +213,15 @@ public static LoaderCombo<string> ModpackInstall(string file, string instanceNam
}
} while (false);

if (nestedModpackEntry is not null)
{
var tempFile = Path.Combine(ModMain.RequestTaskTempFolder(), "modpack.mrpack");
nestedModpackEntry.ExtractToFile(tempFile, overwrite: true);
archive.Dispose();
archive = null;
return ModpackInstall(tempFile, instanceName, logo, resourceId, isOnlineInstall);
}

// 执行对应的安装方法
switch (packType)
{
Expand Down
Loading