From 7ba79db82c59332dccc9f1f638c121800fc5d206 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sat, 15 Jun 2024 21:34:02 +0800 Subject: [PATCH 01/36] =?UTF-8?q?feat(neoforge):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=20NeoForge=20=E7=9A=84=E5=AE=89=E8=A3=85=E9=80=89?= =?UTF-8?q?=E9=A1=B9=EF=BC=8C=E5=B9=B6=E6=94=AF=E6=8C=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 226 +++++++ .../Pages/PageDownload/ModDownloadLib.vb | 624 ++++++++++++++++++ .../PageDownload/PageDownloadInstall.xaml | 19 + .../PageDownload/PageDownloadInstall.xaml.vb | 134 +++- 4 files changed, 1002 insertions(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 10cfdbb9..9e9ea6aa 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -721,6 +721,232 @@ #End Region +#Region "DlNeoForgeVersion | NeoForge 版本列表" + + Public Class DlNeoForgeVersionEntry + ''' + ''' 完整的版本名,如 “14.22.1.2478”。 + ''' + Public Version As String + ''' + ''' 对应的 Minecraft 版本,如“1.12.2”。 + ''' + Public Inherit As String + ''' + ''' 发布时间,格式为“yyyy/MM/dd HH:mm”。 + ''' + Public ReleaseTime As String + ''' + ''' 文件的 MD5 或 SHA1(BMCLAPI 的老版本是 MD5,新版本是 SHA1;官方源总是 MD5)。 + ''' + Public Hash As String = Nothing + ''' + ''' 安装类型。有 installer、client、universal 三种。 + ''' + Public Category As String + ''' + ''' 版本分支。若无分支则为 Nothing。 + ''' + Public Branch As String = Nothing + Public Structure DlNeoForgeListResult + ''' + ''' 数据来源名称,如“Official”,“BMCLAPI”。 + ''' + Public SourceName As String + ''' + ''' 是否为官方的实时数据。 + ''' + Public IsOfficial As Boolean + ''' + ''' 获取到的数据。 + ''' + Public Value As JObject + End Structure + ''' + ''' 是否为新版 Forge。(即为 Minecraft 1.13+) + ''' + Public ReadOnly Property IsNewType As Boolean + Get + Return Version.Split(".")(0) >= 20 + End Get + End Property + ''' + ''' 构建数。 + ''' + Public ReadOnly Property Build As Integer + Get + Dim Version = Me.Version.Split(".") + If Version(0) < 15 Then + Return Version(Version.Count - 1) + Else + Return Version(Version.Count - 1) + 10000 + End If + End Get + End Property + ''' + ''' 用于下载的文件版本名。可能在 Version 的基础上添加了分支。 + ''' + Public ReadOnly Property FileVersion As String + Get + Return Version & If(Branch Is Nothing, "", "-" & Branch) + End Get + End Property + ''' + ''' 即将下载的文件全名。 + ''' + Public ReadOnly Property FileName As String + Get + Return "forge-" & Inherit & "-" & FileVersion & "-" & Category & "." & FileSuffix + End Get + End Property + ''' + ''' 文件扩展名。 + ''' + Public ReadOnly Property FileSuffix As String + Get + If Category = "installer" Then + Return "jar" + Else + Return "zip" + End If + End Get + End Property + End Class + + ''' + ''' NeoForge 版本列表,主加载器。 + ''' + Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) + Dim DlNeoForgeVersionOfficialLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Official", AddressOf DlNeoForgeVersionOfficialMain) + Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) + Select Case Setup.Get("ToolDownloadVersion") + Case 0 + DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 30), + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60) + }, Loader.IsForceRestarting) + Case 1 + DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 5), + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 35) + }, Loader.IsForceRestarting) + Case Else + DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60), + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 60) + }, Loader.IsForceRestarting) + End Select + End Sub + + ''' + ''' NeoForge 版本列表,官方源。 + ''' + Public Sub DlNeoForgeVersionOfficialMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) + Dim Result As String + Dim ResultJson As JObject + Try + Result = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True) + Catch ex As Exception + If GetExceptionSummary(ex).Contains("(404)") Then + Throw New Exception("没有可用版本") + Else + Throw + End If + End Try + If Result.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & Result & ")") + ResultJson = GetJson(Result) + Dim Versions As New List(Of DlNeoForgeVersionEntry) + Dim VersionList As String = ResultJson("versions") + MyMsgBox(VersionList, "VersionList 获取测试") + 'Try + ' Try + ' '基础信息获取 + ' Dim Name As String = RegexSeek(VersionCode, "(?<=[^(0-9)]+)[0-9\.]+") + ' Dim IsRecommended As Boolean = VersionCode.Contains("fa promo-recommended") + ' Dim Inherit As String = Loader.Input + ' '分支获取 + ' Dim Branch As String = RegexSeek(VersionCode, $"(?<=-{Name}-)[^-""]+(?=-[a-z]+.[a-z]{{3}})") + ' If String.IsNullOrWhiteSpace(Branch) Then Branch = Nothing + ' '发布时间获取 + ' Dim ReleaseTimeOriginal = RegexSeek(VersionCode, "(?<=""download-time"" title="")[^""]+") + ' Dim ReleaseTimeSplit = ReleaseTimeOriginal.Split(" -:".ToCharArray) '原格式:"2021-02-15 03:24:02" + ' Dim ReleaseDate As New Date(ReleaseTimeSplit(0), ReleaseTimeSplit(1), ReleaseTimeSplit(2), '年月日 + ' ReleaseTimeSplit(3), ReleaseTimeSplit(4), ReleaseTimeSplit(5), '时分秒 + ' 0, DateTimeKind.Utc) '以 UTC 时间作为标准 + ' Dim ReleaseTime As String = ReleaseDate.ToLocalTime.ToString("yyyy'/'MM'/'dd HH':'mm") '时区与格式转换 + ' '添加进列表 + ' Versions.Add(New DlNeoForgeVersionEntry With {.Category = Category, .Version = Name, .Hash = MD5.Trim(vbCr, vbLf), .Inherit = Inherit, .ReleaseTime = ReleaseTime, .Branch = Branch}) + ' Catch ex As Exception + ' Throw New Exception("版本信息提取失败(" & VersionCode & ")", ex) + ' End Try + 'Catch ex As Exception + ' Throw New Exception("版本列表解析失败(" & Result & ")", ex) + 'End Try + If Not Versions.Any() Then Throw New Exception("没有可用版本") + Loader.Output = Versions + End Sub + + ''' + ''' NeoForge 版本列表,BMCLAPI。 + ''' + Public Sub DlNeoForgeVersionBmclapiMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) + Dim Json As JArray = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/neoforge/list/" & Loader.Input, IsJson:=True) + Dim Versions As New List(Of DlNeoForgeVersionEntry) + Try + For Each Token As JObject In Json + Dim Name As String = Token("version") + Dim Inherit As String = Token("mcversion") + Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit} + Versions.Add(Entry) + Next + 'For Each Token As JObject In Json + ' '分类与 Hash 获取 + ' Dim Hash As String = Nothing, Category As String = "unknown", Proi As Integer = -1 + ' For Each File As JObject In Token("files") + ' Select Case File("category").ToString + ' Case "installer" + ' If File("format").ToString = "jar" Then + ' '类型为 installer.jar,支持范围 ~753 (~ 1.6.1 部分), 738~684 (1.5.2 全部) + ' Hash = File("hash") + ' Category = "installer" + ' Proi = 2 + ' End If + ' Case "universal" + ' If Proi <= 1 AndAlso File("format").ToString = "zip" Then + ' '类型为 universal.zip,支持范围 751~449 (1.6.1 部分), 682~183 (1.5.1 ~ 1.3.2 部分) + ' Hash = File("hash") + ' Category = "universal" + ' Proi = 1 + ' End If + ' Case "client" + ' If Proi <= 0 AndAlso File("format").ToString = "zip" Then + ' '类型为 client.zip,支持范围 182~ (1.3.2 部分 ~) + ' Hash = File("hash") + ' Category = "client" + ' Proi = 0 + ' End If + ' End Select + ' Next + ' '获取 Entry + ' Dim Inherit As String = Loader.Input + ' Dim Branch As String = Token("branch") + ' Dim Name As String = Token("version") + ' '基础信息获取 + ' Dim Entry = New DlNeoForgeVersionEntry With {.Hash = Hash, .Category = Category, .Version = Name, .Branch = Branch, .Inherit = Inherit} + ' Dim TimeSplit = Token("modified").ToString.Split("-"c, "T"c, ":"c, "."c, " "c, "/"c) + ' Entry.ReleaseTime = Token("modified").ToObject(Of Date).ToLocalTime.ToString("yyyy'/'MM'/'dd HH':'mm") + ' '添加项 + ' Versions.Add(Entry) + 'Next + Catch ex As Exception + Throw New Exception("版本列表解析失败(" & Json.ToString & ")", ex) + End Try + If Not Versions.Any() Then Throw New Exception("没有可用版本") + Loader.Output = Versions + End Sub + +#End Region + #Region "DlLiteLoaderList | LiteLoader 版本列表" Public Structure DlLiteLoaderListResult diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 3b02dc6c..6f6a3310 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1696,6 +1696,630 @@ Retry: #End Region +#Region "NeoForge 下载" + + Public Sub McDownloadNeoForge(DownloadInfo As DlNeoForgeVersionEntry) + '老版本提示 + If DownloadInfo.Category = "client" Then + If MyMsgBox("该 Forge 版本过于古老,PCL 暂不支持该版本的自动安装。" & vbCrLf & + "若你仍然希望继续,PCL 将把安装程序下载到你指定的位置,但不会进行安装。", + "版本过老", "继续", "取消") = 1 Then + McDownloadNeoForgeSave(DownloadInfo) + End If + Exit Sub + End If + If DownloadInfo.Category = "universal" OrElse DownloadInfo.Inherit.StartsWithF("1.5") Then '对该版本自动安装的支持将在之后加入 + If MyMsgBox("该 Forge 版本过于古老,PCL 暂不支持该版本的自动安装。" & vbCrLf & + "若你仍然希望继续,PCL 将把安装程序下载到你指定的位置,但不会进行安装。", + "版本过老", "继续", "取消") = 1 Then + McDownloadNeoForgeSave(DownloadInfo) + End If + Exit Sub + End If + '初始化参数 + Dim Id As String = DownloadInfo.Inherit & "-neoforge-" & DownloadInfo.Version + Dim Target As String = PathTemp & "Cache\Code\NeoForgeInstall-" & DownloadInfo.Version & "_" & GetUuid() & "." & DownloadInfo.FileSuffix + Dim VersionFolder As String = PathMcFolder & "versions\" & Id & "\" + Dim DisplayName As String = "Forge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version + Try + + '重复任务检查 + SyncLock LoaderTaskbarLock + For i = 0 To LoaderTaskbar.Count - 1 + If LoaderTaskbar(i).Name = DisplayName & " 下载" Then + Hint("该版本正在下载中!", HintType.Critical) + Exit Sub + End If + Next + End SyncLock + + '已有版本检查 + If File.Exists(VersionFolder & Id & ".json") Then + If MyMsgBox("版本 " & Id & " 已存在,是否重新下载?" & vbCrLf & "这会覆盖版本的 json 和 jar 文件,但不会影响版本隔离的文件。", "版本已存在", "继续", "取消") = 1 Then + File.Delete(VersionFolder & Id & ".jar") + File.Delete(VersionFolder & Id & ".json") + Else + Exit Sub + End If + End If + + '启动 + Dim Loader As New LoaderCombo(Of String)(DisplayName & " 下载", McDownloadNeoForgeLoader(DownloadInfo.Version, DownloadInfo.Inherit, DownloadInfo)) With {.OnStateChanged = AddressOf McInstallState} + Loader.Start(VersionFolder) + LoaderTaskbarAdd(Loader) + FrmMain.BtnExtraDownload.ShowRefresh() + FrmMain.BtnExtraDownload.Ribble() + + Catch ex As Exception + Log(ex, "开始 NeoForge 下载失败", LogLevel.Feedback) + Finally + '删除安装包 + Try + If File.Exists(Target) Then File.Delete(Target) + Catch + End Try + End Try + End Sub + Public Sub McDownloadNeoForgeSave(DownloadInfo As DlNeoForgeVersionEntry) + Try + Dim Target As String = SelectAs("选择保存位置", DownloadInfo.FileName, "NeoForge 文件 (*." & DownloadInfo.FileSuffix & ")|*." & DownloadInfo.FileSuffix) + Dim DisplayName As String = "Forge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version + If Not Target.Contains("\") Then Exit Sub + + '重复任务检查 + SyncLock LoaderTaskbarLock + For i = 0 To LoaderTaskbar.Count - 1 + If LoaderTaskbar(i).Name = DisplayName & " 下载" Then + Hint("该版本正在下载中!", HintType.Critical) + Exit Sub + End If + Next + End SyncLock + + '构造步骤加载器 + Dim Loaders As New List(Of LoaderBase) + '获取下载地址 + Loaders.Add(New LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))("获取下载地址", + Sub(Task As LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))) + Dim Files As New List(Of NetFile) + Files.Add(New NetFile({ + "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, + "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName + }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) + Task.Output = Files + End Sub) With {.ProgressWeight = 0.1, .Show = False}) + '下载 + Loaders.Add(New LoaderDownload("下载主文件", New List(Of NetFile)) With {.ProgressWeight = 6}) + + '启动 + Dim Loader As New LoaderCombo(Of DlForgeVersionEntry)(DisplayName & " 下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave} + Loader.Start(DownloadInfo) + LoaderTaskbarAdd(Loader) + FrmMain.BtnExtraDownload.ShowRefresh() + FrmMain.BtnExtraDownload.Ribble() + + Catch ex As Exception + Log(ex, "开始 NeoForge 下载失败", LogLevel.Feedback) + End Try + End Sub + + Private Sub NeoForgeInjector(Target As String, Task As LoaderTask(Of Boolean, Boolean), McFolder As String, UseJavaWrapper As Boolean) + '选择 Java + Dim Java As JavaEntry + SyncLock JavaLock + Java = JavaSelect("已取消安装。", New Version(1, 8, 0, 60)) + If Java Is Nothing Then + If Not JavaDownloadConfirm("Java 8 或更高版本") Then Throw New Exception("由于未找到 Java,已取消安装。") + '开始自动下载 + Dim JavaLoader = JavaFixLoaders(17) + Try + JavaLoader.Start(17, IsForceRestart:=True) + Do While JavaLoader.State = LoadState.Loading AndAlso Not Task.IsAborted + Thread.Sleep(10) + Loop + Finally + JavaLoader.Abort() '确保取消时中止 Java 下载 + End Try + '检查下载结果 + Java = JavaSelect("已取消安装。", New Version(1, 8, 0, 60)) + If Task.IsAborted Then Exit Sub + If Java Is Nothing Then Throw New Exception("由于未找到 Java,已取消安装。") + End If + End SyncLock + '添加 Java Wrapper 作为主 Jar + Dim Arguments As String + If UseJavaWrapper Then + Arguments = $"-Doolloo.jlw.tmpdir=""{GetJavaWrapperDir()}"" -cp ""{PathTemp}Cache\forge_installer.jar;{Target}"" -jar ""{ExtractJavaWrapper()}"" com.bangbang93.ForgeInstaller ""{McFolder}" + Else + Arguments = $"-cp ""{PathTemp}Cache\forge_installer.jar;{Target}"" com.bangbang93.ForgeInstaller ""{McFolder}" + End If + If Java.VersionCode >= 9 Then Arguments = "--add-exports cpw.mods.bootstraplauncher/cpw.mods.bootstraplauncher=ALL-UNNAMED " & Arguments + '开始启动 + SyncLock InstallSyncLock + Dim Info = New ProcessStartInfo With { + .FileName = Java.PathJavaw, + .Arguments = Arguments, + .UseShellExecute = False, + .CreateNoWindow = True, + .RedirectStandardError = True, + .RedirectStandardOutput = True + } + Log("[Download] 开始安装 NeoForge:" & Arguments) + Dim process As New Process With {.StartInfo = Info} + Dim LastResults As New Queue(Of String) + Using outputWaitHandle As New AutoResetEvent(False) + Using errorWaitHandle As New AutoResetEvent(False) + AddHandler process.OutputDataReceived, + Function(sender, e) + Try + If e.Data Is Nothing Then + outputWaitHandle.[Set]() + Else + LastResults.Enqueue(e.Data) + If LastResults.Count > 100 Then LastResults.Dequeue() + NeoForgeInjectorLine(e.Data, Task) + End If + Catch ex As ObjectDisposedException + Catch ex As Exception + Log(ex, "读取 NeoForge 安装器信息失败") + End Try + Try + If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then + Log("[Installer] 由于任务取消,已中止 NeoForge 安装") + process.Kill() + End If + Catch + End Try + Return Nothing + End Function + AddHandler process.ErrorDataReceived, + Function(sender, e) + Try + If e.Data Is Nothing Then + errorWaitHandle.[Set]() + Else + LastResults.Enqueue(e.Data) + If LastResults.Count > 100 Then LastResults.Dequeue() + ForgeInjectorLine(e.Data, Task) + End If + Catch ex As ObjectDisposedException + Catch ex As Exception + Log(ex, "读取 Forge 安装器错误信息失败") + End Try + Try + If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then + Log("[Installer] 由于任务取消,已中止 Forge 安装") + process.Kill() + End If + Catch + End Try + Return Nothing + End Function + process.Start() + process.BeginOutputReadLine() + process.BeginErrorReadLine() + '等待 + Do Until process.HasExited + Thread.Sleep(10) + Loop + '输出 + outputWaitHandle.WaitOne(10000) + errorWaitHandle.WaitOne(10000) + process.Dispose() + '检查是否安装成功:最后两行中是否有 true(true 可能在倒数第二行,见 #832) + If LastResults.Last = "true" OrElse (LastResults.Count >= 2 AndAlso LastResults(LastResults.Count - 2) = "true") Then Exit Sub + Log(Join(LastResults, vbCrLf)) + Dim LastLines As String = "" + For i As Integer = Math.Max(0, LastResults.Count - 5) To LastResults.Count - 1 '最后 5 行 + LastLines &= vbCrLf & LastResults(i) + Next + Throw New Exception("Forge 安装器出错,日志结束部分为:" & LastLines) + End Using + End Using + End SyncLock + End Sub + Private Sub NeoForgeInjectorLine(Content As String, Task As LoaderTask(Of Boolean, Boolean)) + If Content.StartsWithF(" Data") OrElse Content.StartsWithF(" Slim") Then + If ModeDebug Then Log("[Installer] " & Content) + ElseIf Content.StartsWithF(" Reading patch ") Then + If ModeDebug Then Log("[Installer] " & Content) + Task.Progress = 0.86 + Else + Select Case Content + Case "Extracting json" + Log("[Installer] " & Content) + Task.Progress = 0.07 + Case "Downloading libraries" + Log("[Installer] " & Content) + Task.Progress = 0.08 + Case " File exists: Checksum validated." + If ModeDebug Then Log("[Installer] " & Content) + Task.Progress += 0.003 + Case "Building Processors" + Task.Progress = 0.38 + Case "Task: DOWNLOAD_MOJMAPS" 'B + Task.Progress = 0.4 + Case "Task: MERGE_MAPPING" 'B + Task.Progress = 0.6 + Case "Splitting: " + Task.Progress = 0.62 + Case "Parameter Annotations" 'B + Task.Progress = 0.66 + Case "Processing Complete" 'B + Task.Progress = 0.7 + Case "Remapping final jar" 'A + Task.Progress = 0.72 + Case "Remapping jar... 50%" 'A + Task.Progress = 0.76 + Case "Remapping jar... 100%" 'A + Task.Progress = 0.81 + Case "Injecting profile" + Task.Progress = 0.91 + Case Else + If ModeDebug Then Log("[Installer] " & Content) + Exit Sub + End Select + Log("[Installer] " & Content) + End If + End Sub + + ''' + ''' 获取下载某个 NeoForge 版本的加载器列表。 + ''' + Private Function McDownloadNeoForgeLoader(Version As String, Inherit As String, Optional DownloadInfo As DlNeoForgeVersionEntry = Nothing, Optional McFolder As String = Nothing, Optional ClientDownloadLoader As LoaderCombo(Of String) = Nothing, Optional ClientFolder As String = Nothing, Optional FixLibrary As Boolean = True) As List(Of LoaderBase) + + '参数初始化 + McFolder = If(McFolder, PathMcFolder) + If Version.StartsWithF("1.") AndAlso Version.Contains("-") Then + '类似 1.19.3-41.2.8 格式,优先使用 Version 中要求的版本而非 Inherit(例如 1.19.3 却使用了 1.19 的 Forge) + Inherit = Version.Before("-") + Version = Version.After("-") + End If + Dim IsCustomFolder As Boolean = McFolder <> PathMcFolder + Dim Id As String = Inherit & "-forge-" & Version + Dim InstallerAddress As String = PathTemp & "Cache\Code\NeoForgeInstall-" & Version & "_" & RandomInteger(0, 100000) + Dim VersionFolder As String = McFolder & "versions\" & Id & "\" + Dim DisplayName As String = "Forge " & Inherit & " - " & Version + Dim Loaders As New List(Of LoaderBase) + Dim LibVersionFolder As String = PathMcFolder & "versions\" & Id & "\" '作为 Lib 文件目标的版本文件夹 + + '获取下载信息 + If DownloadInfo Is Nothing Then + Loaders.Add(New LoaderTask(Of String, String)("获取 Mod 加载器详细信息", + Sub(Task As LoaderTask(Of String, String)) + '获取 Forge 版本列表 + Dim NeoForgeLoader = New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("McDownloadNeoForgeLoader " & Inherit, AddressOf DlNeoForgeVersionMain) + NeoForgeLoader.WaitForExit(Inherit) + Task.Progress = 0.8 + '查找对应版本 + For Each NeoForgeVersion In NeoForgeLoader.Output + If NeoForgeVersion.Version = Version Then + DownloadInfo = NeoForgeVersion + Exit Sub + End If + Next + Throw New Exception("未能找到 NeoForge " & Inherit & "-" & Version & " 的详细信息!") + End Sub) With {.ProgressWeight = 3}) + End If + '下载 Forge 主文件 + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("准备 Mod 加载器下载", + Sub(Task As LoaderTask(Of String, List(Of NetFile))) + '启动依赖版本的下载 + If ClientDownloadLoader Is Nothing Then + If IsCustomFolder Then Throw New Exception("如果没有指定原版下载器,则不能指定 MC 安装文件夹") + ClientDownloadLoader = McDownloadClient(NetPreDownloadBehaviour.ExitWhileExistsOrDownloading, Inherit) + End If + '添加主文件 + Dim Files As New List(Of NetFile) From {New NetFile({ + "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, + "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName + }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} + Task.Output = Files + End Sub) With {.ProgressWeight = 0.5, .Show = False}) + Loaders.Add(New LoaderDownload("下载 Mod 加载器主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) + + '安装(仅在新版安装时需要原版 Jar) + If Version.Before(".") >= 20 Then + Log("[Download] 检测为新版 NeoForge:" & Version) + Dim Libs As List(Of McLibToken) = Nothing + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Mod 加载器支持库文件", + Sub(Task As LoaderTask(Of String, List(Of NetFile))) + Task.Output = New List(Of NetFile) + Dim Installer As ZipArchive = Nothing + Try + '解压并获取、合并两个 Json 的信息 + Installer = New ZipArchive(New FileStream(InstallerAddress, FileMode.Open)) + Task.Progress = 0.2 + Dim Json As JObject = GetJson(ReadFile(Installer.GetEntry("install_profile.json").Open)) + Dim Json2 As JObject = GetJson(ReadFile(Installer.GetEntry("version.json").Open)) + Json.Merge(Json2) + '获取 Lib 下载信息 + Libs = McLibListGetWithJson(Json, True) + '添加 Mappings 下载信息 + If Json("data") IsNot Nothing AndAlso Json("data")("MOJMAPS") IsNot Nothing Then + '下载原版 Json 文件 + Task.Progress = 0.4 + Dim RawJson As JObject = GetJson(NetGetCodeByDownload(DlSourceLauncherOrMetaGet(DlClientListGet(Inherit)), IsJson:=True)) + '[net.minecraft:client:1.17.1-20210706.113038:mappings@txt] 或 @tsrg] + Dim OriginalName As String = Json("data")("MOJMAPS")("client").ToString.Trim("[]".ToCharArray()).Before("@") + Dim Address = McLibGet(OriginalName).Replace(".jar", "-mappings." & Json("data")("MOJMAPS")("client").ToString.Trim("[]".ToCharArray()).Split("@")(1)) + Libs.Add(New McLibToken With {.IsJumpLoader = False, .IsNatives = False, .LocalPath = Address, .OriginalName = OriginalName, + .Url = RawJson("downloads")("client_mappings")("url"), .Size = RawJson("downloads")("client_mappings")("size"), .SHA1 = RawJson("downloads")("client_mappings")("sha1")}) + Log("[Download] 需要下载 Mappings:" & Address) + End If + Task.Progress = 0.8 + '去除其中的原始 Forge 项 + For i = 0 To Libs.Count - 1 + If Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & ".jar") OrElse + Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & "-client.jar") Then + Log("[Download] 已从待下载 Forge 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug) + Libs.RemoveAt(i) + Exit For + End If + Next + Task.Output = McLibFixFromLibToken(Libs, PathMcFolder) + Catch ex As Exception + Throw New Exception("获取新版 Forge 支持库列表失败", ex) + Finally + '释放文件 + If Installer IsNot Nothing Then Installer.Dispose() + End Try + End Sub) With {.ProgressWeight = 2}) + Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) + Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 Mod 下载器支持库文件", + Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) +#Region "Forge 文件" + If IsCustomFolder Then + For Each LibFile As McLibToken In Libs + Dim RealPath As String = LibFile.LocalPath.Replace(PathMcFolder, McFolder) + If Not File.Exists(RealPath) Then + Directory.CreateDirectory(IO.Path.GetDirectoryName(RealPath)) + CopyFile(LibFile.LocalPath, RealPath) + End If + If ModeDebug Then Log("[Download] 复制的 Forge 支持库文件:" & LibFile.LocalPath) + Next + End If +#End Region +#Region "原版文件" + '等待原版文件下载完成 + If ClientDownloadLoader Is Nothing Then Exit Sub + Dim TargetLoaders As List(Of LoaderBase) = + ClientDownloadLoader.GetLoaderList.Where(Function(l) l.Name = McDownloadClientLibName OrElse l.Name = McDownloadClientJsonName). + Where(Function(l) l.State <> LoadState.Finished).ToList + If TargetLoaders.Any Then Log("[Download] Forge 安装正在等待原版文件下载完成") + Do While TargetLoaders.Any AndAlso Not Task.IsAborted + TargetLoaders = TargetLoaders.Where(Function(l) l.State <> LoadState.Finished).ToList + Thread.Sleep(50) + Loop + If Task.IsAborted Then Exit Sub + '拷贝原版文件 + If Not IsCustomFolder Then Exit Sub + SyncLock VanillaSyncLock + Dim ClientName As String = GetFolderNameFromPath(ClientFolder) + Directory.CreateDirectory(McFolder & "versions\" & Inherit) + If Not File.Exists(McFolder & "versions\" & Inherit & "\" & Inherit & ".json") Then + CopyFile(ClientFolder & ClientName & ".json", McFolder & "versions\" & Inherit & "\" & Inherit & ".json") + End If + If Not File.Exists(McFolder & "versions\" & Inherit & "\" & Inherit & ".jar") Then + CopyFile(ClientFolder & ClientName & ".jar", McFolder & "versions\" & Inherit & "\" & Inherit & ".jar") + End If + End SyncLock +#End Region + End Sub) With {.ProgressWeight = 0.1, .Show = False}) + Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 Mod 加载器(方式 A)", + Sub(Task As LoaderTask(Of Boolean, Boolean)) + Dim Installer As ZipArchive = Nothing + Try + Log("[Download] 开始进行新版方式 Forge 安装:" & InstallerAddress) + '记录当前文件夹列表(在新建目标文件夹之前) + Dim OldList = New DirectoryInfo(McFolder & "versions\").EnumerateDirectories. + Select(Function(i) i.FullName).ToList() + '解压并获取信息 + Installer = New ZipArchive(New FileStream(InstallerAddress, FileMode.Open)) + Dim Json As JObject = GetJson(ReadFile(Installer.GetEntry("install_profile.json").Open)) + '新建目标版本文件夹 + Directory.CreateDirectory(VersionFolder) + Task.Progress = 0.04 + '释放 launcher_installer.json + McFolderLauncherProfilesJsonCreate(McFolder) + Task.Progress = 0.05 + '运行 Forge 安装器 + Dim UseJavaWrapper As Boolean = True +Retry: + Try + '释放 Forge 注入器 + WriteFile(PathTemp & "Cache\forge_installer.jar", GetResources("ForgeInstaller")) + Task.Progress = 0.06 + '运行注入器 + ForgeInjector(InstallerAddress, Task, McFolder, UseJavaWrapper) + Task.Progress = 0.97 + Catch ex As Exception + If UseJavaWrapper Then + Log(ex, "使用 JavaWrapper 安装 Forge 失败,将不使用 JavaWrapper 并重试") + UseJavaWrapper = False + GoTo Retry + Else + Throw New Exception("运行 Forge 安装器失败", ex) + End If + End Try + '拷贝新增的版本 Json + Dim DeltaList = New DirectoryInfo(McFolder & "versions\").EnumerateDirectories. + SkipWhile(Function(i) OldList.Contains(i.FullName)).ToList() + If DeltaList.Count > 1 Then + '它可能和 OptiFine 安装同时运行,导致增加的文件不止一个(这导致了 #151) + '也可能是因为 Forge 安装器的 Bug,生成了一个名字错误的文件夹,所以需要检查文件夹是否为空 + DeltaList = DeltaList.Where(Function(l) l.Name.Contains("forge") AndAlso l.EnumerateFiles.Any).ToList + End If + If DeltaList.Count = 1 Then '如果没有新增文件夹,那么预测的文件夹名就是正确的 + Dim JsonFile As FileInfo = DeltaList(0).EnumerateFiles.First() + WriteFile(VersionFolder & Id & ".json", ReadFile(JsonFile.FullName)) + End If + '新建 mods 文件夹 + Directory.CreateDirectory(New McVersion(VersionFolder).GetPathIndie(True) & "mods\") + Catch ex As Exception + Throw New Exception("安装新 Forge 版本失败", ex) + Finally + '清理文件 + Try + If Installer IsNot Nothing Then Installer.Dispose() + If File.Exists(InstallerAddress) Then File.Delete(InstallerAddress) + Catch ex As Exception + Log(ex, "安装 Forge 清理文件时出错") + End Try + End Try + End Sub) With {.ProgressWeight = 10}) + Else + Log("[Download] 检测为非新版 Forge:" & Version) + Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("安装 Mod 加载器(方式 B)", + Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) + Dim Installer As ZipArchive = Nothing + Try + '解压并获取信息 + Installer = New ZipArchive(New FileStream(InstallerAddress, FileMode.Open)) + Task.Progress = 0.2 + Dim Json As JObject = GetJson(ReadFile(Installer.GetEntry("install_profile.json").Open)) + Task.Progress = 0.4 + '新建版本文件夹 + Directory.CreateDirectory(VersionFolder) + Task.Progress = 0.5 + If Json("install") Is Nothing Then + '中版格式 + Log("[Download] 进行中版方式安装:" & InstallerAddress) + '建立 Json 文件 + Dim JsonVersion As JObject = GetJson(ReadFile(Installer.GetEntry(Json("json").ToString.TrimStart("/")).Open)) + JsonVersion("id") = Id + WriteFile(VersionFolder & Id & ".json", JsonVersion.ToString) + Task.Progress = 0.6 + '解压支持库文件 + Installer.Dispose() + ExtractFile(InstallerAddress, InstallerAddress & "_unrar\") + CopyDirectory(InstallerAddress & "_unrar\maven\", McFolder & "libraries\") + DeleteDirectory(InstallerAddress & "_unrar\") + Else + '旧版格式 + Log("[Download] 进行旧版方式安装:" & InstallerAddress) + '解压 Jar 文件 + Dim JarAddress As String = McLibGet(Json("install")("path"), CustomMcFolder:=McFolder) + If File.Exists(JarAddress) Then File.Delete(JarAddress) + WriteFile(JarAddress, Installer.GetEntry(Json("install")("filePath")).Open) + Task.Progress = 0.9 + '建立 Json 文件 + Json("versionInfo")("id") = Id + If Json("versionInfo")("inheritsFrom") Is Nothing Then CType(Json("versionInfo"), JObject).Add("inheritsFrom", Inherit) + WriteFile(VersionFolder & Id & ".json", Json("versionInfo").ToString) + End If + '新建 mods 文件夹 + Directory.CreateDirectory(New McVersion(VersionFolder).GetPathIndie(True) & "mods\") + Catch ex As Exception + Throw New Exception("非新版方式安装 Forge 失败", ex) + Finally + Try + '清理文件 + If Installer IsNot Nothing Then Installer.Dispose() + If File.Exists(InstallerAddress) Then File.Delete(InstallerAddress) + If Directory.Exists(InstallerAddress & "_unrar\") Then DeleteDirectory(InstallerAddress & "_unrar\") + Catch ex As Exception + Log(ex, "非新版方式安装 Forge 清理文件时出错") + End Try + End Try + End Sub) With {.ProgressWeight = 1}) + If FixLibrary Then + If IsCustomFolder Then Throw New Exception("若需要补全支持库,就不能自定义 MC 文件夹") + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Mod 加载器支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(VersionFolder))) With {.ProgressWeight = 1, .Show = False}) + Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 11}) + End If + End If + + Return Loaders + End Function + +#End Region + +#Region "NeoForge 下载菜单" + + Public Sub NeoForgeDownloadListItemPreload(Stack As StackPanel, Entrys As List(Of DlNeoForgeVersionEntry), OnClick As MyListItem.ClickEventHandler, IsSaveOnly As Boolean) + '获取最新版本 + Dim FreshVersion As DlNeoForgeVersionEntry = Nothing + If Entrys.Any Then + FreshVersion = Entrys(0) + Else + Log("[System] 未找到可用的 NeoForge 版本", LogLevel.Debug) + End If + Dim RecommendedVersion As DlNeoForgeVersionEntry = Nothing + '显示各个版本 + If FreshVersion IsNot Nothing Then + Dim Fresh = NeoForgeDownloadListItem(FreshVersion, OnClick, IsSaveOnly) + Fresh.Info = "最新版" & If(Fresh.Info = "", "", "," & Fresh.Info) + Stack.Children.Add(Fresh) + End If + '添加间隔 + Stack.Children.Add(New TextBlock With {.Text = "全部版本 (" & Entrys.Count & ")", .HorizontalAlignment = HorizontalAlignment.Left, .Margin = New Thickness(6, 13, 0, 4)}) + End Sub + Public Function NeoForgeDownloadListItem(Entry As DlNeoForgeVersionEntry, OnClick As MyListItem.ClickEventHandler, IsSaveOnly As Boolean) As MyListItem + '建立控件 + Dim NewItem As New MyListItem With { + .Title = Entry.Version, .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, + .Info = If(Entry.ReleaseTime = "", + If(ModeDebug, "种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), + "发布于 " & Entry.ReleaseTime & If(ModeDebug, ",种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), + .Logo = PathImage & "Blocks/Anvil.png" + } + AddHandler NewItem.Click, OnClick + '建立菜单 + If IsSaveOnly Then + NewItem.ContentHandler = AddressOf NeoForgeSaveContMenuBuild + Else + NewItem.ContentHandler = AddressOf NeoForgeContMenuBuild + End If + '结束 + Return NewItem + End Function + Private Sub NeoForgeContMenuBuild(sender As MyListItem, e As EventArgs) + Dim BtnSave As New MyIconButton With {.Logo = Logo.IconButtonSave, .ToolTip = "另存为"} + ToolTipService.SetPlacement(BtnSave, Primitives.PlacementMode.Center) + ToolTipService.SetVerticalOffset(BtnSave, 30) + ToolTipService.SetHorizontalOffset(BtnSave, 2) + AddHandler BtnSave.Click, AddressOf NeoForgeSave_Click + Dim BtnInfo As New MyIconButton With {.LogoScale = 1.05, .Logo = Logo.IconButtonInfo, .ToolTip = "更新日志"} + ToolTipService.SetPlacement(BtnInfo, Primitives.PlacementMode.Center) + ToolTipService.SetVerticalOffset(BtnInfo, 30) + ToolTipService.SetHorizontalOffset(BtnInfo, 2) + AddHandler BtnInfo.Click, AddressOf NeoForgeLog_Click + sender.Buttons = {BtnSave, BtnInfo} + End Sub + Private Sub NeoForgeSaveContMenuBuild(sender As MyListItem, e As EventArgs) + Dim BtnInfo As New MyIconButton With {.LogoScale = 1.05, .Logo = Logo.IconButtonInfo, .ToolTip = "更新日志"} + ToolTipService.SetPlacement(BtnInfo, Primitives.PlacementMode.Center) + ToolTipService.SetVerticalOffset(BtnInfo, 30) + ToolTipService.SetHorizontalOffset(BtnInfo, 2) + AddHandler BtnInfo.Click, AddressOf NeoForgeLog_Click + sender.Buttons = {BtnInfo} + End Sub + Private Sub NeoForgeLog_Click(sender As Object, e As RoutedEventArgs) + Dim Version As DlForgeVersionEntry + If sender.Tag IsNot Nothing Then + Version = sender.Tag + ElseIf sender.Parent.Tag IsNot Nothing Then + Version = sender.Parent.Tag + Else + Version = sender.Parent.Parent.Tag + End If + OpenWebsite("https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & Version.Inherit & "-" & Version.Version & "/forge-" & Version.Inherit & "-" & Version.Version & "-changelog.txt") + End Sub + Public Sub NeoForgeSave_Click(sender As Object, e As RoutedEventArgs) + Dim Version As DlForgeVersionEntry + If sender.Tag IsNot Nothing Then + Version = sender.Tag + ElseIf sender.Parent.Tag IsNot Nothing Then + Version = sender.Parent.Tag + Else + Version = sender.Parent.Parent.Tag + End If + McDownloadForgeSave(Version) + End Sub + +#End Region + #Region "Fabric 下载" Public Sub McDownloadFabricLoaderSave(DownloadInfo As JObject) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml index b6b6dc59..69c47f36 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml @@ -79,6 +79,24 @@ Data="F1 M2,0 L0,2 8,10 0,18 2,20 10,12 18,20 20,18 12,10 20,2 18,0 10,8 2,0Z" /> + + + + + + + + + + + + + + + + + @@ -178,6 +196,7 @@ + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index d7ef0bc9..f703ef49 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -51,6 +51,7 @@ CardOptiFine.IsSwaped = True CardLiteLoader.IsSwaped = True CardForge.IsSwaped = True + CardNeoForge.IsSwaped = True CardFabric.IsSwaped = True CardFabricApi.IsSwaped = True CardOptiFabric.IsSwaped = True @@ -73,6 +74,13 @@ ForgeLoader.Start(SelectedMinecraftId) End If + '启动 NeoForge 加载 + If SelectedMinecraftId.StartsWith("1.") Then + Dim NeoForgeLoader = New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion " & SelectedMinecraftId, AddressOf DlNeoForgeVersionMain) + LoadNeoForge.State = NeoForgeLoader + NeoForgeLoader.Start(SelectedMinecraftId) + End If + '启动 Fabric API、OptiFabric 加载 DlFabricApiLoader.Start() DlOptiFabricLoader.Start() @@ -86,6 +94,7 @@ OptiFine_Loaded() LiteLoader_Loaded() Forge_Loaded() + NeoForge_Loaded() Fabric_Loaded() FabricApi_Loaded() OptiFabric_Loaded() @@ -102,6 +111,7 @@ BtnOptiFineClearInner.SetBinding(Shapes.Path.FillProperty, New Binding("Foreground") With {.Source = CardOptiFine.MainTextBlock, .Mode = BindingMode.OneWay}) BtnLiteLoaderClearInner.SetBinding(Shapes.Path.FillProperty, New Binding("Foreground") With {.Source = CardLiteLoader.MainTextBlock, .Mode = BindingMode.OneWay}) BtnForgeClearInner.SetBinding(Shapes.Path.FillProperty, New Binding("Foreground") With {.Source = CardForge.MainTextBlock, .Mode = BindingMode.OneWay}) + BtnNeoForgeClearInner.SetBinding(Shapes.Path.FillProperty, New Binding("Foreground") With {.Source = CardNeoForge.MainTextBlock, .Mode = BindingMode.OneWay}) BtnFabricClearInner.SetBinding(Shapes.Path.FillProperty, New Binding("Foreground") With {.Source = CardFabric.MainTextBlock, .Mode = BindingMode.OneWay}) BtnFabricApiClearInner.SetBinding(Shapes.Path.FillProperty, New Binding("Foreground") With {.Source = CardFabricApi.MainTextBlock, .Mode = BindingMode.OneWay}) BtnOptiFabricClearInner.SetBinding(Shapes.Path.FillProperty, New Binding("Foreground") With {.Source = CardOptiFabric.MainTextBlock, .Mode = BindingMode.OneWay}) @@ -213,6 +223,26 @@ End If End Sub + 'NeoForge + Private SelectedNeoForge As DlNeoForgeVersionEntry = Nothing + Private Sub SetNeoForgeInfoShow(IsShow As String) + If PanNeoForgeInfo.Tag = IsShow Then Exit Sub + PanNeoForgeInfo.Tag = IsShow + If IsShow = "True" Then + '显示信息栏 + AniStart({ + AaTranslateY(PanNeoForgeInfo, -CType(PanNeoForgeInfo.RenderTransform, TranslateTransform).Y, 270, 100, Ease:=New AniEaseOutBack), + AaOpacity(PanNeoForgeInfo, 1 - PanNeoForgeInfo.Opacity, 100, 90) + }, "SetNeoForgeInfoShow") + Else + '隐藏信息栏 + AniStart({ + AaTranslateY(PanNeoForgeInfo, 6 - CType(PanNeoForgeInfo.RenderTransform, TranslateTransform).Y, 200), + AaOpacity(PanNeoForgeInfo, -PanNeoForgeInfo.Opacity, 100) + }, "SetNeoForgeInfoShow") + End If + End Sub + 'Fabric Private SelectedFabric As String = Nothing Private Sub SetFabricInfoShow(IsShow As String) @@ -277,7 +307,7 @@ ''' ''' 重载已选择的项目的显示。 ''' - Private Sub SelectReload() Handles CardOptiFine.Swap, LoadOptiFine.StateChanged, CardForge.Swap, LoadForge.StateChanged, CardFabric.Swap, LoadFabric.StateChanged, CardFabricApi.Swap, LoadFabricApi.StateChanged, CardOptiFabric.Swap, LoadOptiFabric.StateChanged, CardLiteLoader.Swap, LoadLiteLoader.StateChanged + Private Sub SelectReload() Handles CardOptiFine.Swap, LoadOptiFine.StateChanged, CardForge.Swap, LoadForge.StateChanged, CardNeoForge.Swap, LoadNeoForge.StateChanged, CardFabric.Swap, LoadFabric.StateChanged, CardFabricApi.Swap, LoadFabricApi.StateChanged, CardOptiFabric.Swap, LoadOptiFabric.StateChanged, CardLiteLoader.Swap, LoadLiteLoader.StateChanged If SelectedMinecraftId Is Nothing OrElse IsReloading Then Exit Sub IsReloading = True '主预览 @@ -341,6 +371,22 @@ LabForge.Text = SelectedForge.Version LabForge.Foreground = ColorGray1 End If + 'NeoForge + Dim NeoForgeError As String = LoadNeoForgeGetError() + CardNeoForge.MainSwap.Visibility = If(NeoForgeError Is Nothing, Visibility.Visible, Visibility.Collapsed) + If NeoForgeError IsNot Nothing Then CardNeoForge.IsSwaped = True + SetNeoForgeInfoShow(CardNeoForge.IsSwaped) + If SelectedNeoForge Is Nothing Then + BtnNeoForgeClear.Visibility = Visibility.Collapsed + ImgNeoForge.Visibility = Visibility.Collapsed + LabNeoForge.Text = If(NeoForgeError, "点击选择") + LabNeoForge.Foreground = ColorGray4 + Else + BtnNeoForgeClear.Visibility = Visibility.Visible + ImgNeoForge.Visibility = Visibility.Visible + LabNeoForge.Text = SelectedNeoForge.Version + LabNeoForge.Foreground = ColorGray1 + End If 'Fabric If SelectedMinecraftId.Contains("1.") AndAlso Val(SelectedMinecraftId.Split(".")(1)) <= 13 Then CardFabric.Visibility = Visibility.Collapsed @@ -434,6 +480,7 @@ SelectedOptiFine = Nothing SelectedLiteLoader = Nothing SelectedForge = Nothing + SelectedNeoForge = Nothing SelectedFabric = Nothing SelectedFabricApi = Nothing SelectedOptiFabric = Nothing @@ -451,6 +498,9 @@ If SelectedForge IsNot Nothing Then Name += "-Forge_" & SelectedForge.Version End If + If SelectedNeoForge IsNot Nothing Then + Name += "-NeoForge_" & SelectedNeoForge.Version + End If If SelectedLiteLoader IsNot Nothing Then Name += "-LiteLoader" End If @@ -470,6 +520,9 @@ If SelectedForge IsNot Nothing Then Info += ", Forge " & SelectedForge.Version End If + If SelectedNeoForge IsNot Nothing Then + Info += ", NeoForge " & SelectedNeoForge.Version + End If If SelectedLiteLoader IsNot Nothing Then Info += ", LiteLoader" End If @@ -487,6 +540,8 @@ Return "pack://application:,,,/images/Blocks/Fabric.png" ElseIf SelectedForge IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Anvil.png" + ElseIf SelectedNeoForge IsNot Nothing Then + Return "pack://application:,,,/images/Blocks/Anvil.png" ElseIf SelectedLiteLoader IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Egg.png" ElseIf SelectedOptiFine IsNot Nothing Then @@ -706,6 +761,7 @@ If SelectedForge IsNot Nothing AndAlso Not IsOptiFineSuitForForge(SelectedOptiFine, SelectedForge) Then SelectedForge = Nothing OptiFabric_Loaded() Forge_Loaded() + NeoForge_Loaded() CardOptiFine.IsSwaped = True SelectReload() End Sub @@ -715,6 +771,7 @@ CardOptiFine.IsSwaped = True e.Handled = True Forge_Loaded() + NeoForge_Loaded() SelectReload() End Sub @@ -866,6 +923,81 @@ #End Region +#Region "NeoForge 列表" + + ''' + ''' 获取 NeoForge 的加载异常信息。若正常则返回 Nothing。 + ''' + Private Function LoadNeoForgeGetError() As String + If Not SelectedMinecraftId.StartsWith("1.") Then Return "没有可用版本" + If Not LoadNeoForge.State.IsLoader Then Return "正在获取版本列表……" + Dim Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)) = LoadNeoForge.State + If SelectedMinecraftId <> Loader.Input Then Return "正在获取版本列表……" + If Loader.State = LoadState.Loading Then Return "正在获取版本列表……" + If Loader.State = LoadState.Failed Then + Dim ErrorMessage As String = Loader.Error.Message + If ErrorMessage.Contains("没有可用版本") Then + Return "没有可用版本" + Else + Return "获取版本列表失败:" & ErrorMessage + End If + End If + If Loader.State <> LoadState.Finished Then Return "获取版本列表失败:未知错误,状态为 " & GetStringFromEnum(Loader.State) + For Each Version In Loader.Output + If Version.Category = "universal" OrElse Version.Category = "client" Then Continue For '跳过无法自动安装的版本 + If SelectedFabric IsNot Nothing Then Return "与 Fabric 不兼容" + Return Nothing + Next + Return False + End Function + + '限制展开 + Private Sub CardNeoForge_PreviewSwap(sender As Object, e As RouteEventArgs) Handles CardNeoForge.PreviewSwap + If LoadNeoForgeGetError() IsNot Nothing Then e.Handled = True + End Sub + + ''' + ''' 尝试重新可视化 NeoForge 版本列表。 + ''' + Private Sub NeoForge_Loaded() Handles LoadForge.StateChanged + Try + If Not LoadNeoForge.State.IsLoader Then Exit Sub + Dim Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)) = LoadNeoForge.State + If SelectedMinecraftId <> Loader.Input Then Exit Sub + If Loader.State <> LoadState.Finished Then Exit Sub + '获取要显示的版本 + Dim Versions As New List(Of DlNeoForgeVersionEntry) + Versions.AddRange(Loader.Output) '复制数组,以免 Output 在实例化后变空 + If Not Loader.Output.Any() Then Exit Sub + PanNeoForge.Children.Clear() + + 'Versions = Sort(Versions, Function(a, b) New Version(a.Version) > New Version(b.Version)).ToList + NeoForgeDownloadListItemPreload(PanNeoForge, Versions, AddressOf NeoForge_Selected, False) + For Each Version In Versions + PanNeoForge.Children.Add(NeoForgeDownloadListItem(Version, AddressOf NeoForge_Selected, False)) + Next + Catch ex As Exception + Log(ex, "可视化 NeoForge 安装版本列表出错", LogLevel.Feedback) + End Try + End Sub + + '选择与清除 + Private Sub NeoForge_Selected(sender As MyListItem, e As EventArgs) + SelectedNeoForge = sender.Tag + CardNeoForge.IsSwaped = True + OptiFine_Loaded() + SelectReload() + End Sub + Private Sub NeoForge_Clear(sender As Object, e As MouseButtonEventArgs) Handles BtnNeoForgeClear.MouseLeftButtonUp + SelectedNeoForge = Nothing + CardNeoForge.IsSwaped = True + e.Handled = True + OptiFine_Loaded() + SelectReload() + End Sub + +#End Region + #Region "Fabric 列表" ''' From e731ef69d4adaa344d7136741576aa8eadeaa0b9 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sat, 15 Jun 2024 22:38:39 +0800 Subject: [PATCH 02/36] =?UTF-8?q?ui:=20=E6=98=BE=E7=A4=BA=20NeoForge=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=B1=9E=E6=80=A7=EF=BC=88=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=89=88=20/=20=E7=A8=B3=E5=AE=9A=E7=89=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 17 ++++++++++++++--- .../Pages/PageDownload/ModDownloadLib.vb | 5 +++-- .../PageDownload/PageDownloadInstall.xaml.vb | 4 ++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 9e9ea6aa..78907b57 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -748,6 +748,10 @@ ''' 版本分支。若无分支则为 Nothing。 ''' Public Branch As String = Nothing + ''' + ''' 是否是 Beta 版。若未提供则默认为 False。 + ''' + Public IsBeta As Boolean = False Public Structure DlNeoForgeListResult ''' ''' 数据来源名称,如“Official”,“BMCLAPI”。 @@ -857,7 +861,6 @@ ResultJson = GetJson(Result) Dim Versions As New List(Of DlNeoForgeVersionEntry) Dim VersionList As String = ResultJson("versions") - MyMsgBox(VersionList, "VersionList 获取测试") 'Try ' Try ' '基础信息获取 @@ -894,9 +897,17 @@ Dim Versions As New List(Of DlNeoForgeVersionEntry) Try For Each Token As JObject In Json - Dim Name As String = Token("version") + Dim Name As String + Dim IsBeta As Boolean + If Token("version").Contains("-beta") Then + Name = Token("version").ToString() - "-beta" + IsBeta = True + Else + Name = Token("version") + IsBeta = False + End If Dim Inherit As String = Token("mcversion") - Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit} + Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit, .IsBeta = IsBeta} Versions.Add(Entry) Next 'For Each Token As JObject In Json diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 6f6a3310..97a63446 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2258,8 +2258,9 @@ Retry: Public Function NeoForgeDownloadListItem(Entry As DlNeoForgeVersionEntry, OnClick As MyListItem.ClickEventHandler, IsSaveOnly As Boolean) As MyListItem '建立控件 Dim NewItem As New MyListItem With { - .Title = Entry.Version, .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, - .Info = If(Entry.ReleaseTime = "", + .Title = If(Entry.IsBeta, Entry.Version & "-beta", Entry.Version), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, + .Info = If(Entry.IsBeta, "稳定版", "测试版") & + If(Entry.ReleaseTime = "", If(ModeDebug, "种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), "发布于 " & Entry.ReleaseTime & If(ModeDebug, ",种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), .Logo = PathImage & "Blocks/Anvil.png" diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index f703ef49..e93e7789 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -787,6 +787,7 @@ If LoadLiteLoader Is Nothing OrElse LoadLiteLoader.State.LoadingState = MyLoading.MyLoadingState.Run Then Return "正在获取版本列表……" If LoadLiteLoader.State.LoadingState = MyLoading.MyLoadingState.Error Then Return "获取版本列表失败:" & CType(LoadLiteLoader.State, Object).Error.Message For Each Version As DlLiteLoaderListEntry In DlLiteLoaderListLoader.Output.Value + If SelectedNeoForge IsNot Nothing Then Return "与 NeoForge 不兼容" If Version.Inherit = SelectedMinecraftId Then Return Nothing Next Return "没有可用版本" @@ -857,6 +858,7 @@ Dim NotSuitForOptiFine As Boolean = False For Each Version In Loader.Output If Version.Category = "universal" OrElse Version.Category = "client" Then Continue For '跳过无法自动安装的版本 + If SelectedNeoForge IsNot Nothing Then Return "与 NeoForge 不兼容" If SelectedFabric IsNot Nothing Then Return "与 Fabric 不兼容" If SelectedOptiFine IsNot Nothing AndAlso VersionSortInteger(SelectedMinecraftId, "1.13") >= 0 AndAlso VersionSortInteger("1.14.3", SelectedMinecraftId) >= 0 Then @@ -945,6 +947,7 @@ If Loader.State <> LoadState.Finished Then Return "获取版本列表失败:未知错误,状态为 " & GetStringFromEnum(Loader.State) For Each Version In Loader.Output If Version.Category = "universal" OrElse Version.Category = "client" Then Continue For '跳过无法自动安装的版本 + If SelectedForge IsNot Nothing Then Return "与 Forge 不兼容" If SelectedFabric IsNot Nothing Then Return "与 Fabric 不兼容" Return Nothing Next @@ -1008,6 +1011,7 @@ If LoadFabric.State.LoadingState = MyLoading.MyLoadingState.Error Then Return "获取版本列表失败:" & CType(LoadFabric.State, Object).Error.Message For Each Version As JObject In DlFabricListLoader.Output.Value("game") If Version("version").ToString = SelectedMinecraftId.Replace("∞", "infinite").Replace("Combat Test 7c", "1.16_combat-3") Then + If SelectedNeoForge IsNot Nothing Then Return "与 NeoForge 不兼容" If SelectedForge IsNot Nothing Then Return "与 Forge 不兼容" 'If SelectedOptiFine IsNot Nothing Then Return "与 OptiFine 不兼容" Return Nothing From 8d9dc4712bc3f54a089d99e221348ea7dbe21555 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sat, 15 Jun 2024 23:12:42 +0800 Subject: [PATCH 03/36] =?UTF-8?q?fix:=20NeoForge=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E6=8A=BD=E8=B1=A1=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 14 ++++++++++---- .../Pages/PageDownload/ModDownloadLib.vb | 3 +-- .../Pages/PageDownload/PageDownloadInstall.xaml.vb | 4 +++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 78907b57..b6db08cf 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -752,6 +752,10 @@ ''' 是否是 Beta 版。若未提供则默认为 False。 ''' Public IsBeta As Boolean = False + ''' + ''' 标准的版本号 + ''' + Public StdVersion As String Public Structure DlNeoForgeListResult ''' ''' 数据来源名称,如“Official”,“BMCLAPI”。 @@ -897,17 +901,19 @@ Dim Versions As New List(Of DlNeoForgeVersionEntry) Try For Each Token As JObject In Json - Dim Name As String + Dim Name As String '存储 rawVersion,貌似变化更加频繁 + Dim StdVersion As String '存储 version,相对规则 Dim IsBeta As Boolean If Token("version").Contains("-beta") Then - Name = Token("version").ToString() - "-beta" + StdVersion = Token("version").ToString() - "-beta" IsBeta = True Else - Name = Token("version") + StdVersion = Token("version").ToString() IsBeta = False End If + Name = Token("rawVersion") Dim Inherit As String = Token("mcversion") - Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit, .IsBeta = IsBeta} + Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} Versions.Add(Entry) Next 'For Each Token As JObject In Json diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 97a63446..9a58b325 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2241,11 +2241,10 @@ Retry: '获取最新版本 Dim FreshVersion As DlNeoForgeVersionEntry = Nothing If Entrys.Any Then - FreshVersion = Entrys(0) + FreshVersion = Entrys.Last() Else Log("[System] 未找到可用的 NeoForge 版本", LogLevel.Debug) End If - Dim RecommendedVersion As DlNeoForgeVersionEntry = Nothing '显示各个版本 If FreshVersion IsNot Nothing Then Dim Fresh = NeoForgeDownloadListItem(FreshVersion, OnClick, IsSaveOnly) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index e93e7789..8d3808d9 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -974,9 +974,11 @@ If Not Loader.Output.Any() Then Exit Sub PanNeoForge.Children.Clear() + Dim VersionsArray As Array = Versions.ToArray() + VersionsArray.Reverse(VersionsArray) 'Versions = Sort(Versions, Function(a, b) New Version(a.Version) > New Version(b.Version)).ToList NeoForgeDownloadListItemPreload(PanNeoForge, Versions, AddressOf NeoForge_Selected, False) - For Each Version In Versions + For Each Version In VersionsArray PanNeoForge.Children.Add(NeoForgeDownloadListItem(Version, AddressOf NeoForge_Selected, False)) Next Catch ex As Exception From 655364b06a789308be699b0d3047b8f2bd961633 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sat, 15 Jun 2024 23:29:53 +0800 Subject: [PATCH 04/36] =?UTF-8?q?fix:=20=E4=B8=80=E5=A4=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF=EF=BC=8C=E4=BD=86?= =?UTF-8?q?=E6=9C=AA=E8=A7=A3=E5=86=B3=E7=89=88=E6=9C=AC=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb | 2 +- Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index b6db08cf..d2d68105 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -904,7 +904,7 @@ Dim Name As String '存储 rawVersion,貌似变化更加频繁 Dim StdVersion As String '存储 version,相对规则 Dim IsBeta As Boolean - If Token("version").Contains("-beta") Then + If Token("rawVersion").Contains("-beta") Then StdVersion = Token("version").ToString() - "-beta" IsBeta = True Else diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 9a58b325..793a5129 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2258,7 +2258,7 @@ Retry: '建立控件 Dim NewItem As New MyListItem With { .Title = If(Entry.IsBeta, Entry.Version & "-beta", Entry.Version), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, - .Info = If(Entry.IsBeta, "稳定版", "测试版") & + .Info = If(Entry.IsBeta, "测试版", "稳定版") & If(Entry.ReleaseTime = "", If(ModeDebug, "种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), "发布于 " & Entry.ReleaseTime & If(ModeDebug, ",种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), From 65d21d4f2155f76375eeb79f1c87559fe0318098 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sat, 15 Jun 2024 23:57:29 +0800 Subject: [PATCH 05/36] =?UTF-8?q?Installer=20=E4=B8=8B=E8=BD=BD=E5=92=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 65 +------------------ .../Pages/PageDownload/ModDownloadLib.vb | 4 +- 2 files changed, 3 insertions(+), 66 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index d2d68105..ad69aa10 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -804,7 +804,7 @@ ''' Public ReadOnly Property FileName As String Get - Return "forge-" & Inherit & "-" & FileVersion & "-" & Category & "." & FileSuffix + Return "neoforge-" & "-" & StdVersion & "-" & "installer" & "." & "jar" End Get End Property ''' @@ -865,30 +865,6 @@ ResultJson = GetJson(Result) Dim Versions As New List(Of DlNeoForgeVersionEntry) Dim VersionList As String = ResultJson("versions") - 'Try - ' Try - ' '基础信息获取 - ' Dim Name As String = RegexSeek(VersionCode, "(?<=[^(0-9)]+)[0-9\.]+") - ' Dim IsRecommended As Boolean = VersionCode.Contains("fa promo-recommended") - ' Dim Inherit As String = Loader.Input - ' '分支获取 - ' Dim Branch As String = RegexSeek(VersionCode, $"(?<=-{Name}-)[^-""]+(?=-[a-z]+.[a-z]{{3}})") - ' If String.IsNullOrWhiteSpace(Branch) Then Branch = Nothing - ' '发布时间获取 - ' Dim ReleaseTimeOriginal = RegexSeek(VersionCode, "(?<=""download-time"" title="")[^""]+") - ' Dim ReleaseTimeSplit = ReleaseTimeOriginal.Split(" -:".ToCharArray) '原格式:"2021-02-15 03:24:02" - ' Dim ReleaseDate As New Date(ReleaseTimeSplit(0), ReleaseTimeSplit(1), ReleaseTimeSplit(2), '年月日 - ' ReleaseTimeSplit(3), ReleaseTimeSplit(4), ReleaseTimeSplit(5), '时分秒 - ' 0, DateTimeKind.Utc) '以 UTC 时间作为标准 - ' Dim ReleaseTime As String = ReleaseDate.ToLocalTime.ToString("yyyy'/'MM'/'dd HH':'mm") '时区与格式转换 - ' '添加进列表 - ' Versions.Add(New DlNeoForgeVersionEntry With {.Category = Category, .Version = Name, .Hash = MD5.Trim(vbCr, vbLf), .Inherit = Inherit, .ReleaseTime = ReleaseTime, .Branch = Branch}) - ' Catch ex As Exception - ' Throw New Exception("版本信息提取失败(" & VersionCode & ")", ex) - ' End Try - 'Catch ex As Exception - ' Throw New Exception("版本列表解析失败(" & Result & ")", ex) - 'End Try If Not Versions.Any() Then Throw New Exception("没有可用版本") Loader.Output = Versions End Sub @@ -916,45 +892,6 @@ Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} Versions.Add(Entry) Next - 'For Each Token As JObject In Json - ' '分类与 Hash 获取 - ' Dim Hash As String = Nothing, Category As String = "unknown", Proi As Integer = -1 - ' For Each File As JObject In Token("files") - ' Select Case File("category").ToString - ' Case "installer" - ' If File("format").ToString = "jar" Then - ' '类型为 installer.jar,支持范围 ~753 (~ 1.6.1 部分), 738~684 (1.5.2 全部) - ' Hash = File("hash") - ' Category = "installer" - ' Proi = 2 - ' End If - ' Case "universal" - ' If Proi <= 1 AndAlso File("format").ToString = "zip" Then - ' '类型为 universal.zip,支持范围 751~449 (1.6.1 部分), 682~183 (1.5.1 ~ 1.3.2 部分) - ' Hash = File("hash") - ' Category = "universal" - ' Proi = 1 - ' End If - ' Case "client" - ' If Proi <= 0 AndAlso File("format").ToString = "zip" Then - ' '类型为 client.zip,支持范围 182~ (1.3.2 部分 ~) - ' Hash = File("hash") - ' Category = "client" - ' Proi = 0 - ' End If - ' End Select - ' Next - ' '获取 Entry - ' Dim Inherit As String = Loader.Input - ' Dim Branch As String = Token("branch") - ' Dim Name As String = Token("version") - ' '基础信息获取 - ' Dim Entry = New DlNeoForgeVersionEntry With {.Hash = Hash, .Category = Category, .Version = Name, .Branch = Branch, .Inherit = Inherit} - ' Dim TimeSplit = Token("modified").ToString.Split("-"c, "T"c, ":"c, "."c, " "c, "/"c) - ' Entry.ReleaseTime = Token("modified").ToObject(Of Date).ToLocalTime.ToString("yyyy'/'MM'/'dd HH':'mm") - ' '添加项 - ' Versions.Add(Entry) - 'Next Catch ex As Exception Throw New Exception("版本列表解析失败(" & Json.ToString & ")", ex) End Try diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 793a5129..ac13c412 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1783,8 +1783,8 @@ Retry: Sub(Task As LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))) Dim Files As New List(Of NetFile) Files.Add(New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, - "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName + "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) Task.Output = Files End Sub) With {.ProgressWeight = 0.1, .Show = False}) From 31e391f87296f30798d81bbfd796f24486006deb Mon Sep 17 00:00:00 2001 From: JingHai-Lingyun Date: Sun, 16 Jun 2024 00:34:42 +0800 Subject: [PATCH 06/36] optimize: version name and icon Now, NeoForge client's info and name looks like the Forge client's behavior --- .../Pages/PageDownload/ModDownloadLib.vb | 2 +- .../Pages/PageDownload/PageDownloadInstall.xaml | 2 +- .../Pages/PageDownload/PageDownloadInstall.xaml.vb | 6 +++--- Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj | 8 +------- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index ac13c412..c053888d 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2262,7 +2262,7 @@ Retry: If(Entry.ReleaseTime = "", If(ModeDebug, "种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), "发布于 " & Entry.ReleaseTime & If(ModeDebug, ",种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), - .Logo = PathImage & "Blocks/Anvil.png" + .Logo = PathImage & "Blocks/NeoForge.png" } AddHandler NewItem.Click, OnClick '建立菜单 diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml index 69c47f36..1cf0a2d5 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml @@ -89,7 +89,7 @@ - + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index 8d3808d9..dee744cd 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -499,7 +499,7 @@ Name += "-Forge_" & SelectedForge.Version End If If SelectedNeoForge IsNot Nothing Then - Name += "-NeoForge_" & SelectedNeoForge.Version + Name += "-NeoForge_" & SelectedNeoForge.Version.Replace("neoforge-", "").Replace("forge-", "").Replace("1.20.1-", "") End If If SelectedLiteLoader IsNot Nothing Then Name += "-LiteLoader" @@ -521,7 +521,7 @@ Info += ", Forge " & SelectedForge.Version End If If SelectedNeoForge IsNot Nothing Then - Info += ", NeoForge " & SelectedNeoForge.Version + Info += ", NeoForge " & SelectedNeoForge.Version.Replace("neoforge-", "").Replace("forge-", "").Replace("1.20.1-", "") End If If SelectedLiteLoader IsNot Nothing Then Info += ", LiteLoader" @@ -541,7 +541,7 @@ ElseIf SelectedForge IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Anvil.png" ElseIf SelectedNeoForge IsNot Nothing Then - Return "pack://application:,,,/images/Blocks/Anvil.png" + Return "pack://application:,,,/images/Blocks/NeoForge.png" ElseIf SelectedLiteLoader IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Egg.png" ElseIf SelectedOptiFine IsNot Nothing Then diff --git a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj index 72db6888..7f353ad6 100644 --- a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj +++ b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj @@ -185,9 +185,6 @@ MyIconTextButton.xaml - - - @@ -469,7 +466,6 @@ FormMain.xaml Code - MSBuild:Compile Designer @@ -754,6 +750,7 @@ + @@ -919,9 +916,6 @@ - - - From d8fe5997399cdad68bfab9bdfb6b54296701a29f Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 07:00:37 +0800 Subject: [PATCH 07/36] =?UTF-8?q?fix:=20=E6=89=80=E6=9C=89=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E9=83=BD=E6=98=BE=E7=A4=BA=E4=B8=BA=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=89=88=20/=20=E6=AD=A3=E5=BC=8F=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb | 8 +++++--- .../Pages/PageDownload/ModDownloadLib.vb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index ad69aa10..a81f8fa7 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -880,19 +880,21 @@ Dim Name As String '存储 rawVersion,貌似变化更加频繁 Dim StdVersion As String '存储 version,相对规则 Dim IsBeta As Boolean - If Token("rawVersion").Contains("-beta") Then - StdVersion = Token("version").ToString() - "-beta" + Dim rawVersion As String = Token("rawVersion") + If rawVersion.Contains("-beta") Then + StdVersion = Token("version").ToString().Replace("-beta", "") IsBeta = True Else StdVersion = Token("version").ToString() IsBeta = False End If - Name = Token("rawVersion") + Name = rawVersion Dim Inherit As String = Token("mcversion") Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} Versions.Add(Entry) Next Catch ex As Exception + MyMsgBox(ex.ToString(), "错误") Throw New Exception("版本列表解析失败(" & Json.ToString & ")", ex) End Try If Not Versions.Any() Then Throw New Exception("没有可用版本") diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index ac13c412..f294d67c 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2257,7 +2257,7 @@ Retry: Public Function NeoForgeDownloadListItem(Entry As DlNeoForgeVersionEntry, OnClick As MyListItem.ClickEventHandler, IsSaveOnly As Boolean) As MyListItem '建立控件 Dim NewItem As New MyListItem With { - .Title = If(Entry.IsBeta, Entry.Version & "-beta", Entry.Version), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, + .Title = Entry.Version, .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, .Info = If(Entry.IsBeta, "测试版", "稳定版") & If(Entry.ReleaseTime = "", If(ModeDebug, "种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), From 0e0335e688b60e15e6e47479de365de7a5214cdb Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 08:52:45 +0800 Subject: [PATCH 08/36] =?UTF-8?q?ui:=20=E6=B7=BB=E5=8A=A0=20NeoForge=20?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=AE=89=E8=A3=85=20Tab=20feat:=20NeoForge?= =?UTF-8?q?=20=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85=20Stage=201=20fix:=20St?= =?UTF-8?q?dVersion=20=E5=8F=AF=E8=83=BD=E9=94=99=E8=AF=AF=E5=9C=B0?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E4=BA=86=20"neoforge-"=20=E5=89=8D=E7=BC=80?= =?UTF-8?q?=20fix:=20=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85=E9=80=89?= =?UTF-8?q?=E6=8B=A9=20NeoForge=20=E6=97=B6=E8=87=AA=E5=8A=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E6=A0=B8=E5=BF=83=E5=90=8D=E7=A7=B0=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E9=87=8D=E5=A4=8D=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/FormMain.xaml.vb | 1 + .../Modules/Minecraft/ModDownload.vb | 10 ++-- Plain Craft Launcher 2/Modules/ModMain.vb | 1 + .../Pages/PageDownload/ModDownloadLib.vb | 60 +++++++++---------- .../PageDownload/PageDownloadInstall.xaml.vb | 4 +- .../Pages/PageDownload/PageDownloadLeft.xaml | 9 +++ .../PageDownload/PageDownloadLeft.xaml.vb | 11 +++- .../PageDownload/PageDownloadNeoForge.xaml | 28 +++++++++ .../PageDownload/PageDownloadNeoForge.xaml.vb | 32 ++++++++++ .../Plain Craft Launcher 2.vbproj | 12 ++-- 10 files changed, 125 insertions(+), 43 deletions(-) create mode 100644 Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml create mode 100644 Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb diff --git a/Plain Craft Launcher 2/FormMain.xaml.vb b/Plain Craft Launcher 2/FormMain.xaml.vb index 5ed09e66..339404b0 100644 --- a/Plain Craft Launcher 2/FormMain.xaml.vb +++ b/Plain Craft Launcher 2/FormMain.xaml.vb @@ -1019,6 +1019,7 @@ Install: DownloadClient = 4 DownloadOptiFine = 5 DownloadForge = 6 + DownloadNeoForge = 13 DownloadFabric = 7 DownloadLiteLoader = 8 DownloadMod = 10 diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index a81f8fa7..471eb1a3 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -725,7 +725,7 @@ Public Class DlNeoForgeVersionEntry ''' - ''' 完整的版本名,如 “14.22.1.2478”。 + ''' 完整的版本名,如 “neoforge-20.4.30-beta”。 ''' Public Version As String ''' @@ -753,7 +753,7 @@ ''' Public IsBeta As Boolean = False ''' - ''' 标准的版本号 + ''' 标准的版本号,如 “20.4.30”。 ''' Public StdVersion As String Public Structure DlNeoForgeListResult @@ -820,10 +820,10 @@ End Get End Property End Class - ''' ''' NeoForge 版本列表,主加载器。 ''' + Public DlNeoForgeListLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeList Main", AddressOf DlNeoForgeVersionMain) Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) Dim DlNeoForgeVersionOfficialLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Official", AddressOf DlNeoForgeVersionOfficialMain) Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) @@ -882,10 +882,10 @@ Dim IsBeta As Boolean Dim rawVersion As String = Token("rawVersion") If rawVersion.Contains("-beta") Then - StdVersion = Token("version").ToString().Replace("-beta", "") + StdVersion = Token("version").ToString().Replace("neoforge-", "").Replace("-beta", "") IsBeta = True Else - StdVersion = Token("version").ToString() + StdVersion = Token("version").ToString().Replace("neoforge-", "") IsBeta = False End If Name = rawVersion diff --git a/Plain Craft Launcher 2/Modules/ModMain.vb b/Plain Craft Launcher 2/Modules/ModMain.vb index e2b797ca..a9718867 100644 --- a/Plain Craft Launcher 2/Modules/ModMain.vb +++ b/Plain Craft Launcher 2/Modules/ModMain.vb @@ -394,6 +394,7 @@ EndHint: Public FrmDownloadOptiFine As PageDownloadOptiFine Public FrmDownloadLiteLoader As PageDownloadLiteLoader Public FrmDownloadForge As PageDownloadForge + Public FrmDownloadNeoForge As PageDownloadNeoForge Public FrmDownloadFabric As PageDownloadFabric Public FrmDownloadMod As PageDownloadMod Public FrmDownloadPack As PageDownloadPack diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index f294d67c..881f4d66 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1829,9 +1829,9 @@ Retry: '添加 Java Wrapper 作为主 Jar Dim Arguments As String If UseJavaWrapper Then - Arguments = $"-Doolloo.jlw.tmpdir=""{GetJavaWrapperDir()}"" -cp ""{PathTemp}Cache\forge_installer.jar;{Target}"" -jar ""{ExtractJavaWrapper()}"" com.bangbang93.ForgeInstaller ""{McFolder}" + Arguments = $"-Doolloo.jlw.tmpdir=""{GetJavaWrapperDir()}"" -cp ""{PathTemp}Cache\neoforge_installer.jar;{Target}"" -jar ""{ExtractJavaWrapper()}"" com.bangbang93.ForgeInstaller ""{McFolder}" Else - Arguments = $"-cp ""{PathTemp}Cache\forge_installer.jar;{Target}"" com.bangbang93.ForgeInstaller ""{McFolder}" + Arguments = $"-cp ""{PathTemp}Cache\neoforge_installer.jar;{Target}"" com.bangbang93.ForgeInstaller ""{McFolder}" End If If Java.VersionCode >= 9 Then Arguments = "--add-exports cpw.mods.bootstraplauncher/cpw.mods.bootstraplauncher=ALL-UNNAMED " & Arguments '开始启动 @@ -1979,7 +1979,7 @@ Retry: Dim Id As String = Inherit & "-forge-" & Version Dim InstallerAddress As String = PathTemp & "Cache\Code\NeoForgeInstall-" & Version & "_" & RandomInteger(0, 100000) Dim VersionFolder As String = McFolder & "versions\" & Id & "\" - Dim DisplayName As String = "Forge " & Inherit & " - " & Version + Dim DisplayName As String = "NeoForge " & Inherit & " - " & Version Dim Loaders As New List(Of LoaderBase) Dim LibVersionFolder As String = PathMcFolder & "versions\" & Id & "\" '作为 Lib 文件目标的版本文件夹 @@ -1987,7 +1987,7 @@ Retry: If DownloadInfo Is Nothing Then Loaders.Add(New LoaderTask(Of String, String)("获取 Mod 加载器详细信息", Sub(Task As LoaderTask(Of String, String)) - '获取 Forge 版本列表 + '获取 NeoForge 版本列表 Dim NeoForgeLoader = New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("McDownloadNeoForgeLoader " & Inherit, AddressOf DlNeoForgeVersionMain) NeoForgeLoader.WaitForExit(Inherit) Task.Progress = 0.8 @@ -2001,7 +2001,7 @@ Retry: Throw New Exception("未能找到 NeoForge " & Inherit & "-" & Version & " 的详细信息!") End Sub) With {.ProgressWeight = 3}) End If - '下载 Forge 主文件 + '下载 NeoForge 主文件 Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("准备 Mod 加载器下载", Sub(Task As LoaderTask(Of String, List(Of NetFile))) '启动依赖版本的下载 @@ -2011,8 +2011,8 @@ Retry: End If '添加主文件 Dim Files As New List(Of NetFile) From {New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, - "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName + "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) @@ -2050,16 +2050,16 @@ Retry: Task.Progress = 0.8 '去除其中的原始 Forge 项 For i = 0 To Libs.Count - 1 - If Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & ".jar") OrElse + If Libs(i).LocalPath.EndsWithF("neoforge-" & Inherit & "-" & Version & ".jar") OrElse Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & "-client.jar") Then - Log("[Download] 已从待下载 Forge 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug) + Log("[Download] 已从待下载 NeoForge 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug) Libs.RemoveAt(i) Exit For End If Next Task.Output = McLibFixFromLibToken(Libs, PathMcFolder) Catch ex As Exception - Throw New Exception("获取新版 Forge 支持库列表失败", ex) + Throw New Exception("获取新版 NeoForge 支持库列表失败", ex) Finally '释放文件 If Installer IsNot Nothing Then Installer.Dispose() @@ -2068,7 +2068,7 @@ Retry: Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 Mod 下载器支持库文件", Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) -#Region "Forge 文件" +#Region "NeoForge 文件" If IsCustomFolder Then For Each LibFile As McLibToken In Libs Dim RealPath As String = LibFile.LocalPath.Replace(PathMcFolder, McFolder) @@ -2076,7 +2076,7 @@ Retry: Directory.CreateDirectory(IO.Path.GetDirectoryName(RealPath)) CopyFile(LibFile.LocalPath, RealPath) End If - If ModeDebug Then Log("[Download] 复制的 Forge 支持库文件:" & LibFile.LocalPath) + If ModeDebug Then Log("[Download] 复制的 NeoForge 支持库文件:" & LibFile.LocalPath) Next End If #End Region @@ -2086,7 +2086,7 @@ Retry: Dim TargetLoaders As List(Of LoaderBase) = ClientDownloadLoader.GetLoaderList.Where(Function(l) l.Name = McDownloadClientLibName OrElse l.Name = McDownloadClientJsonName). Where(Function(l) l.State <> LoadState.Finished).ToList - If TargetLoaders.Any Then Log("[Download] Forge 安装正在等待原版文件下载完成") + If TargetLoaders.Any Then Log("[Download] NeoForge 安装正在等待原版文件下载完成") Do While TargetLoaders.Any AndAlso Not Task.IsAborted TargetLoaders = TargetLoaders.Where(Function(l) l.State <> LoadState.Finished).ToList Thread.Sleep(50) @@ -2110,7 +2110,7 @@ Retry: Sub(Task As LoaderTask(Of Boolean, Boolean)) Dim Installer As ZipArchive = Nothing Try - Log("[Download] 开始进行新版方式 Forge 安装:" & InstallerAddress) + Log("[Download] 开始进行新版方式 NeoForge 安装:" & InstallerAddress) '记录当前文件夹列表(在新建目标文件夹之前) Dim OldList = New DirectoryInfo(McFolder & "versions\").EnumerateDirectories. Select(Function(i) i.FullName).ToList() @@ -2123,23 +2123,23 @@ Retry: '释放 launcher_installer.json McFolderLauncherProfilesJsonCreate(McFolder) Task.Progress = 0.05 - '运行 Forge 安装器 + '运行 NeoForge 安装器 Dim UseJavaWrapper As Boolean = True Retry: Try - '释放 Forge 注入器 - WriteFile(PathTemp & "Cache\forge_installer.jar", GetResources("ForgeInstaller")) + '释放 NeoForge 注入器 + WriteFile(PathTemp & "Cache\neoforge_installer.jar", GetResources("ForgeInstaller")) Task.Progress = 0.06 '运行注入器 ForgeInjector(InstallerAddress, Task, McFolder, UseJavaWrapper) Task.Progress = 0.97 Catch ex As Exception If UseJavaWrapper Then - Log(ex, "使用 JavaWrapper 安装 Forge 失败,将不使用 JavaWrapper 并重试") + Log(ex, "使用 JavaWrapper 安装 NeoForge 失败,将不使用 JavaWrapper 并重试") UseJavaWrapper = False GoTo Retry Else - Throw New Exception("运行 Forge 安装器失败", ex) + Throw New Exception("运行 NeoForge 安装器失败", ex) End If End Try '拷贝新增的版本 Json @@ -2147,7 +2147,7 @@ Retry: SkipWhile(Function(i) OldList.Contains(i.FullName)).ToList() If DeltaList.Count > 1 Then '它可能和 OptiFine 安装同时运行,导致增加的文件不止一个(这导致了 #151) - '也可能是因为 Forge 安装器的 Bug,生成了一个名字错误的文件夹,所以需要检查文件夹是否为空 + '也可能是因为 NeoForge 安装器的 Bug,生成了一个名字错误的文件夹,所以需要检查文件夹是否为空 DeltaList = DeltaList.Where(Function(l) l.Name.Contains("forge") AndAlso l.EnumerateFiles.Any).ToList End If If DeltaList.Count = 1 Then '如果没有新增文件夹,那么预测的文件夹名就是正确的 @@ -2157,19 +2157,19 @@ Retry: '新建 mods 文件夹 Directory.CreateDirectory(New McVersion(VersionFolder).GetPathIndie(True) & "mods\") Catch ex As Exception - Throw New Exception("安装新 Forge 版本失败", ex) + Throw New Exception("安装新 NeoForge 版本失败", ex) Finally '清理文件 Try If Installer IsNot Nothing Then Installer.Dispose() If File.Exists(InstallerAddress) Then File.Delete(InstallerAddress) Catch ex As Exception - Log(ex, "安装 Forge 清理文件时出错") + Log(ex, "安装 NeoForge 清理文件时出错") End Try End Try End Sub) With {.ProgressWeight = 10}) Else - Log("[Download] 检测为非新版 Forge:" & Version) + Log("[Download] 检测为非新版 NeoForge:" & Version) Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("安装 Mod 加载器(方式 B)", Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) Dim Installer As ZipArchive = Nothing @@ -2211,7 +2211,7 @@ Retry: '新建 mods 文件夹 Directory.CreateDirectory(New McVersion(VersionFolder).GetPathIndie(True) & "mods\") Catch ex As Exception - Throw New Exception("非新版方式安装 Forge 失败", ex) + Throw New Exception("非新版方式安装 NeoForge 失败", ex) Finally Try '清理文件 @@ -2219,7 +2219,7 @@ Retry: If File.Exists(InstallerAddress) Then File.Delete(InstallerAddress) If Directory.Exists(InstallerAddress & "_unrar\") Then DeleteDirectory(InstallerAddress & "_unrar\") Catch ex As Exception - Log(ex, "非新版方式安装 Forge 清理文件时出错") + Log(ex, "非新版方式安装 NeoForge 清理文件时出错") End Try End Try End Sub) With {.ProgressWeight = 1}) @@ -2257,7 +2257,7 @@ Retry: Public Function NeoForgeDownloadListItem(Entry As DlNeoForgeVersionEntry, OnClick As MyListItem.ClickEventHandler, IsSaveOnly As Boolean) As MyListItem '建立控件 Dim NewItem As New MyListItem With { - .Title = Entry.Version, .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, + .Title = If(Entry.IsBeta, Entry.StdVersion & "-beta", Entry.StdVersion), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, .Info = If(Entry.IsBeta, "测试版", "稳定版") & If(Entry.ReleaseTime = "", If(ModeDebug, "种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), @@ -2296,7 +2296,7 @@ Retry: sender.Buttons = {BtnInfo} End Sub Private Sub NeoForgeLog_Click(sender As Object, e As RoutedEventArgs) - Dim Version As DlForgeVersionEntry + Dim Version As DlNeoForgeVersionEntry If sender.Tag IsNot Nothing Then Version = sender.Tag ElseIf sender.Parent.Tag IsNot Nothing Then @@ -2304,10 +2304,10 @@ Retry: Else Version = sender.Parent.Parent.Tag End If - OpenWebsite("https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & Version.Inherit & "-" & Version.Version & "/forge-" & Version.Inherit & "-" & Version.Version & "-changelog.txt") + OpenWebsite("https://maven.neoforged.net/releases/net/neoforged/neoforge/" & Version.StdVersion & "/" & Version.Version & "-changelog.txt") End Sub Public Sub NeoForgeSave_Click(sender As Object, e As RoutedEventArgs) - Dim Version As DlForgeVersionEntry + Dim Version As DlNeoForgeVersionEntry If sender.Tag IsNot Nothing Then Version = sender.Tag ElseIf sender.Parent.Tag IsNot Nothing Then @@ -2315,7 +2315,7 @@ Retry: Else Version = sender.Parent.Parent.Tag End If - McDownloadForgeSave(Version) + McDownloadNeoForgeSave(Version) End Sub #End Region diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index 8d3808d9..0c5e1467 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -499,7 +499,7 @@ Name += "-Forge_" & SelectedForge.Version End If If SelectedNeoForge IsNot Nothing Then - Name += "-NeoForge_" & SelectedNeoForge.Version + Name += "-NeoForge_" & SelectedNeoForge.StdVersion & If(SelectedNeoForge.IsBeta, "-beta", "") End If If SelectedLiteLoader IsNot Nothing Then Name += "-LiteLoader" @@ -521,7 +521,7 @@ Info += ", Forge " & SelectedForge.Version End If If SelectedNeoForge IsNot Nothing Then - Info += ", NeoForge " & SelectedNeoForge.Version + Info += ", NeoForge " & SelectedNeoForge.StdVersion & If(SelectedNeoForge.IsBeta, "-beta", "") End If If SelectedLiteLoader IsNot Nothing Then Info += ", LiteLoader" diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadLeft.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadLeft.xaml index da78a289..f4b76530 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadLeft.xaml +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadLeft.xaml @@ -43,6 +43,15 @@ + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadLeft.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadLeft.xaml.vb index da173ad1..8d1e2e25 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadLeft.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadLeft.xaml.vb @@ -10,7 +10,7 @@ ''' ''' 勾选事件改变页面。 ''' - Private Sub PageCheck(sender As MyListItem, e As RouteEventArgs) Handles ItemInstall.Check, ItemClient.Check, ItemOptiFine.Check, ItemForge.Check, ItemLiteLoader.Check, ItemMod.Check, ItemFabric.Check, ItemPack.Check + Private Sub PageCheck(sender As MyListItem, e As RouteEventArgs) Handles ItemInstall.Check, ItemClient.Check, ItemOptiFine.Check, ItemForge.Check, ItemNeoForge.Check, ItemLiteLoader.Check, ItemMod.Check, ItemFabric.Check, ItemPack.Check '尚未初始化控件属性时,sender.Tag 为 Nothing,会导致切换到页面 0 '若使用 IsLoaded,则会导致模拟点击不被执行(模拟点击切换页面时,控件的 IsLoaded 为 False) If sender.Tag IsNot Nothing Then PageChange(Val(sender.Tag)) @@ -31,6 +31,9 @@ Case FormMain.PageSubType.DownloadForge If FrmDownloadForge Is Nothing Then FrmDownloadForge = New PageDownloadForge Return FrmDownloadForge + Case FormMain.PageSubType.DownloadNeoForge + If FrmDownloadNeoForge Is Nothing Then FrmDownloadNeoForge = New PageDownloadNeoForge + Return FrmDownloadNeoForge Case FormMain.PageSubType.DownloadLiteLoader If FrmDownloadLiteLoader Is Nothing Then FrmDownloadLiteLoader = New PageDownloadLiteLoader Return FrmDownloadLiteLoader @@ -91,6 +94,7 @@ DlClientListLoader.Start(IsForceRestart:=True) DlOptiFineListLoader.Start(IsForceRestart:=True) DlForgeListLoader.Start(IsForceRestart:=True) + DlNeoForgeListLoader.Start(IsForceRestart:=True) DlLiteLoaderListLoader.Start(IsForceRestart:=True) DlFabricListLoader.Start(IsForceRestart:=True) DlFabricApiLoader.Start(IsForceRestart:=True) @@ -117,6 +121,9 @@ Case FormMain.PageSubType.DownloadForge DlForgeListLoader.Start(IsForceRestart:=True) ItemForge.Checked = True + Case FormMain.PageSubType.DownloadNeoForge + DlNeoForgeListLoader.Start(IsForceRestart:=True) + ItemNeoForge.Checked = True Case FormMain.PageSubType.DownloadLiteLoader DlLiteLoaderListLoader.Start(IsForceRestart:=True) ItemLiteLoader.Checked = True @@ -154,6 +161,7 @@ ItemOptiFine.Visibility = Visibility.Visible ItemFabric.Visibility = Visibility.Visible ItemForge.Visibility = Visibility.Visible + ItemNeoForge.Visibility = Visibility.Visible ItemLiteLoader.Visibility = Visibility.Visible RunInThread(Sub() Thread.Sleep(20) @@ -172,6 +180,7 @@ ItemOptiFine.Visibility = Visibility.Collapsed ItemFabric.Visibility = Visibility.Collapsed ItemForge.Visibility = Visibility.Collapsed + ItemNeoForge.Visibility = Visibility.Collapsed ItemLiteLoader.Visibility = Visibility.Collapsed RunInThread(Sub() Thread.Sleep(20) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml new file mode 100644 index 00000000..aae4da7a --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb new file mode 100644 index 00000000..fcb44919 --- /dev/null +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb @@ -0,0 +1,32 @@ +Public Class PageDownloadNeoForge + + Private Sub LoaderInit() Handles Me.Initialized + PageLoaderInit(Load, PanLoad, CardVersions, CardTip, DlNeoForgeListLoader, AddressOf Load_OnFinish) + End Sub + Private Sub Init() Handles Me.Loaded + PanBack.ScrollToHome() + End Sub + + Private Sub Load_OnFinish() + '结果数据化 + Try + Dim Versions As List(Of DlNeoForgeVersionEntry) = DlNeoForgeListLoader.Output + PanVersions.Children.Clear() + For Each Version In Versions + PanVersions.Children.Add(NeoForgeDownloadListItem(Version, AddressOf NeoForge_Selected, True)) + Next + CardVersions.Title = "版本列表 (" & Versions.Count & ")" + Catch ex As Exception + Log(ex, "可视化 NeoForge 版本列表出错", LogLevel.Feedback) + End Try + End Sub + + Private Sub NeoForge_Selected(sender As MyListItem, e As EventArgs) + McDownloadNeoForgeSave(sender.Tag) + End Sub + + Private Sub BtnWeb_Click(sender As Object, e As EventArgs) Handles BtnWeb.Click + OpenWebsite("https://neoforged.net/") + End Sub + +End Class diff --git a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj index 72db6888..48f9bfbf 100644 --- a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj +++ b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj @@ -185,9 +185,6 @@ MyIconTextButton.xaml - - - @@ -232,6 +229,9 @@ MyCompItem.xaml + + PageDownloadNeoForge.xaml + PageDownloadMod.xaml @@ -469,7 +469,6 @@ FormMain.xaml Code - MSBuild:Compile Designer @@ -478,6 +477,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -921,7 +924,6 @@ - From f4b1e3ed1aea29b2cbcaa12bab084177f58b433f Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 09:44:00 +0800 Subject: [PATCH 09/36] =?UTF-8?q?feat:=20=E6=AD=A3=E5=BC=8F=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20NeoForge=20=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 4 +- .../Pages/PageDownload/ModDownloadLib.vb | 162 ++++++++---------- .../PageDownload/PageDownloadInstall.xaml.vb | 3 +- 3 files changed, 71 insertions(+), 98 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 471eb1a3..69e2308d 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -804,7 +804,7 @@ ''' Public ReadOnly Property FileName As String Get - Return "neoforge-" & "-" & StdVersion & "-" & "installer" & "." & "jar" + Return "neoforge-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" End Get End Property ''' @@ -815,7 +815,7 @@ If Category = "installer" Then Return "jar" Else - Return "zip" + Return "jar" End If End Get End Property diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 881f4d66..8b5bc2f7 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1779,8 +1779,8 @@ Retry: '构造步骤加载器 Dim Loaders As New List(Of LoaderBase) '获取下载地址 - Loaders.Add(New LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))("获取下载地址", - Sub(Task As LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))) + Loaders.Add(New LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))("获取下载地址", + Sub(Task As LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))) Dim Files As New List(Of NetFile) Files.Add(New NetFile({ "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName, @@ -1792,7 +1792,7 @@ Retry: Loaders.Add(New LoaderDownload("下载主文件", New List(Of NetFile)) With {.ProgressWeight = 6}) '启动 - Dim Loader As New LoaderCombo(Of DlForgeVersionEntry)(DisplayName & " 下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave} + Dim Loader As New LoaderCombo(Of DlNeoForgeVersionEntry)(DisplayName & " 下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave} Loader.Start(DownloadInfo) LoaderTaskbarAdd(Loader) FrmMain.BtnExtraDownload.ShowRefresh() @@ -1880,15 +1880,15 @@ Retry: Else LastResults.Enqueue(e.Data) If LastResults.Count > 100 Then LastResults.Dequeue() - ForgeInjectorLine(e.Data, Task) + NeoForgeInjectorLine(e.Data, Task) End If Catch ex As ObjectDisposedException Catch ex As Exception - Log(ex, "读取 Forge 安装器错误信息失败") + Log(ex, "读取 NeoForge 安装器错误信息失败") End Try Try If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then - Log("[Installer] 由于任务取消,已中止 Forge 安装") + Log("[Installer] 由于任务取消,已中止 NeoForge 安装") process.Kill() End If Catch @@ -1913,7 +1913,7 @@ Retry: For i As Integer = Math.Max(0, LastResults.Count - 5) To LastResults.Count - 1 '最后 5 行 LastLines &= vbCrLf & LastResults(i) Next - Throw New Exception("Forge 安装器出错,日志结束部分为:" & LastLines) + Throw New Exception("NeoForge 安装器出错,日志结束部分为:" & LastLines) End Using End Using End SyncLock @@ -1970,13 +1970,9 @@ Retry: '参数初始化 McFolder = If(McFolder, PathMcFolder) - If Version.StartsWithF("1.") AndAlso Version.Contains("-") Then - '类似 1.19.3-41.2.8 格式,优先使用 Version 中要求的版本而非 Inherit(例如 1.19.3 却使用了 1.19 的 Forge) - Inherit = Version.Before("-") - Version = Version.After("-") - End If + Version = DownloadInfo.StdVersion Dim IsCustomFolder As Boolean = McFolder <> PathMcFolder - Dim Id As String = Inherit & "-forge-" & Version + Dim Id As String = DownloadInfo.Version Dim InstallerAddress As String = PathTemp & "Cache\Code\NeoForgeInstall-" & Version & "_" & RandomInteger(0, 100000) Dim VersionFolder As String = McFolder & "versions\" & Id & "\" Dim DisplayName As String = "NeoForge " & Inherit & " - " & Version @@ -2011,18 +2007,17 @@ Retry: End If '添加主文件 Dim Files As New List(Of NetFile) From {New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName + "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) Loaders.Add(New LoaderDownload("下载 Mod 加载器主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) '安装(仅在新版安装时需要原版 Jar) - If Version.Before(".") >= 20 Then - Log("[Download] 检测为新版 NeoForge:" & Version) - Dim Libs As List(Of McLibToken) = Nothing - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Mod 加载器支持库文件", + Log("[Download] 检测为新版 NeoForge:" & Version) + Dim Libs As List(Of McLibToken) = Nothing + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Mod 加载器支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = New List(Of NetFile) Dim Installer As ZipArchive = Nothing @@ -2048,7 +2043,7 @@ Retry: Log("[Download] 需要下载 Mappings:" & Address) End If Task.Progress = 0.8 - '去除其中的原始 Forge 项 + '去除其中的原始 NeoForge 项 For i = 0 To Libs.Count - 1 If Libs(i).LocalPath.EndsWithF("neoforge-" & Inherit & "-" & Version & ".jar") OrElse Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & "-client.jar") Then @@ -2065,8 +2060,8 @@ Retry: If Installer IsNot Nothing Then Installer.Dispose() End Try End Sub) With {.ProgressWeight = 2}) - Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) - Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 Mod 下载器支持库文件", + Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) + Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 Mod 下载器支持库文件", Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) #Region "NeoForge 文件" If IsCustomFolder Then @@ -2106,7 +2101,7 @@ Retry: End SyncLock #End Region End Sub) With {.ProgressWeight = 0.1, .Show = False}) - Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 Mod 加载器(方式 A)", + Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 Mod 加载器(方式 A)", Sub(Task As LoaderTask(Of Boolean, Boolean)) Dim Installer As ZipArchive = Nothing Try @@ -2131,7 +2126,7 @@ Retry: WriteFile(PathTemp & "Cache\neoforge_installer.jar", GetResources("ForgeInstaller")) Task.Progress = 0.06 '运行注入器 - ForgeInjector(InstallerAddress, Task, McFolder, UseJavaWrapper) + NeoForgeInjector(InstallerAddress, Task, McFolder, UseJavaWrapper) Task.Progress = 0.97 Catch ex As Exception If UseJavaWrapper Then @@ -2148,7 +2143,7 @@ Retry: If DeltaList.Count > 1 Then '它可能和 OptiFine 安装同时运行,导致增加的文件不止一个(这导致了 #151) '也可能是因为 NeoForge 安装器的 Bug,生成了一个名字错误的文件夹,所以需要检查文件夹是否为空 - DeltaList = DeltaList.Where(Function(l) l.Name.Contains("forge") AndAlso l.EnumerateFiles.Any).ToList + DeltaList = DeltaList.Where(Function(l) l.Name.Contains("neoforge") AndAlso l.EnumerateFiles.Any).ToList End If If DeltaList.Count = 1 Then '如果没有新增文件夹,那么预测的文件夹名就是正确的 Dim JsonFile As FileInfo = DeltaList(0).EnumerateFiles.First() @@ -2168,67 +2163,6 @@ Retry: End Try End Try End Sub) With {.ProgressWeight = 10}) - Else - Log("[Download] 检测为非新版 NeoForge:" & Version) - Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("安装 Mod 加载器(方式 B)", - Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) - Dim Installer As ZipArchive = Nothing - Try - '解压并获取信息 - Installer = New ZipArchive(New FileStream(InstallerAddress, FileMode.Open)) - Task.Progress = 0.2 - Dim Json As JObject = GetJson(ReadFile(Installer.GetEntry("install_profile.json").Open)) - Task.Progress = 0.4 - '新建版本文件夹 - Directory.CreateDirectory(VersionFolder) - Task.Progress = 0.5 - If Json("install") Is Nothing Then - '中版格式 - Log("[Download] 进行中版方式安装:" & InstallerAddress) - '建立 Json 文件 - Dim JsonVersion As JObject = GetJson(ReadFile(Installer.GetEntry(Json("json").ToString.TrimStart("/")).Open)) - JsonVersion("id") = Id - WriteFile(VersionFolder & Id & ".json", JsonVersion.ToString) - Task.Progress = 0.6 - '解压支持库文件 - Installer.Dispose() - ExtractFile(InstallerAddress, InstallerAddress & "_unrar\") - CopyDirectory(InstallerAddress & "_unrar\maven\", McFolder & "libraries\") - DeleteDirectory(InstallerAddress & "_unrar\") - Else - '旧版格式 - Log("[Download] 进行旧版方式安装:" & InstallerAddress) - '解压 Jar 文件 - Dim JarAddress As String = McLibGet(Json("install")("path"), CustomMcFolder:=McFolder) - If File.Exists(JarAddress) Then File.Delete(JarAddress) - WriteFile(JarAddress, Installer.GetEntry(Json("install")("filePath")).Open) - Task.Progress = 0.9 - '建立 Json 文件 - Json("versionInfo")("id") = Id - If Json("versionInfo")("inheritsFrom") Is Nothing Then CType(Json("versionInfo"), JObject).Add("inheritsFrom", Inherit) - WriteFile(VersionFolder & Id & ".json", Json("versionInfo").ToString) - End If - '新建 mods 文件夹 - Directory.CreateDirectory(New McVersion(VersionFolder).GetPathIndie(True) & "mods\") - Catch ex As Exception - Throw New Exception("非新版方式安装 NeoForge 失败", ex) - Finally - Try - '清理文件 - If Installer IsNot Nothing Then Installer.Dispose() - If File.Exists(InstallerAddress) Then File.Delete(InstallerAddress) - If Directory.Exists(InstallerAddress & "_unrar\") Then DeleteDirectory(InstallerAddress & "_unrar\") - Catch ex As Exception - Log(ex, "非新版方式安装 NeoForge 清理文件时出错") - End Try - End Try - End Sub) With {.ProgressWeight = 1}) - If FixLibrary Then - If IsCustomFolder Then Throw New Exception("若需要补全支持库,就不能自定义 MC 文件夹") - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Mod 加载器支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(VersionFolder))) With {.ProgressWeight = 1, .Show = False}) - Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 11}) - End If - End If Return Loaders End Function @@ -2485,6 +2419,16 @@ Retry: ''' Public ForgeEntry As DlForgeVersionEntry = Nothing + '若要下载 NeoForge,则需要在下面两项中完成至少一项 + ''' + ''' 欲下载的 NeoForge 版本名。接受例如 36.1.4 / 14.23.5.2859 / 1.19-41.1.0 的输入。 + ''' + Public NeoForgeVersion As String = Nothing + ''' + ''' 欲下载的 NeoForge。 + ''' + Public NeoForgeEntry As DlNeoForgeVersionEntry = Nothing + ''' ''' 欲下载的 Fabric Loader 版本名。 ''' @@ -2585,7 +2529,7 @@ Retry: Public Function McInstallLoader(Request As McInstallRequest, Optional DontFixLibraries As Boolean = False) As List(Of LoaderBase) '获取缓存目录 Dim PathInstallTemp As String - If PathTemp.Contains(" ") AndAlso Request.ForgeEntry IsNot Nothing Then + If PathTemp.Contains(" ") AndAlso (Request.ForgeEntry IsNot Nothing Or Request.NeoForgeEntry IsNot Nothing) Then PathInstallTemp = OsDrive & "ProgramData\PCL\Install\" Else PathInstallTemp = PathTemp & "Install\" @@ -2622,6 +2566,9 @@ Retry: Dim ForgeFolder As String = Nothing If Request.ForgeEntry IsNot Nothing Then Request.ForgeVersion = If(Request.ForgeVersion, Request.ForgeEntry.Version) If Request.ForgeVersion IsNot Nothing Then ForgeFolder = TempMcFolder & "versions\" & Request.MinecraftName & "-forge-" & Request.ForgeVersion + Dim NeoForgeFolder As String = Nothing + If Request.NeoForgeEntry IsNot Nothing Then Request.NeoForgeVersion = If(Request.NeoForgeVersion, Request.NeoForgeEntry.Version) + If Request.NeoForgeVersion IsNot Nothing Then NeoForgeFolder = TempMcFolder & "versions\" & Request.NeoForgeVersion Dim FabricFolder As String = Nothing If Request.FabricVersion IsNot Nothing Then FabricFolder = TempMcFolder & "versions\fabric-loader-" & Request.FabricVersion & "-" & Request.MinecraftName Dim LiteLoaderFolder As String = Nothing @@ -2638,6 +2585,7 @@ Retry: '记录日志 If OptiFineFolder IsNot Nothing Then Log("[Download] OptiFine 缓存:" & OptiFineFolder) If ForgeFolder IsNot Nothing Then Log("[Download] Forge 缓存:" & ForgeFolder) + If NeoForgeFolder IsNot Nothing Then Log("[Download] NeoForge 缓存:" & NeoForgeFolder) If FabricFolder IsNot Nothing Then Log("[Download] Fabric 缓存:" & FabricFolder) If LiteLoaderFolder IsNot Nothing Then Log("[Download] LiteLoader 缓存:" & LiteLoaderFolder) Log("[Download] 对应的原版版本:" & Request.MinecraftName) @@ -2672,7 +2620,11 @@ Retry: End If 'Forge If Request.ForgeVersion IsNot Nothing Then - LoaderList.Add(New LoaderCombo(Of String)("下载 Forge " & Request.ForgeVersion, McDownloadForgeLoader(Request.ForgeVersion, Request.MinecraftName, Request.ForgeEntry, TempMcFolder, ClientLoader, Request.TargetVersionFolder, False)) With {.Show = False, .ProgressWeight = 25, .Block = Request.FabricVersion Is Nothing AndAlso Request.LiteLoaderEntry Is Nothing}) + LoaderList.Add(New LoaderCombo(Of String)("下载 Forge " & Request.ForgeVersion, McDownloadForgeLoader(Request.ForgeVersion, Request.MinecraftName, Request.ForgeEntry, TempMcFolder, ClientLoader, Request.TargetVersionFolder, False)) With {.Show = False, .ProgressWeight = 25, .Block = Request.FabricVersion Is Nothing AndAlso Request.LiteLoaderEntry Is Nothing AndAlso Request.NeoForgeEntry Is Nothing}) + End If + 'NeoForge + If Request.NeoForgeVersion IsNot Nothing Then + LoaderList.Add(New LoaderCombo(Of String)("下载 NeoForge " & Request.NeoForgeVersion, McDownloadNeoForgeLoader(Request.NeoForgeVersion, Request.MinecraftName, Request.NeoForgeEntry, TempMcFolder, ClientLoader, Request.TargetVersionFolder, False)) With {.Show = False, .ProgressWeight = 25, .Block = Request.ForgeEntry Is Nothing AndAlso Request.FabricVersion Is Nothing AndAlso Request.LiteLoaderEntry Is Nothing}) End If 'LiteLoader If Request.LiteLoaderEntry IsNot Nothing Then @@ -2685,14 +2637,14 @@ Retry: '合并安装 LoaderList.Add(New LoaderTask(Of String, String)("安装游戏", Sub(Task As LoaderTask(Of String, String)) - InstallMerge(OutputFolder, OutputFolder, OptiFineFolder, OptiFineAsMod, ForgeFolder, Request.ForgeVersion, FabricFolder, LiteLoaderFolder) + InstallMerge(OutputFolder, OutputFolder, OptiFineFolder, OptiFineAsMod, ForgeFolder, Request.ForgeVersion, NeoForgeFolder, Request.NeoForgeVersion, FabricFolder, LiteLoaderFolder) Task.Progress = 0.3 If Directory.Exists(TempMcFolder & "libraries") Then CopyDirectory(TempMcFolder & "libraries", PathMcFolder & "libraries") If Directory.Exists(TempMcFolder & "mods") Then CopyDirectory(TempMcFolder & "mods", PathMcFolder & "mods") End Sub) With {.ProgressWeight = 2, .Block = True}) '补全文件 If Not DontFixLibraries AndAlso - (Request.OptiFineEntry IsNot Nothing OrElse (Request.ForgeVersion IsNot Nothing AndAlso Request.ForgeVersion.Before(".") >= 20) OrElse Request.FabricVersion IsNot Nothing OrElse Request.LiteLoaderEntry IsNot Nothing) Then + (Request.OptiFineEntry IsNot Nothing OrElse (Request.ForgeVersion IsNot Nothing AndAlso Request.ForgeVersion.Before(".") >= 20) OrElse (Request.NeoForgeVersion IsNot Nothing) OrElse Request.FabricVersion IsNot Nothing OrElse Request.LiteLoaderEntry IsNot Nothing) Then Dim LoadersLib As New List(Of LoaderBase) LoadersLib.Add(New LoaderTask(Of String, List(Of NetFile))("分析游戏支持库文件(副加载器)", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(OutputFolder))) With {.ProgressWeight = 1, .Show = False}) LoadersLib.Add(New LoaderDownload("下载游戏支持库文件(副加载器)", New List(Of NetFile)) With {.ProgressWeight = 7, .Show = False}) @@ -2708,17 +2660,18 @@ Retry: ''' ''' 将多个版本 Json 进行合并,如果目标已存在则直接覆盖。失败会抛出异常。 ''' - Private Sub InstallMerge(OutputFolder As String, MinecraftFolder As String, Optional OptiFineFolder As String = Nothing, Optional OptiFineAsMod As Boolean = False, Optional ForgeFolder As String = Nothing, Optional ForgeVersion As String = Nothing, Optional FabricFolder As String = Nothing, Optional LiteLoaderFolder As String = Nothing) + Private Sub InstallMerge(OutputFolder As String, MinecraftFolder As String, Optional OptiFineFolder As String = Nothing, Optional OptiFineAsMod As Boolean = False, Optional ForgeFolder As String = Nothing, Optional ForgeVersion As String = Nothing, Optional NeoForgeFolder As String = Nothing, Optional NeoForgeVersion As String = Nothing, Optional FabricFolder As String = Nothing, Optional LiteLoaderFolder As String = Nothing) Log("[Download] 开始进行版本合并,输出:" & OutputFolder & ",Minecraft:" & MinecraftFolder & If(OptiFineFolder IsNot Nothing, ",OptiFine:" & OptiFineFolder, "") & If(ForgeFolder IsNot Nothing, ",Forge:" & ForgeFolder, "") & + If(NeoForgeFolder IsNot Nothing, ",NeoForge:" & NeoForgeFolder, "") & If(LiteLoaderFolder IsNot Nothing, ",LiteLoader:" & LiteLoaderFolder, "") & If(FabricFolder IsNot Nothing, ",Fabric:" & FabricFolder, "")) Directory.CreateDirectory(OutputFolder) - Dim HasOptiFine As Boolean = OptiFineFolder IsNot Nothing AndAlso Not OptiFineAsMod, HasForge As Boolean = ForgeFolder IsNot Nothing, HasLiteLoader As Boolean = LiteLoaderFolder IsNot Nothing, HasFabric As Boolean = FabricFolder IsNot Nothing - Dim OutputName As String, MinecraftName As String, OptiFineName As String, ForgeName As String, LiteLoaderName As String, FabricName As String - Dim OutputJsonPath As String, MinecraftJsonPath As String, OptiFineJsonPath As String = Nothing, ForgeJsonPath As String = Nothing, LiteLoaderJsonPath As String = Nothing, FabricJsonPath As String = Nothing + Dim HasOptiFine As Boolean = OptiFineFolder IsNot Nothing AndAlso Not OptiFineAsMod, HasForge As Boolean = ForgeFolder IsNot Nothing, HasNeoForge As Boolean = NeoForgeFolder IsNot Nothing, HasLiteLoader As Boolean = LiteLoaderFolder IsNot Nothing, HasFabric As Boolean = FabricFolder IsNot Nothing + Dim OutputName As String, MinecraftName As String, OptiFineName As String, ForgeName As String, NeoForgeName As String, LiteLoaderName As String, FabricName As String + Dim OutputJsonPath As String, MinecraftJsonPath As String, OptiFineJsonPath As String = Nothing, ForgeJsonPath As String = Nothing, NeoForgeJsonPath As String = Nothing, LiteLoaderJsonPath As String = Nothing, FabricJsonPath As String = Nothing Dim OutputJar As String, MinecraftJar As String #Region "初始化路径信息" If Not OutputFolder.EndsWithF("\") Then OutputFolder += "\" @@ -2743,6 +2696,12 @@ Retry: ForgeJsonPath = ForgeFolder & ForgeName & ".json" End If + If HasNeoForge Then + If Not NeoForgeFolder.EndsWithF("\") Then NeoForgeFolder += "\" + NeoForgeName = GetFolderNameFromPath(NeoForgeFolder) + NeoForgeJsonPath = NeoForgeFolder & NeoForgeName & ".json" + End If + If HasLiteLoader Then If Not LiteLoaderFolder.EndsWithF("\") Then LiteLoaderFolder += "\" LiteLoaderName = GetFolderNameFromPath(LiteLoaderFolder) @@ -2756,7 +2715,7 @@ Retry: End If #End Region - Dim OutputJson As JObject, MinecraftJson As JObject, OptiFineJson As JObject = Nothing, ForgeJson As JObject = Nothing, LiteLoaderJson As JObject = Nothing, FabricJson As JObject = Nothing + Dim OutputJson As JObject, MinecraftJson As JObject, OptiFineJson As JObject = Nothing, ForgeJson As JObject = Nothing, NeoForgeJson As JObject = Nothing, LiteLoaderJson As JObject = Nothing, FabricJson As JObject = Nothing #Region "读取文件并检查文件是否合规" Dim MinecraftJsonText As String = ReadFile(MinecraftJsonPath) If Not MinecraftJsonText.StartsWithF("{") Then Throw New Exception("Minecraft json 有误,地址:" & MinecraftJsonPath & ",前段内容:" & MinecraftJsonText.Substring(0, Math.Min(MinecraftJsonText.Length, 1000))) @@ -2774,6 +2733,12 @@ Retry: ForgeJson = GetJson(ForgeJsonText) End If + If HasNeoForge Then + Dim NeoForgeJsonText As String = ReadFile(NeoForgeJsonPath) + If Not NeoForgeJsonText.StartsWithF("{") Then Throw New Exception("NeoForge json 有误,地址:" & NeoForgeJsonPath & ",前段内容:" & NeoForgeJsonText.Substring(0, Math.Min(NeoForgeJsonText.Length, 1000))) + NeoForgeJson = GetJson(NeoForgeJsonText) + End If + If HasLiteLoader Then Dim LiteLoaderJsonText As String = ReadFile(LiteLoaderJsonPath) If Not LiteLoaderJsonText.StartsWithF("{") Then Throw New Exception("LiteLoader json 有误,地址:" & LiteLoaderJsonPath & ",前段内容:" & LiteLoaderJsonText.Substring(0, Math.Min(LiteLoaderJsonText.Length, 1000))) @@ -2793,6 +2758,7 @@ Retry: If(MinecraftJson("minecraftArguments"), " ").ToString & " " & If(OptiFineJson IsNot Nothing, If(OptiFineJson("minecraftArguments"), " ").ToString, " ") & " " & If(ForgeJson IsNot Nothing, If(ForgeJson("minecraftArguments"), " ").ToString, " ") & " " & + If(NeoForgeJson IsNot Nothing, If(NeoForgeJson("minecraftArguments"), " ").ToString, " ") & " " & If(LiteLoaderJson IsNot Nothing, If(LiteLoaderJson("minecraftArguments"), " ").ToString, " ") '分割参数字符串 Dim RawArguments As List(Of String) = AllArguments.Split(" ").Where(Function(l) l <> "").Select(Function(l) l.Trim).ToList @@ -2822,6 +2788,12 @@ Retry: ForgeJson.Remove("time") OutputJson.Merge(ForgeJson) End If + If HasNeoForge Then + '合并 NeoForge + NeoForgeJson.Remove("releaseTime") + NeoForgeJson.Remove("time") + OutputJson.Merge(NeoForgeJson) + End If If HasLiteLoader Then '合并 LiteLoader LiteLoaderJson.Remove("releaseTime") diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index 0c5e1467..17ded347 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -1279,7 +1279,7 @@ End Sub Private Sub BtnSelectStart_Click() Handles BtnSelectStart.Click '确认版本隔离 - If (SelectedForge IsNot Nothing OrElse SelectedFabric IsNot Nothing) AndAlso + If (SelectedForge IsNot Nothing OrElse SelectedFabric IsNot Nothing OrElse SelectedNeoForge IsNot Nothing) AndAlso (Setup.Get("LaunchArgumentIndie") = 0 OrElse Setup.Get("LaunchArgumentIndie") = 2) Then If MyMsgBox("你尚未开启版本隔离,这会导致多个 MC 共用同一个 Mod 文件夹。" & vbCrLf & "因此在切换 MC 版本时,MC 会因为读取到与当前版本不符的 Mod 而崩溃。" & vbCrLf & @@ -1295,6 +1295,7 @@ .MinecraftName = SelectedMinecraftId, .OptiFineEntry = SelectedOptiFine, .ForgeEntry = SelectedForge, + .NeoForgeEntry = SelectedNeoForge, .FabricVersion = SelectedFabric, .FabricApi = SelectedFabricApi, .OptiFabric = SelectedOptiFabric, From 27825ed1079624eb8f6e1c1e5ba09b6b332e2fc4 Mon Sep 17 00:00:00 2001 From: JingHai-Lingyun Date: Sun, 16 Jun 2024 10:32:57 +0800 Subject: [PATCH 10/36] Update PageDownloadInstall.xaml.vb Solve a conflict --- .../Pages/PageDownload/PageDownloadInstall.xaml.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index dee744cd..5bfc3261 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -499,7 +499,7 @@ Name += "-Forge_" & SelectedForge.Version End If If SelectedNeoForge IsNot Nothing Then - Name += "-NeoForge_" & SelectedNeoForge.Version.Replace("neoforge-", "").Replace("forge-", "").Replace("1.20.1-", "") + Name += "-NeoForge_" & SelectedNeoForge.StdVersion & If(SelectedNeoForge.IsBeta, "-beta", "") End If If SelectedLiteLoader IsNot Nothing Then Name += "-LiteLoader" @@ -521,7 +521,7 @@ Info += ", Forge " & SelectedForge.Version End If If SelectedNeoForge IsNot Nothing Then - Info += ", NeoForge " & SelectedNeoForge.Version.Replace("neoforge-", "").Replace("forge-", "").Replace("1.20.1-", "") + Info += ", NeoForge " & SelectedNeoForge.ohao & If(SelectedNeoForge.IsBeta, "-beta", "") End If If SelectedLiteLoader IsNot Nothing Then Info += ", LiteLoader" From d305dd3e430207359dd1e34db6df70e0c6e915f8 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 13:19:17 +0800 Subject: [PATCH 11/36] =?UTF-8?q?fix:=20=E7=89=88=E6=9C=AC=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=A0=B8=E5=BF=83=20NeoForge=20=E7=89=88=E6=9C=AC=20fix:=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85=E9=A1=B5=20NeoForge=20?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=A4=9A=E4=BD=99=E7=9A=84=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=20chores:=20NeoForge=20Icon=20=E6=98=BE=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E7=9B=AE=E5=89=8D=E6=9C=89=E7=82=B9=E5=B0=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Images/Icons/NeoForged.png | Bin 0 -> 4395 bytes .../Images/Icons/NeoForgedLarge.png | Bin 0 -> 1123 bytes .../Modules/Minecraft/ModMinecraft.vb | 49 ++++++++++++++++-- .../Pages/PageDownload/ModDownloadLib.vb | 4 +- .../PageDownload/PageDownloadInstall.xaml | 2 +- .../PageDownload/PageDownloadInstall.xaml.vb | 2 +- .../Pages/PageVersion/PageVersionOverall.xaml | 1 + Plain Craft Launcher 2/Resources/Custom.xaml | 2 + 8 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 Plain Craft Launcher 2/Images/Icons/NeoForged.png create mode 100644 Plain Craft Launcher 2/Images/Icons/NeoForgedLarge.png diff --git a/Plain Craft Launcher 2/Images/Icons/NeoForged.png b/Plain Craft Launcher 2/Images/Icons/NeoForged.png new file mode 100644 index 0000000000000000000000000000000000000000..a9f8076f3d25782eb7fc55f0ef491ecba1c13eed GIT binary patch literal 4395 zcmV+`5!CL9P)Gk#@kXS=4A{5HQ zphiFmi68uciHRuD_-YW0iAEB&NNP-kC~8poM2IA)G2tQJih@*#zzwCgMJdorZ*RHx zoP8d9ueIiybNFGdwa-&kdOQxxaNF4lSk3orc=b1-AfX4g&)SQQjP26crSg&f&Z6|NfZ~y-1(bR6{ zK~?DWdKCR0mt!Q`a>p zG);q|*d*obmmlKEul^4dM9OiO}o!Kp;(1s;Zg+ zanh5jlBOyB{s5QMIOllk$)|A6fx=*IK!0_BhPZmYUT^7YrJAN&lT`o|BG_j@zn zm7_5)d;J?Ye&hF0j!RUP@pz1?lK1*N@`cay*^m7bS<#<)t}aL1^_rhx?YbMN#-oD) zFv4hSm!07bVg(W5*tN$IiHlZM)r|d}fqI_S)>^#xpz(ieEh-TJV`f#tm{zBfl)NY? z1_Sb5pJ}gWj3v#o$x3z4bt;i&8AX3URz%>m{UZWto@1>gNfH#$R!x@yV64F=7BMn2 z*7-3n1)ymfnx?^fj~IiswjIQxVeBTNs+8kV^s^f9O+#WW*6!Js{bb%2%q&0$sx2pY77Wzo*&p|H~GVC#smOkE$7dl=du5Ogr;c#xc2&Mpl!rChii?Hszxfcoz-Q@ zNB-t7smd{maD1iD3vT`12!;=Q_3YDlzX*bekhc@bdj)Blq8i< zA|tVupe!2nB_QlKNNWt%8jS2QKma+UQIVrZn+pJRFIaRN)057M0+5LgBXL-Y!8Z-% zc#IP8UZ)#C(iGcY!OZQ$Y`>4BXV;8C-icfrs0;`Zs*q9Zo~VAs;c?s zM?Q-89+Tya9(#y$AKt;uF)B?GM*sUYOqK(RwU!@v@k_|_3~Lh}d-PHC(ML#<1Y<3y z|Lp;cwP*;~H0Aa?UxZDPrSZvVdo*d&RrUUEFwb+=*4J>gLxZyO)DG%(@?8f&Xd1rw z$y1c0T|}axe8I_^NfJv{j=A-=+qmoHufWwcqtPxO{rEpeOP^+p9{m#MPCtMbJIes| zjEe6y+!jVXnez<4F{CUUX_|5V?2xB6hva#Mguu;y8wrsCY4F4) zTLeNx=&ugwY{2gBXa3IGe?$YeCzBcPi<_H zWd#|^-F}Mh{zMy52X_@FUHm=YCeRH!vN-++m2v@fwXwrvc8(snBND5KjoF~Yf=xi?x5@&ECEg2ItKdecfa0*BrVu5SKzfm5>n7dVf@!&I z0F*fSA0M2?o%`Z{GuE zug$6ZyS^v=Uq-U}k^m5a^}eD;!Nk>FAB3eDqBbdWNqwyK!_v8_LRrUnfS^dBmz-q1 zGysT$!vrwW4%Y8Gh@N9qz%I)!Un&53fjsyz z(8keQKSqD;YC!PgE%ZHaB8-QKv8e9w^oRZcRe^epzUcMn z54|3$@f8A~W59SDf{$skL2G!X7-0KX0RiJYQaL0^_nzNJ_ALM6S%4HPNU;iy!}Qj$ z{q+fm#>D6`lA>jRDpaF5)+45b5@X^lj5#QQ*ix%5W6vTONn$!oVic#rqoDx}J_V&iRY=857;KV+2mk9d?|jeuSY2IbJ%f8*mr-P~VOIrQxo6!cY?xc6 zs;>F-zx^P?8n(BG^w*Db&yT!10-&%xGPqq6RiIbUf9V^M{#ta4O$|+rWLZ4dfC&Iq zRkO9ZP134oVoW@#HlQtPWUBL1fQMcgIzSiHNYe zGC&;|JbBig1GFmJs-Co7KwK47H24{NGS9OG6*y=RGy2mww9N-d72RNW{wNZ|T@5iu zr|R4IJ4DMo(`Nh3d|%zv=2CEbueR;rQH?=Y2Y`y=$2+l+;G?UyDWaaRTdRU{p;D#OSilW|Qii+)XXOP|&>w`WU=bmKa{5f1z5(?08EE-N= zyR>X~)SUxnbr4wX`N*uGY;K%mSi;WE78~cDq&jzo;qC|>Z*zRDB4iG+7Vo$D^1I(b z69lQp*t=ehz3Wv_#Z-A`2QCVL=@mc~bv0qMgEk&x1reRK#Ok44ox>Oqbg?=sEZHC} zGQcloKxi4@JxD!nRYAe~LrZdw9tQ*ut|n$S1Z$MUwuvYUlCL27DyHaDlhIUxtyH7G zUIM_p%mbjncCBnxN~i)g8Kzi8oCQ^^1-e9wD$+QlQN-0q2<^lVw>3utz&p&1C*khb zLXu*<;jodc={>N>W$aq6$AYKM0fXU;0#<&gm<#oYN45}U@L>Bf`b53VD)H~^X&`Rpz*>JXOH82hNwq+J$kQu6}C5M-C(I3E zi8Yb>Dv^$o4-gARp$6)5&-!ZUGWhXu!Wg^go)CQSlXHJX*si->qyj0XNFyK~Y@1^g zrR}thQYWXyM+}9J2EgGm(d{`s79?(x+Koe1m6YRZ!78f;iXtcP7j!8hUyc^C{Y$qE zmm!x8K=c6c^k#~cx$xe5l9e^?`1SXZ4%SGEoIk$*Px$>mdl&2LYcuT(hg z-1}>|vcm0d@x?#DwXdHrXkX#P<*;iPGuz;ys|DY3;@#{dXy`14?iX zlS>DnEo6$@V6&NIN6*yld_KYPHdG|m3@WTrmA)it|YyELvLc+WQ;Khu_> zDC<|RvwqduV$Gi_*cAJNuZj`aoPQT%IQ_xDZfgbwSB-JyXldPHTJ%Zt9-w$1kUQ=s zS=L{Y#;orWcVLWRxVgn}V;J}T)^PoEuEW^nC*Cvl0d-ZgJKTx20M7CC$Dg2a4(~lD zZn>GOk6m>z0P_L9F)-fY^m~5~#yc^WAO~zxy4`2+&|6{U7k(GpTUlIX)yR(h0N5Dv z)vr7rD@)UqYp=WJ2mmmp0xE5ls6m6BG`zpGq3GghpsvW;l35OHV@g7Z`dwEs19g%5 zZQ2S~J5{Z^pB!ieZL(J;ds+4Ua|ZKJxlGsA6-HZY;~Wl9^i~lAy7wqUaTq z1mlrq-eq2tT$*e1-gErgV+>aN(FRB?u-fnU4Tmzo=w3DVCCjC*<|VqejsZt1mNrJ# zy9;B?%&$b8ag&skP1;iRD;bC%CP!77DG`a=YTx(?038@fk}TM=L{)!Fgu)nMcwyre zkHbBoEhcK3Chknz5;JQr?UeVK7VmvLt#0#y9RS7{h8H&e)fjnTlAoA<@ZNiW=WQW` z`?~8H`siYg{o7Rzs&F;Ny#4DIA literal 0 HcmV?d00001 diff --git a/Plain Craft Launcher 2/Images/Icons/NeoForgedLarge.png b/Plain Craft Launcher 2/Images/Icons/NeoForgedLarge.png new file mode 100644 index 0000000000000000000000000000000000000000..55848a69dfab001562da00828f41574339f6910f GIT binary patch literal 1123 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrU=i?iaSW-L^JcES$CN^e3<0}fkT0hsRLrzJF^SY&)I(cI=d$AZkF-tHEUvWa_bAfKf1Z#HQ)UGDQU*W#%bRk zoO-(8xOKrU>leE;Hp$!1p80)N^#ycG?-+hKyZUz8$D~GK2-l#p#C!Fq(uzFRAMYF+9yUetiCwpdAE)Kooc3yh@t$tba&D?jtReXIH z)Bbyg+SBajtey3bcg=Lom2f`pk{|rSksaz^B(L8&&$uV@{^97K?`F&{TK`sl`(}P; zVaMm!uKg*HzieZiJ^$s^M{AcYo>#ANZ&k&czcXfH1l}FP4FX$2eP`Xwxi4v)oi)dJ zv*^jL1yPe`MjD^C*t#Y3X8N+tr<<}mn@SB>8c~8%=ck0k)|uYdZaj`L6bzsHdE=Zc zXLKiart;|Qy_uO7_&C@(>%y63mlvmf`+Du5YuI=7`*V8dA3wGD`$zpW+U$vnByQg?WI$BiGU_BZ!S`>0%- z;d$jn>cd<;P@D;D<&`bV%ijIRg#8J!X_yn-Im(jY!O$C zZlYhOc-43QrvL5p=1uu&cNs0|Go->ickVo}RQUg2nCrH|IoBl$9a4C2)i1Kvxb6Mw<&;$S!O7GzS literal 0 HcmV?d00001 diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb index 458a42a4..efb1dfba 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb @@ -1,4 +1,5 @@ Imports System.IO.Compression +Imports MS.Internal Public Module ModMinecraft @@ -345,7 +346,7 @@ Public Module ModMinecraft End If Next End If - '从 Forge Arguments 中获取版本号 + '从 Forge / NeoForge Arguments 中获取版本号 If JsonObject("arguments") IsNot Nothing AndAlso JsonObject("arguments")("game") IsNot Nothing Then Dim Mark As Boolean = False For Each Argument In JsonObject("arguments")("game") @@ -729,12 +730,20 @@ Recheck: State = McVersionState.Fabric Version.FabricVersion = If(RegexSeek(RealJson, "(?<=(net.fabricmc:fabric-loader:)|(org.quiltmc:quilt-loader:))[0-9\.]+(\+build.[0-9]+)?"), "未知版本").Replace("+build", "") Version.HasFabric = True - ElseIf RealJson.Contains("minecraftforge") Then + ElseIf RealJson.Contains("minecraftforge") AndAlso Not RealJson.Contains("neoforge") Then State = McVersionState.Forge Version.ForgeVersion = RegexSeek(RealJson, "(?<=forge:[0-9\.]+(_pre[0-9]*)?\-)[0-9\.]+") If Version.ForgeVersion Is Nothing Then Version.ForgeVersion = RegexSeek(RealJson, "(?<=net\.minecraftforge:minecraftforge:)[0-9\.]+") If Version.ForgeVersion Is Nothing Then Version.ForgeVersion = If(RegexSeek(RealJson, "(?<=net\.minecraftforge:fmlloader:[0-9\.]+-)[0-9\.]+"), "未知版本") Version.HasForge = True + ElseIf RealJson.Contains("neoforge") Then + State = McVersionState.NeoForge + Dim JsonStr1() As String = RealJson.Replace(" ", "").Split("""--fml.neoForgeVersion""," & vbCrLf & """") '这里的实现比较抽象,正则我写不会 + Dim JsonStr2() As String = JsonStr1(1).Split("""") + Version.NeoForgeVersion = JsonStr2(0) + If Version.NeoForgeVersion Is Nothing Then Version.NeoForgeVersion = RegexSeek(RealJson, "(?<=""--fml.neoForgeVersion"",)[0-9\.]+") + If Version.NeoForgeVersion Is Nothing Then Version.NeoForgeVersion = If(RegexSeek(RealJson, "(?<=net\.minecraftforge:fmlloader:[0-9\.]+-)[0-9\.]+"), "未知版本") + Version.HasNeoForge = True End If Version.IsApiLoaded = True End Select @@ -752,6 +761,8 @@ ExitDataLoad: Logo = PathImage & "Blocks/CobbleStone.png" Case McVersionState.Forge Logo = PathImage & "Blocks/Anvil.png" + Case McVersionState.NeoForge + Logo = PathImage & "Icons/NeoForged.png" Case McVersionState.Fabric Logo = PathImage & "Blocks/Fabric.png" Case McVersionState.OptiFine @@ -780,7 +791,7 @@ ExitDataLoad: End If Case McVersionState.Old Info = "远古版本" - Case McVersionState.Original, McVersionState.Forge, McVersionState.Fabric, McVersionState.OptiFine, McVersionState.LiteLoader + Case McVersionState.Original, McVersionState.Forge, McVersionState.NeoForge, McVersionState.Fabric, McVersionState.OptiFine, McVersionState.LiteLoader Info = Version.ToString Case McVersionState.Fool Info = GetMcFoolName(Version.McName) @@ -813,6 +824,7 @@ ExitDataLoad: WriteIni(Path & "PCL\Setup.ini", "VersionOptiFine", Version.OptiFineVersion) WriteIni(Path & "PCL\Setup.ini", "VersionLiteLoader", Version.HasLiteLoader) WriteIni(Path & "PCL\Setup.ini", "VersionForge", Version.ForgeVersion) + WriteIni(Path & "PCL\Setup.ini", "VersionNeoForge", Version.NeoForgeVersion) WriteIni(Path & "PCL\Setup.ini", "VersionApiCode", Version.SortCode) WriteIni(Path & "PCL\Setup.ini", "VersionOriginal", Version.McName) WriteIni(Path & "PCL\Setup.ini", "VersionOriginalMain", Version.McCodeMain) @@ -852,6 +864,7 @@ ExitDataLoad: OptiFine Old Forge + NeoForge LiteLoader Fabric End Enum @@ -903,6 +916,17 @@ ExitDataLoad: ''' Public ForgeVersion As String = "" + 'NeoForge + + ''' + ''' 该版本是否安装了 NeoForge。 + ''' + Public HasNeoForge As Boolean = False + ''' + ''' NeoForge 版本号,如 31.1.2、14.23.5.2847。 + ''' + Public NeoForgeVersion As String = "" + 'Fabric ''' @@ -929,6 +953,7 @@ ExitDataLoad: Public Overrides Function ToString() As String ToString = "" If HasForge Then ToString += ", Forge" & If(ForgeVersion = "未知版本", "", " " & ForgeVersion) + If HasNeoForge Then ToString += ", NeoForge" & If(NeoForgeVersion = "未知版本", "", " " & NeoForgeVersion) If HasFabric Then ToString += ", Fabric" & If(FabricVersion = "未知版本", "", " " & FabricVersion) If HasOptiFine Then ToString += ", OptiFine" & If(OptiFineVersion = "未知版本", "", " " & OptiFineVersion) If HasLiteLoader Then ToString += ", LiteLoader" @@ -965,6 +990,16 @@ ExitDataLoad: Else Throw New Exception("无效的 Forge 版本:" & ForgeVersion) End If + ElseIf HasNeoForge Then + If NeoForgeVersion = "未知版本" Then Return 0 + Dim SubVersions = NeoForgeVersion.Split(".") + If SubVersions.Length = 4 Then + _SortCode = Val(SubVersions(0)) * 1000000 + Val(SubVersions(1)) * 10000 + Val(SubVersions(3)) + ElseIf SubVersions.Length = 3 Then + _SortCode = Val(SubVersions(0)) * 1000000 + Val(SubVersions(1)) * 10000 + Val(SubVersions(2)) + Else + Throw New Exception("无效的 NeoForge 版本:" & NeoForgeVersion) + End If ElseIf HasOptiFine Then If OptiFineVersion = "未知版本" Then Return 0 '由对应原版次级版本号(2 位)、字母(2 位)、末尾数字(2 位)、测试标记(2 位,正式版为 99,Pre[x] 为 50+x,Beta[x] 为 x)组成 @@ -1175,6 +1210,7 @@ OnLoaded: Dim VersionInfo As New McVersionInfo With { .FabricVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionFabric", ""), .ForgeVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionForge", ""), + .NeoForgeVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionNeoForge", ""), .OptiFineVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionOptiFine", ""), .HasLiteLoader = ReadIni(Version.Path & "PCL\Setup.ini", "VersionLiteLoader", False), .SortCode = ReadIni(Version.Path & "PCL\Setup.ini", "VersionApiCode", -1), @@ -1185,6 +1221,7 @@ OnLoaded: } VersionInfo.HasFabric = VersionInfo.FabricVersion.Count > 1 VersionInfo.HasForge = VersionInfo.ForgeVersion.Count > 1 + VersionInfo.HasNeoForge = VersionInfo.NeoForgeVersion.Count > 1 VersionInfo.HasOptiFine = VersionInfo.OptiFineVersion.Count > 1 Version.Version = VersionInfo End If @@ -1273,7 +1310,7 @@ OnLoaded: McVersionFilter(VersionList, VersionListOriginal, {McVersionState.Fool}, McVersionCardType.Fool) '筛选 API 版本 - McVersionFilter(VersionList, VersionListOriginal, {McVersionState.Forge, McVersionState.LiteLoader, McVersionState.Fabric}, McVersionCardType.API) + McVersionFilter(VersionList, VersionListOriginal, {McVersionState.Forge, McVersionState.NeoForge, McVersionState.LiteLoader, McVersionState.Fabric}, McVersionCardType.API) '将老版本预先分类入不常用,只剩余原版、快照、OptiFine Dim VersionUseful As New List(Of McVersion) @@ -1407,7 +1444,7 @@ OnLoaded: End Function) End If - 'API 版本:优先按版本排序,此后【先放 Fabric,再放 Forge(按版本号从高到低排序),最后放 LiteLoader(按名称排序)】 + 'API 版本:优先按版本排序,此后【先放 Fabric,再放 Forge,再放 NeoForge(按版本号从高到低排序),最后放 LiteLoader(按名称排序)】 If ResultVersionList.ContainsKey(McVersionCardType.API) Then ResultVersionList(McVersionCardType.API) = Sort(ResultVersionList(McVersionCardType.API), Function(Left As McVersion, Right As McVersion) @@ -1419,6 +1456,8 @@ OnLoaded: Return Left.Version.HasFabric ElseIf Left.Version.HasForge Xor Right.Version.HasForge Then Return Left.Version.HasForge + ElseIf Left.Version.HasNeoForge Xor Right.Version.HasNeoForge Then + Return Left.Version.HasNeoForge ElseIf Not Left.Version.SortCode <> Right.Version.SortCode Then Return Left.Version.SortCode > Right.Version.SortCode Else diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 8b5bc2f7..a8ca4d73 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2194,9 +2194,9 @@ Retry: .Title = If(Entry.IsBeta, Entry.StdVersion & "-beta", Entry.StdVersion), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, .Info = If(Entry.IsBeta, "测试版", "稳定版") & If(Entry.ReleaseTime = "", - If(ModeDebug, "种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), + If(ModeDebug, If(Entry.Category IsNot Nothing, "种类:" & Entry.Category, "") & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), "发布于 " & Entry.ReleaseTime & If(ModeDebug, ",种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), - .Logo = PathImage & "Blocks/Anvil.png" + .Logo = PathImage & "Icons/NeoForged.png" } AddHandler NewItem.Click, OnClick '建立菜单 diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml index 69c47f36..b16b8646 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml @@ -89,7 +89,7 @@ - + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index 17ded347..ef6a2f98 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -541,7 +541,7 @@ ElseIf SelectedForge IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Anvil.png" ElseIf SelectedNeoForge IsNot Nothing Then - Return "pack://application:,,,/images/Blocks/Anvil.png" + Return "pack://application:,,,/images/Icons/NeoForged.png" ElseIf SelectedLiteLoader IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Egg.png" ElseIf SelectedOptiFine IsNot Nothing Then diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml index 34523574..50b7b9f8 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml @@ -37,6 +37,7 @@ + diff --git a/Plain Craft Launcher 2/Resources/Custom.xaml b/Plain Craft Launcher 2/Resources/Custom.xaml index f35be1d9..f0236e47 100644 --- a/Plain Craft Launcher 2/Resources/Custom.xaml +++ b/Plain Craft Launcher 2/Resources/Custom.xaml @@ -202,6 +202,8 @@ + + From 66182f2cd0e1f373d7eb519298504703ded03a45 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 14:41:16 +0800 Subject: [PATCH 12/36] =?UTF-8?q?fix:=20Icon=20=E6=98=BE=E7=A4=BA=E5=8F=8A?= =?UTF-8?q?=E5=85=B6=E5=AF=BC=E8=87=B4=E7=9A=84=E5=B4=A9=E6=BA=83=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20fix:=201.20.1=20NeoForge=20=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=8B=BC=E6=8E=A5=E9=94=99=E8=AF=AF=20fix:?= =?UTF-8?q?=20=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E9=80=89=E6=8B=A9=20NeoForge=20=E5=90=8E=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BA=86=20rawVersion=20=E4=BD=9C=E4=B8=BA=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Images/Icons/NeoForged.png | Bin 4395 -> 1412 bytes .../Images/Icons/NeoForgedLarge.png | Bin 1123 -> 0 bytes .../Modules/Minecraft/ModDownload.vb | 22 ++++++-------- .../Modules/Minecraft/ModMinecraft.vb | 8 ++--- .../Pages/PageDownload/ModDownloadLib.vb | 28 ++++++++++++++---- .../PageDownload/PageDownloadInstall.xaml | 2 +- .../PageDownload/PageDownloadInstall.xaml.vb | 4 +-- .../Plain Craft Launcher 2.vbproj | 5 ++-- 8 files changed, 41 insertions(+), 28 deletions(-) delete mode 100644 Plain Craft Launcher 2/Images/Icons/NeoForgedLarge.png diff --git a/Plain Craft Launcher 2/Images/Icons/NeoForged.png b/Plain Craft Launcher 2/Images/Icons/NeoForged.png index a9f8076f3d25782eb7fc55f0ef491ecba1c13eed..7d46d392e44d7b7007041bb213ddc4540925b33f 100644 GIT binary patch delta 1393 zcmV-%1&;cwB7_T&B!2;OQb$4nuFf3k00004b3#c}2nYxWd-SFZiwG`xm;zNNn8jUdq38pW|O9P1^ zF-D^y(tS`aqS!(dH7UD6Drl56(FY5WE@&^BF15SU*~`qH@qYoknKS3?>`bj5&CK_- z^X-4m|IfE`zCD-WUxg*X2L@LE~z0%k6__}pTqnI-nE-e4#_5SfneW?J6Lm!`x zny-=${_l41e}^Lg>jGHAWwk*(9&bP%PnDMY@Zf&0x^y*}0uSIF9vNxIxI!TxjYg-f z^kZ3o^Iv{;^naJjKSi|MU3WGSabwpftafb(N{+S15AIKDi91%^od5t!#%TK?;0VCF z0M;<{fOtG!hdiDdEqC$EY42i_RRJ^&kBk`lB?mwnib?Q-Kr_bqXf!%wkgq)UJl{Jo z``dJnmJ0_1P#3Jl;<}%EfoQw8uaDr`<=>6cm2l2oPk(Ux`uhp)$UARg*E4fzNX=z1 zE_7Q%?7-WHwwKFg`yt>6z`6j|u)P3={{m}@H$c%D*R>n-Fs3t_&F11f+=J#Z&Q z(;ETVmVcJx-YVRSd<6xdU@Aok)&&sqP+OJL6?c}1TSgHeSZ{6??MCEXOjB~KuEMX= zMGi6+A8OkV0Y?DV1+a#p2l%}JMIUZ>focSP9rtg*@2fnCQYpWuP{DQ#1*q|;0M+>N z-S0!-uVx^C$()>ih3_%muC@ITa0Fmo0Be*6On<)}(=cFMm#{(py zvF{Q98WThS5uSs++CaCQAPK;A0$irNk05s5UmIm(wqyV9&79H~*povQu zBY#Snwmc_bzZkmdiwOW{2si@RUVxGZ@Bj&SQo$=B@a09?9-h^q;AxHspc~41G;4> zha||RXE9Ei$M@!L!bdQAgDMBw%8!;qUk8UIV%eO@iR+K`ZXVEb0?!R@dH16s0F3~- zsq1Sv;Ci%yYFGh(7%zrLS;%Jasc%*iDYropKyOfGKofwLLth7vvP9c-Dz#Ec&3~=b zax$pb0AL8f83K*~wilq}0SeE@TnauBDhU2PlPU2rEf=~v1|h&#dOPl`HkHiGzFs-d za^$|p>zKVd2D2%Am#-lBKUY!yfR)N@SSCoBPPCEDL(ag_3tX)j9AJ2cWm}UR~Fp;Xf zk`z{~z9_UmxmC-lE|&<0$?dcS7z)tc(J=!6*qhczUh2t}31hu4<%}HntxE zjsUC+U=7PNLDwT&wiY9WitoFf*tX#-P~rB)m8Am*zY5!5eY8@TAbWD~M$BT@{}A4P z>Y;G}SiVHvC7(IGk#@kXS=4A{5HQ zphiFmi68uciHRuD_-YW0iAEB&NNP-kC~8poM2IA)G2tQJih@*#zzwCgMJdorZ*RHx zoP8d9ueIiybNFGdwa-&kdOQxxaNF4lSk3orc=b1-AfX4g&)SQQjP26crSg&f&Z6|NfZ~y-1(bR6{ zK~?DWdKCR0mt!Q`a>p zG);q|*d*obmmlKEul^4dM9OiO}o!Kp;(1s;Zg+ zanh5jlBOyB{s5QMIOllk$)|A6fx=*IK!0_BhPZmYUT^7YrJAN&lT`o|BG_j@zn zm7_5)d;J?Ye&hF0j!RUP@pz1?lK1*N@`cay*^m7bS<#<)t}aL1^_rhx?YbMN#-oD) zFv4hSm!07bVg(W5*tN$IiHlZM)r|d}fqI_S)>^#xpz(ieEh-TJV`f#tm{zBfl)NY? z1_Sb5pJ}gWj3v#o$x3z4bt;i&8AX3URz%>m{UZWto@1>gNfH#$R!x@yV64F=7BMn2 z*7-3n1)ymfnx?^fj~IiswjIQxVeBTNs+8kV^s^f9O+#WW*6!Js{bb%2%q&0$sx2pY77Wzo*&p|H~GVC#smOkE$7dl=du5Ogr;c#xc2&Mpl!rChii?Hszxfcoz-Q@ zNB-t7smd{maD1iD3vT`12!;=Q_3YDlzX*bekhc@bdj)Blq8i< zA|tVupe!2nB_QlKNNWt%8jS2QKma+UQIVrZn+pJRFIaRN)057M0+5LgBXL-Y!8Z-% zc#IP8UZ)#C(iGcY!OZQ$Y`>4BXV;8C-icfrs0;`Zs*q9Zo~VAs;c?s zM?Q-89+Tya9(#y$AKt;uF)B?GM*sUYOqK(RwU!@v@k_|_3~Lh}d-PHC(ML#<1Y<3y z|Lp;cwP*;~H0Aa?UxZDPrSZvVdo*d&RrUUEFwb+=*4J>gLxZyO)DG%(@?8f&Xd1rw z$y1c0T|}axe8I_^NfJv{j=A-=+qmoHufWwcqtPxO{rEpeOP^+p9{m#MPCtMbJIes| zjEe6y+!jVXnez<4F{CUUX_|5V?2xB6hva#Mguu;y8wrsCY4F4) zTLeNx=&ugwY{2gBXa3IGe?$YeCzBcPi<_H zWd#|^-F}Mh{zMy52X_@FUHm=YCeRH!vN-++m2v@fwXwrvc8(snBND5KjoF~Yf=xi?x5@&ECEg2ItKdecfa0*BrVu5SKzfm5>n7dVf@!&I z0F*fSA0M2?o%`Z{GuE zug$6ZyS^v=Uq-U}k^m5a^}eD;!Nk>FAB3eDqBbdWNqwyK!_v8_LRrUnfS^dBmz-q1 zGysT$!vrwW4%Y8Gh@N9qz%I)!Un&53fjsyz z(8keQKSqD;YC!PgE%ZHaB8-QKv8e9w^oRZcRe^epzUcMn z54|3$@f8A~W59SDf{$skL2G!X7-0KX0RiJYQaL0^_nzNJ_ALM6S%4HPNU;iy!}Qj$ z{q+fm#>D6`lA>jRDpaF5)+45b5@X^lj5#QQ*ix%5W6vTONn$!oVic#rqoDx}J_V&iRY=857;KV+2mk9d?|jeuSY2IbJ%f8*mr-P~VOIrQxo6!cY?xc6 zs;>F-zx^P?8n(BG^w*Db&yT!10-&%xGPqq6RiIbUf9V^M{#ta4O$|+rWLZ4dfC&Iq zRkO9ZP134oVoW@#HlQtPWUBL1fQMcgIzSiHNYe zGC&;|JbBig1GFmJs-Co7KwK47H24{NGS9OG6*y=RGy2mww9N-d72RNW{wNZ|T@5iu zr|R4IJ4DMo(`Nh3d|%zv=2CEbueR;rQH?=Y2Y`y=$2+l+;G?UyDWaaRTdRU{p;D#OSilW|Qii+)XXOP|&>w`WU=bmKa{5f1z5(?08EE-N= zyR>X~)SUxnbr4wX`N*uGY;K%mSi;WE78~cDq&jzo;qC|>Z*zRDB4iG+7Vo$D^1I(b z69lQp*t=ehz3Wv_#Z-A`2QCVL=@mc~bv0qMgEk&x1reRK#Ok44ox>Oqbg?=sEZHC} zGQcloKxi4@JxD!nRYAe~LrZdw9tQ*ut|n$S1Z$MUwuvYUlCL27DyHaDlhIUxtyH7G zUIM_p%mbjncCBnxN~i)g8Kzi8oCQ^^1-e9wD$+QlQN-0q2<^lVw>3utz&p&1C*khb zLXu*<;jodc={>N>W$aq6$AYKM0fXU;0#<&gm<#oYN45}U@L>Bf`b53VD)H~^X&`Rpz*>JXOH82hNwq+J$kQu6}C5M-C(I3E zi8Yb>Dv^$o4-gARp$6)5&-!ZUGWhXu!Wg^go)CQSlXHJX*si->qyj0XNFyK~Y@1^g zrR}thQYWXyM+}9J2EgGm(d{`s79?(x+Koe1m6YRZ!78f;iXtcP7j!8hUyc^C{Y$qE zmm!x8K=c6c^k#~cx$xe5l9e^?`1SXZ4%SGEoIk$*Px$>mdl&2LYcuT(hg z-1}>|vcm0d@x?#DwXdHrXkX#P<*;iPGuz;ys|DY3;@#{dXy`14?iX zlS>DnEo6$@V6&NIN6*yld_KYPHdG|m3@WTrmA)it|YyELvLc+WQ;Khu_> zDC<|RvwqduV$Gi_*cAJNuZj`aoPQT%IQ_xDZfgbwSB-JyXldPHTJ%Zt9-w$1kUQ=s zS=L{Y#;orWcVLWRxVgn}V;J}T)^PoEuEW^nC*Cvl0d-ZgJKTx20M7CC$Dg2a4(~lD zZn>GOk6m>z0P_L9F)-fY^m~5~#yc^WAO~zxy4`2+&|6{U7k(GpTUlIX)yR(h0N5Dv z)vr7rD@)UqYp=WJ2mmmp0xE5ls6m6BG`zpGq3GghpsvW;l35OHV@g7Z`dwEs19g%5 zZQ2S~J5{Z^pB!ieZL(J;ds+4Ua|ZKJxlGsA6-HZY;~Wl9^i~lAy7wqUaTq z1mlrq-eq2tT$*e1-gErgV+>aN(FRB?u-fnU4Tmzo=w3DVCCjC*<|VqejsZt1mNrJ# zy9;B?%&$b8ag&skP1;iRD;bC%CP!77DG`a=YTx(?038@fk}TM=L{)!Fgu)nMcwyre zkHbBoEhcK3Chknz5;JQr?UeVK7VmvLt#0#y9RS7{h8H&e)fjnTlAoA<@ZNiW=WQW` z`?~8H`siYg{o7Rzs&F;Ny#4DIA diff --git a/Plain Craft Launcher 2/Images/Icons/NeoForgedLarge.png b/Plain Craft Launcher 2/Images/Icons/NeoForgedLarge.png deleted file mode 100644 index 55848a69dfab001562da00828f41574339f6910f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1123 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrU=i?iaSW-L^JcES$CN^e3<0}fkT0hsRLrzJF^SY&)I(cI=d$AZkF-tHEUvWa_bAfKf1Z#HQ)UGDQU*W#%bRk zoO-(8xOKrU>leE;Hp$!1p80)N^#ycG?-+hKyZUz8$D~GK2-l#p#C!Fq(uzFRAMYF+9yUetiCwpdAE)Kooc3yh@t$tba&D?jtReXIH z)Bbyg+SBajtey3bcg=Lom2f`pk{|rSksaz^B(L8&&$uV@{^97K?`F&{TK`sl`(}P; zVaMm!uKg*HzieZiJ^$s^M{AcYo>#ANZ&k&czcXfH1l}FP4FX$2eP`Xwxi4v)oi)dJ zv*^jL1yPe`MjD^C*t#Y3X8N+tr<<}mn@SB>8c~8%=ck0k)|uYdZaj`L6bzsHdE=Zc zXLKiart;|Qy_uO7_&C@(>%y63mlvmf`+Du5YuI=7`*V8dA3wGD`$zpW+U$vnByQg?WI$BiGU_BZ!S`>0%- z;d$jn>cd<;P@D;D<&`bV%ijIRg#8J!X_yn-Im(jY!O$C zZlYhOc-43QrvL5p=1uu&cNs0|Go->ickVo}RQUg2nCrH|IoBl$9a4C2)i1Kvxb6Mw<&;$S!O7GzS diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 69e2308d..9b4a6936 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -771,7 +771,7 @@ Public Value As JObject End Structure ''' - ''' 是否为新版 Forge。(即为 Minecraft 1.13+) + ''' 是否为新版 NeoForge。(即为 Minecraft 1.13+) ''' Public ReadOnly Property IsNewType As Boolean Get @@ -804,21 +804,17 @@ ''' Public ReadOnly Property FileName As String Get - Return "neoforge-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" + If StdVersion.StartsWith("47.") Then 'NeoForge 1.20.1 的版本命名有些特殊... + Return "forge-" & Inherit & "-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" + Else + Return "neoforge-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" + End If End Get End Property ''' ''' 文件扩展名。 ''' - Public ReadOnly Property FileSuffix As String - Get - If Category = "installer" Then - Return "jar" - Else - Return "jar" - End If - End Get - End Property + Public FileSuffix As String = "jar" End Class ''' ''' NeoForge 版本列表,主加载器。 @@ -882,10 +878,10 @@ Dim IsBeta As Boolean Dim rawVersion As String = Token("rawVersion") If rawVersion.Contains("-beta") Then - StdVersion = Token("version").ToString().Replace("neoforge-", "").Replace("-beta", "") + StdVersion = Token("version").ToString().Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") IsBeta = True Else - StdVersion = Token("version").ToString().Replace("neoforge-", "") + StdVersion = Token("version").ToString().Replace("neoforge-", "").Replace("1.20.1-", "") IsBeta = False End If Name = rawVersion diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb index efb1dfba..f1cdb964 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb @@ -736,12 +736,12 @@ Recheck: If Version.ForgeVersion Is Nothing Then Version.ForgeVersion = RegexSeek(RealJson, "(?<=net\.minecraftforge:minecraftforge:)[0-9\.]+") If Version.ForgeVersion Is Nothing Then Version.ForgeVersion = If(RegexSeek(RealJson, "(?<=net\.minecraftforge:fmlloader:[0-9\.]+-)[0-9\.]+"), "未知版本") Version.HasForge = True - ElseIf RealJson.Contains("neoforge") Then - State = McVersionState.NeoForge - Dim JsonStr1() As String = RealJson.Replace(" ", "").Split("""--fml.neoForgeVersion""," & vbCrLf & """") '这里的实现比较抽象,正则我写不会 + ElseIf RealJson.Contains("neoforge") Then '1.20.1 NeoForge Json 内信息不同,为了方便直接截断 orgeVersion;这里的实现比较抽象,正则我写不会 + State = McVersionState.NeoForge '1.20.1 Json 标识:"--fml.forgeVersion" 1.20.1 以上 Json 标识:"--fml.neoForgeVersion" + Dim JsonStr1() As String = RealJson.Replace(" ", "").Split("orgeVersion""," & vbCrLf & """") Dim JsonStr2() As String = JsonStr1(1).Split("""") Version.NeoForgeVersion = JsonStr2(0) - If Version.NeoForgeVersion Is Nothing Then Version.NeoForgeVersion = RegexSeek(RealJson, "(?<=""--fml.neoForgeVersion"",)[0-9\.]+") + If Version.NeoForgeVersion Is Nothing Then Version.NeoForgeVersion = RegexSeek(RealJson, "(?<=orgeVersion"",)[0-9\.]+") If Version.NeoForgeVersion Is Nothing Then Version.NeoForgeVersion = If(RegexSeek(RealJson, "(?<=net\.minecraftforge:fmlloader:[0-9\.]+-)[0-9\.]+"), "未知版本") Version.HasNeoForge = True End If diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index c0e083cc..0ccffe1d 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1782,10 +1782,17 @@ Retry: Loaders.Add(New LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))("获取下载地址", Sub(Task As LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))) Dim Files As New List(Of NetFile) - Files.Add(New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & "/" & DownloadInfo.FileName + If DownloadInfo.StdVersion.StartsWith("47.") Then '1.20.1 NeoForge 下载地址不同 + Files.Add(New NetFile({ + "https://bmclapi2.bangbang93.com/maven/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName + }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) + Else + Files.Add(New NetFile({ + "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) + End If Task.Output = Files End Sub) With {.ProgressWeight = 0.1, .Show = False}) '下载 @@ -2005,11 +2012,20 @@ Retry: If IsCustomFolder Then Throw New Exception("如果没有指定原版下载器,则不能指定 MC 安装文件夹") ClientDownloadLoader = McDownloadClient(NetPreDownloadBehaviour.ExitWhileExistsOrDownloading, Inherit) End If - '添加主文件 - Dim Files As New List(Of NetFile) From {New NetFile({ + Dim Files + If DownloadInfo.StdVersion.StartsWith("47.") Then '1.20.1 NeoForge 下载地址不同 + Dim FilesLegacy As New List(Of NetFile) From {New NetFile({ + "https://bmclapi2.bangbang93.com/maven/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName + }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} + Files = FilesLegacy + Else + Dim FilesLatest As New List(Of NetFile) From {New NetFile({ "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} + Files = FilesLatest + End If Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) Loaders.Add(New LoaderDownload("下载 Mod 加载器主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) @@ -2196,7 +2212,7 @@ Retry: If(Entry.ReleaseTime = "", If(ModeDebug, If(Entry.Category IsNot Nothing, "种类:" & Entry.Category, "") & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), "发布于 " & Entry.ReleaseTime & If(ModeDebug, ",种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), - .Logo = PathImage & "Blocks/NeoForge.png" + .Logo = PathImage & "Icons/NeoForged.png" } AddHandler NewItem.Click, OnClick '建立菜单 diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml index 1cf0a2d5..b16b8646 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml @@ -89,7 +89,7 @@ - + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index 326a03cb..6fd4e6e8 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -384,7 +384,7 @@ Else BtnNeoForgeClear.Visibility = Visibility.Visible ImgNeoForge.Visibility = Visibility.Visible - LabNeoForge.Text = SelectedNeoForge.Version + LabNeoForge.Text = SelectedNeoForge.StdVersion & If(SelectedNeoForge.IsBeta, "-beta", "") LabNeoForge.Foreground = ColorGray1 End If 'Fabric @@ -541,7 +541,7 @@ ElseIf SelectedForge IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Anvil.png" ElseIf SelectedNeoForge IsNot Nothing Then - Return "pack://application:,,,/images/Blocks/NeoForge.png" + Return "pack://application:,,,/images/Icons/NeoForged.png" ElseIf SelectedLiteLoader IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Egg.png" ElseIf SelectedOptiFine IsNot Nothing Then diff --git a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj index 41f804e9..663d1ee2 100644 --- a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj +++ b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj @@ -757,7 +757,6 @@ - @@ -924,6 +923,8 @@ - + + + \ No newline at end of file From f3079dd619733eb0b3b69b3c38fc09674bb43620 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 15:29:30 +0800 Subject: [PATCH 13/36] =?UTF-8?q?feat:=20NeoForge=20=E6=95=B4=E5=90=88?= =?UTF-8?q?=E5=8C=85=E5=AE=89=E8=A3=85=20fix:=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E5=AE=89=E8=A3=85=20NeoForge=20?= =?UTF-8?q?=E4=BC=9A=E5=A4=B1=E8=B4=A5=EF=BC=88DownloadInfo=20=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModModpack.vb | 23 +++++++++++++++++++ .../Pages/PageDownload/ModDownloadLib.vb | 20 ++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb index bcd878c6..b11f875c 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb @@ -183,6 +183,7 @@ Retry: '获取 Mod API 版本信息 Dim ForgeVersion As String = Nothing + Dim NeoForgeVersion As String = Nothing Dim FabricVersion As String = Nothing For Each Entry In If(Json("minecraft")("modLoaders"), {}) Dim Id As String = If(Entry("id"), "").ToString.ToLower @@ -199,6 +200,19 @@ Retry: Catch ex As Exception Log(ex, "读取整合包 Forge 版本失败:" & Id) End Try + ElseIf Id.StartsWithF("neoforge-") Then + 'NeoForge 指定 + If Id.Contains("recommended") Then + Log("[ModPack] 该整合包版本过老,已不支持进行安装!", LogLevel.Hint) + Exit Sub + End If + Try + Log("[ModPack] 整合包 NeoForge 版本:" & Id) + NeoForgeVersion = Id.Split("-")(1) + Exit For + Catch ex As Exception + Log(ex, "读取整合包 Forge 版本失败:" & Id) + End Try ElseIf Id.StartsWithF("fabric-") Then 'Fabric 指定 Try @@ -301,6 +315,7 @@ Retry: .TargetVersionFolder = $"{PathMcFolder}versions\{VersionName}\", .MinecraftName = Json("minecraft")("version").ToString, .ForgeVersion = ForgeVersion, + .NeoForgeVersion = NeoForgeVersion, .FabricVersion = FabricVersion } Dim MergeLoaders As List(Of LoaderBase) = McInstallLoader(Request, True) @@ -368,6 +383,7 @@ Retry: '获取 Mod API 版本信息 Dim MinecraftVersion As String = Nothing Dim ForgeVersion As String = Nothing + Dim NeoForgeVersion As String = Nothing Dim FabricVersion As String = Nothing For Each Entry As JProperty In If(Json("dependencies"), {}) Select Case Entry.Name.ToLower @@ -376,6 +392,9 @@ Retry: Case "forge" 'eg. 14.23.5.2859 / 1.19-41.1.0 ForgeVersion = Entry.Value.ToString Log("[ModPack] 整合包 Forge 版本:" & ForgeVersion) + Case "neoforge" 'eg. 20.6.98-beta + NeoForgeVersion = Entry.Value.ToString + Log("[ModPack] 整合包 NeoForge 版本:" & NeoForgeVersion) Case "fabric-loader" 'eg. 0.14.14 FabricVersion = Entry.Value.ToString Log("[ModPack] 整合包 Fabric 版本:" & FabricVersion) @@ -447,6 +466,7 @@ Retry: .TargetVersionFolder = $"{PathMcFolder}versions\{VersionName}\", .MinecraftName = MinecraftVersion, .ForgeVersion = ForgeVersion, + .NeoForgeVersion = NeoForgeVersion, .FabricVersion = FabricVersion } Dim MergeLoaders As List(Of LoaderBase) = McInstallLoader(Request, True) @@ -676,6 +696,8 @@ Retry: Request.MinecraftName = Component("version") Case "net.minecraftforge" Request.ForgeVersion = Component("version") + Case "net.neoforged" + Request.NeoForgeVersion = Component("version") Case "net.fabricmc.fabric-loader" Request.FabricVersion = Component("version") Case "org.quiltmc.quilt-loader" 'eg. 1.0.0 @@ -772,6 +794,7 @@ Retry: .MinecraftName = Addons("game"), .OptiFineVersion = If(Addons.ContainsKey("optifine"), Addons("optifine"), Nothing), .ForgeVersion = If(Addons.ContainsKey("forge"), Addons("forge"), Nothing), + .NeoForgeVersion = If(Addons.ContainsKey("neoforge"), Addons("neoforge"), Nothing), .FabricVersion = If(Addons.ContainsKey("fabric"), Addons("fabric"), Nothing) } Dim MergeLoaders As List(Of LoaderBase) = McInstallLoader(Request, True) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 0ccffe1d..625b4dad 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1973,11 +1973,27 @@ Retry: ''' ''' 获取下载某个 NeoForge 版本的加载器列表。 ''' - Private Function McDownloadNeoForgeLoader(Version As String, Inherit As String, Optional DownloadInfo As DlNeoForgeVersionEntry = Nothing, Optional McFolder As String = Nothing, Optional ClientDownloadLoader As LoaderCombo(Of String) = Nothing, Optional ClientFolder As String = Nothing, Optional FixLibrary As Boolean = True) As List(Of LoaderBase) + Private Function McDownloadNeoForgeLoader(Version As String, Inherit As String, Optional DownloadRawInfo As DlNeoForgeVersionEntry = Nothing, Optional McFolder As String = Nothing, Optional ClientDownloadLoader As LoaderCombo(Of String) = Nothing, Optional ClientFolder As String = Nothing, Optional FixLibrary As Boolean = True) As List(Of LoaderBase) '参数初始化 + Dim DownloadInfo As New DlNeoForgeVersionEntry McFolder = If(McFolder, PathMcFolder) - Version = DownloadInfo.StdVersion + If DownloadRawInfo Is Nothing Then '兜底,有的时候 DownloadInfo 可能是空的 + If Version.Contains("-beta") Then + DownloadInfo.Version = Version + Version = Version.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") + DownloadInfo.StdVersion = Version + DownloadInfo.IsBeta = True + Else + DownloadInfo.Version = Version + Version = Version.Replace("neoforge-", "").Replace("1.20.1-", "") + DownloadInfo.StdVersion = Version + DownloadInfo.IsBeta = False + End If + Else + DownloadInfo = DownloadRawInfo + Version = DownloadInfo.StdVersion + End If Dim IsCustomFolder As Boolean = McFolder <> PathMcFolder Dim Id As String = DownloadInfo.Version Dim InstallerAddress As String = PathTemp & "Cache\Code\NeoForgeInstall-" & Version & "_" & RandomInteger(0, 100000) From 9c64dc02099074ab72e43df75157d038fffbffaf Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 15:37:00 +0800 Subject: [PATCH 14/36] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=20Ne?= =?UTF-8?q?oForge=20=E6=89=8B=E5=8A=A8=E5=AE=89=E8=A3=85=E5=8C=85=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8A=A0=E8=BD=BD=E4=B8=8D=E5=87=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E4=BD=86=E6=98=AF=E5=A4=B1=E8=B4=A5=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 9b4a6936..6f40b267 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -820,24 +820,24 @@ ''' NeoForge 版本列表,主加载器。 ''' Public DlNeoForgeListLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeList Main", AddressOf DlNeoForgeVersionMain) - Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) + Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) 'BMCLAPI 不会返回完整的 NeoForge 版本列表,始终从官方源获取 Dim DlNeoForgeVersionOfficialLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Official", AddressOf DlNeoForgeVersionOfficialMain) - Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) + 'Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) Select Case Setup.Get("ToolDownloadVersion") Case 0 DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { - New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 30), + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 30), New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60) }, Loader.IsForceRestarting) Case 1 DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 5), - New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 35) + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 35) }, Loader.IsForceRestarting) Case Else DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60), - New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 60) + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60) }, Loader.IsForceRestarting) End Select End Sub From 9dab0b8b6bee01d8393ad52df8958c30ec7b54c8 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 15:37:54 +0800 Subject: [PATCH 15/36] =?UTF-8?q?=E6=94=B9=E4=B8=80=E8=A1=8C=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 6f40b267..cbbc6a4f 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -820,7 +820,7 @@ ''' NeoForge 版本列表,主加载器。 ''' Public DlNeoForgeListLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeList Main", AddressOf DlNeoForgeVersionMain) - Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) 'BMCLAPI 不会返回完整的 NeoForge 版本列表,始终从官方源获取 + Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) 'BMCLAPI 不会返回完整的 NeoForge 版本列表,而貌似也没有办法获取 NeoForge 支持的所有 Minecraft 版本,始终从官方源获取 Dim DlNeoForgeVersionOfficialLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Official", AddressOf DlNeoForgeVersionOfficialMain) 'Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) Select Case Setup.Get("ToolDownloadVersion") From 136803f652754e08d7ac4db7e773fc55cce6ca01 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 16 Jun 2024 16:19:28 +0800 Subject: [PATCH 16/36] =?UTF-8?q?fix:=20=E5=9B=9E=E6=BB=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=89=88=E6=9C=AC=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index cbbc6a4f..0b390916 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -820,24 +820,24 @@ ''' NeoForge 版本列表,主加载器。 ''' Public DlNeoForgeListLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeList Main", AddressOf DlNeoForgeVersionMain) - Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) 'BMCLAPI 不会返回完整的 NeoForge 版本列表,而貌似也没有办法获取 NeoForge 支持的所有 Minecraft 版本,始终从官方源获取 + Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) 'BMCLAPI 不会返回完整的 NeoForge 版本列表,而貌似也没有办法获取 NeoForge 支持的所有 Minecraft 版本 Dim DlNeoForgeVersionOfficialLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Official", AddressOf DlNeoForgeVersionOfficialMain) - 'Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) + Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) Select Case Setup.Get("ToolDownloadVersion") Case 0 DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { - New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 30), + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 30), New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60) }, Loader.IsForceRestarting) Case 1 DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 5), - New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 35) + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 35) }, Loader.IsForceRestarting) Case Else DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)) From { New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60), - New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionOfficialLoader, 60) + New KeyValuePair(Of LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)), Integer)(DlNeoForgeVersionBmclapiLoader, 60) }, Loader.IsForceRestarting) End Select End Sub From f83afdbbc1912392fbd68c4d068663448f564241 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Fri, 21 Jun 2024 16:38:42 +0800 Subject: [PATCH 17/36] =?UTF-8?q?fix:=201.20.1=20NeoForge=20=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=9C=B0=E5=9D=80=E6=8B=BC=E6=8E=A5=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E6=9C=89=E8=AF=AF=EF=BC=88=E5=A6=82=E6=9E=9C=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=BA=201.20.1=20=E5=88=99=E7=A1=AC=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E4=BB=A5=E9=81=BF=E5=85=8D=E9=97=AE=E9=A2=98=EF=BC=89=20fix:?= =?UTF-8?q?=20=E6=95=B4=E5=90=88=E5=8C=85=E5=AE=89=E8=A3=85=E6=97=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=96=87=E6=9C=AC=E6=9C=89?= =?UTF-8?q?=E8=AF=AF=20chores:=20=E4=BB=A3=E7=A0=81=E6=B8=85=E7=90=86?= =?UTF-8?q?=EF=BC=88NeoForge=20=E4=B8=8D=E9=9C=80=E8=A6=81=E9=83=A8?= =?UTF-8?q?=E5=88=86=20Forge=20=E9=80=BB=E8=BE=91=EF=BC=89=20fix(=E6=9C=AA?= =?UTF-8?q?=E5=AE=8C=E6=88=90):=20=E5=AE=98=E6=96=B9=E6=BA=90=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 12 ++---------- .../Modules/Minecraft/ModModpack.vb | 6 +----- .../Pages/PageDownload/ModDownloadLib.vb | 17 ----------------- 3 files changed, 3 insertions(+), 32 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 0b390916..b1df6c33 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -771,14 +771,6 @@ Public Value As JObject End Structure ''' - ''' 是否为新版 NeoForge。(即为 Minecraft 1.13+) - ''' - Public ReadOnly Property IsNewType As Boolean - Get - Return Version.Split(".")(0) >= 20 - End Get - End Property - ''' ''' 构建数。 ''' Public ReadOnly Property Build As Integer @@ -805,7 +797,7 @@ Public ReadOnly Property FileName As String Get If StdVersion.StartsWith("47.") Then 'NeoForge 1.20.1 的版本命名有些特殊... - Return "forge-" & Inherit & "-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" + Return "forge-" & "1.20.1" & "-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" Else Return "neoforge-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" End If @@ -859,8 +851,8 @@ End Try If Result.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & Result & ")") ResultJson = GetJson(Result) + Dim VersionArray As Array = ResultJson("versions") Dim Versions As New List(Of DlNeoForgeVersionEntry) - Dim VersionList As String = ResultJson("versions") If Not Versions.Any() Then Throw New Exception("没有可用版本") Loader.Output = Versions End Sub diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb index b11f875c..b9327b4f 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb @@ -202,16 +202,12 @@ Retry: End Try ElseIf Id.StartsWithF("neoforge-") Then 'NeoForge 指定 - If Id.Contains("recommended") Then - Log("[ModPack] 该整合包版本过老,已不支持进行安装!", LogLevel.Hint) - Exit Sub - End If Try Log("[ModPack] 整合包 NeoForge 版本:" & Id) NeoForgeVersion = Id.Split("-")(1) Exit For Catch ex As Exception - Log(ex, "读取整合包 Forge 版本失败:" & Id) + Log(ex, "读取整合包 NeoForge 版本失败:" & Id) End Try ElseIf Id.StartsWithF("fabric-") Then 'Fabric 指定 diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 625b4dad..8a1b6187 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1699,23 +1699,6 @@ Retry: #Region "NeoForge 下载" Public Sub McDownloadNeoForge(DownloadInfo As DlNeoForgeVersionEntry) - '老版本提示 - If DownloadInfo.Category = "client" Then - If MyMsgBox("该 Forge 版本过于古老,PCL 暂不支持该版本的自动安装。" & vbCrLf & - "若你仍然希望继续,PCL 将把安装程序下载到你指定的位置,但不会进行安装。", - "版本过老", "继续", "取消") = 1 Then - McDownloadNeoForgeSave(DownloadInfo) - End If - Exit Sub - End If - If DownloadInfo.Category = "universal" OrElse DownloadInfo.Inherit.StartsWithF("1.5") Then '对该版本自动安装的支持将在之后加入 - If MyMsgBox("该 Forge 版本过于古老,PCL 暂不支持该版本的自动安装。" & vbCrLf & - "若你仍然希望继续,PCL 将把安装程序下载到你指定的位置,但不会进行安装。", - "版本过老", "继续", "取消") = 1 Then - McDownloadNeoForgeSave(DownloadInfo) - End If - Exit Sub - End If '初始化参数 Dim Id As String = DownloadInfo.Inherit & "-neoforge-" & DownloadInfo.Version Dim Target As String = PathTemp & "Cache\Code\NeoForgeInstall-" & DownloadInfo.Version & "_" & GetUuid() & "." & DownloadInfo.FileSuffix From e0ae69660b94f8069bcf4882af325edd10ab658c Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Fri, 21 Jun 2024 17:00:02 +0800 Subject: [PATCH 18/36] =?UTF-8?q?chores:=20=E7=95=8C=E9=9D=A2=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=9B=B4=E6=94=B9=EF=BC=8C=E7=8E=B0=E5=9C=A8=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E7=9A=84=E6=98=AF=20NeoForge=20=E8=BF=98=E6=98=AF=20F?= =?UTF-8?q?orge=20=E6=9B=B4=E6=B8=85=E6=99=B0=E4=BA=86=20fix:=20=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=97=A9=E6=9C=9F=20Modrinth=20=E7=9A=84=20NeoForge?= =?UTF-8?q?=20=E6=95=B4=E5=90=88=E5=8C=85=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModModpack.vb | 3 ++ .../Pages/PageDownload/ModDownloadLib.vb | 44 +++++++++---------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb index b9327b4f..20ab3fcb 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb @@ -391,6 +391,9 @@ Retry: Case "neoforge" 'eg. 20.6.98-beta NeoForgeVersion = Entry.Value.ToString Log("[ModPack] 整合包 NeoForge 版本:" & NeoForgeVersion) + Case "neo-forge" 'eg. 20.6.98-beta / 有些早期的 Modrinth 整合包可能会写成这样,也检测一下 + NeoForgeVersion = Entry.Value.ToString + Log("[ModPack] 整合包 NeoForge 版本:" & NeoForgeVersion) Case "fabric-loader" 'eg. 0.14.14 FabricVersion = Entry.Value.ToString Log("[ModPack] 整合包 Fabric 版本:" & FabricVersion) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 8a1b6187..714dd93f 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1294,7 +1294,7 @@ Retry: '获取下载信息 If DownloadInfo Is Nothing Then - Loaders.Add(New LoaderTask(Of String, String)("获取 Mod 加载器详细信息", + Loaders.Add(New LoaderTask(Of String, String)("获取 Forge 详细信息", Sub(Task As LoaderTask(Of String, String)) '获取 Forge 版本列表 Dim ForgeLoader = New LoaderTask(Of String, List(Of DlForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlForgeVersionMain) @@ -1311,7 +1311,7 @@ Retry: End Sub) With {.ProgressWeight = 3}) End If '下载 Forge 主文件 - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("准备 Mod 加载器下载", + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("准备下载 Forge", Sub(Task As LoaderTask(Of String, List(Of NetFile))) '启动依赖版本的下载 If ClientDownloadLoader Is Nothing Then @@ -1325,13 +1325,13 @@ Retry: }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) - Loaders.Add(New LoaderDownload("下载 Mod 加载器主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) + Loaders.Add(New LoaderDownload("下载 Forge 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) '安装(仅在新版安装时需要原版 Jar) If Version.Before(".") >= 20 Then Log("[Download] 检测为新版 Forge:" & Version) Dim Libs As List(Of McLibToken) = Nothing - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Mod 加载器支持库文件", + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Forge 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = New List(Of NetFile) Dim Installer As ZipArchive = Nothing @@ -1374,8 +1374,8 @@ Retry: If Installer IsNot Nothing Then Installer.Dispose() End Try End Sub) With {.ProgressWeight = 2}) - Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) - Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 Mod 下载器支持库文件", + Loaders.Add(New LoaderDownload("下载 Forge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) + Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 Forge 支持库文件", Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) #Region "Forge 文件" If IsCustomFolder Then @@ -1415,7 +1415,7 @@ Retry: End SyncLock #End Region End Sub) With {.ProgressWeight = 0.1, .Show = False}) - Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 Mod 加载器(方式 A)", + Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 Forge(方式 A)", Sub(Task As LoaderTask(Of Boolean, Boolean)) Dim Installer As ZipArchive = Nothing Try @@ -1479,7 +1479,7 @@ Retry: End Sub) With {.ProgressWeight = 10}) Else Log("[Download] 检测为非新版 Forge:" & Version) - Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("安装 Mod 加载器(方式 B)", + Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("安装 Forge(方式 B)", Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) Dim Installer As ZipArchive = Nothing Try @@ -1534,8 +1534,8 @@ Retry: End Sub) With {.ProgressWeight = 1}) If FixLibrary Then If IsCustomFolder Then Throw New Exception("若需要补全支持库,就不能自定义 MC 文件夹") - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Mod 加载器支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(VersionFolder))) With {.ProgressWeight = 1, .Show = False}) - Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 11}) + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Forge 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(VersionFolder))) With {.ProgressWeight = 1, .Show = False}) + Loaders.Add(New LoaderDownload("下载 Forge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 11}) End If End If @@ -1718,7 +1718,7 @@ Retry: '已有版本检查 If File.Exists(VersionFolder & Id & ".json") Then - If MyMsgBox("版本 " & Id & " 已存在,是否重新下载?" & vbCrLf & "这会覆盖版本的 json 和 jar 文件,但不会影响版本隔离的文件。", "版本已存在", "继续", "取消") = 1 Then + If MyMsgBox("版本 " & Id & " 已存在,是否重新下载?" & vbCrLf & "这会覆盖版本的 Json 和 Jar 文件,但不会影响版本隔离的文件。", "版本已存在", "继续", "取消") = 1 Then File.Delete(VersionFolder & Id & ".jar") File.Delete(VersionFolder & Id & ".json") Else @@ -1746,7 +1746,7 @@ Retry: Public Sub McDownloadNeoForgeSave(DownloadInfo As DlNeoForgeVersionEntry) Try Dim Target As String = SelectAs("选择保存位置", DownloadInfo.FileName, "NeoForge 文件 (*." & DownloadInfo.FileSuffix & ")|*." & DownloadInfo.FileSuffix) - Dim DisplayName As String = "Forge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version + Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version If Not Target.Contains("\") Then Exit Sub '重复任务检查 @@ -1987,7 +1987,7 @@ Retry: '获取下载信息 If DownloadInfo Is Nothing Then - Loaders.Add(New LoaderTask(Of String, String)("获取 Mod 加载器详细信息", + Loaders.Add(New LoaderTask(Of String, String)("获取 NeoForge 详细信息", Sub(Task As LoaderTask(Of String, String)) '获取 NeoForge 版本列表 Dim NeoForgeLoader = New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("McDownloadNeoForgeLoader " & Inherit, AddressOf DlNeoForgeVersionMain) @@ -2004,7 +2004,7 @@ Retry: End Sub) With {.ProgressWeight = 3}) End If '下载 NeoForge 主文件 - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("准备 Mod 加载器下载", + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("准备下载 NeoForge", Sub(Task As LoaderTask(Of String, List(Of NetFile))) '启动依赖版本的下载 If ClientDownloadLoader Is Nothing Then @@ -2027,12 +2027,12 @@ Retry: End If Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) - Loaders.Add(New LoaderDownload("下载 Mod 加载器主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) + Loaders.Add(New LoaderDownload("下载 NeoForge 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) - '安装(仅在新版安装时需要原版 Jar) + '安装(需要原版 Jar) Log("[Download] 检测为新版 NeoForge:" & Version) Dim Libs As List(Of McLibToken) = Nothing - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Mod 加载器支持库文件", + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 NeoForge 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = New List(Of NetFile) Dim Installer As ZipArchive = Nothing @@ -2069,14 +2069,14 @@ Retry: Next Task.Output = McLibFixFromLibToken(Libs, PathMcFolder) Catch ex As Exception - Throw New Exception("获取新版 NeoForge 支持库列表失败", ex) + Throw New Exception("获取 NeoForge 支持库列表失败", ex) Finally '释放文件 If Installer IsNot Nothing Then Installer.Dispose() End Try End Sub) With {.ProgressWeight = 2}) - Loaders.Add(New LoaderDownload("下载 Mod 加载器支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) - Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 Mod 下载器支持库文件", + Loaders.Add(New LoaderDownload("下载 NeoForge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) + Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 NeoForge 支持库文件", Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) #Region "NeoForge 文件" If IsCustomFolder Then @@ -2116,11 +2116,11 @@ Retry: End SyncLock #End Region End Sub) With {.ProgressWeight = 0.1, .Show = False}) - Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 Mod 加载器(方式 A)", + Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 NeoForge", Sub(Task As LoaderTask(Of Boolean, Boolean)) Dim Installer As ZipArchive = Nothing Try - Log("[Download] 开始进行新版方式 NeoForge 安装:" & InstallerAddress) + Log("[Download] 开始进行 NeoForge 安装:" & InstallerAddress) '记录当前文件夹列表(在新建目标文件夹之前) Dim OldList = New DirectoryInfo(McFolder & "versions\").EnumerateDirectories. Select(Function(i) i.FullName).ToList() From 3bc34160a2d3d5b3e21f704db5ab925c12f23b41 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Fri, 21 Jun 2024 23:13:52 +0800 Subject: [PATCH 19/36] =?UTF-8?q?fix:=201.20.1=20NeoForge=20=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=A4=B1=E8=B4=A5=EF=BC=88Json=20=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 714dd93f..866027ca 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1703,7 +1703,7 @@ Retry: Dim Id As String = DownloadInfo.Inherit & "-neoforge-" & DownloadInfo.Version Dim Target As String = PathTemp & "Cache\Code\NeoForgeInstall-" & DownloadInfo.Version & "_" & GetUuid() & "." & DownloadInfo.FileSuffix Dim VersionFolder As String = PathMcFolder & "versions\" & Id & "\" - Dim DisplayName As String = "Forge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version + Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version Try '重复任务检查 @@ -2436,7 +2436,7 @@ Retry: '若要下载 NeoForge,则需要在下面两项中完成至少一项 ''' - ''' 欲下载的 NeoForge 版本名。接受例如 36.1.4 / 14.23.5.2859 / 1.19-41.1.0 的输入。 + ''' 欲下载的 NeoForge 版本名。 ''' Public NeoForgeVersion As String = Nothing ''' @@ -2583,7 +2583,7 @@ Retry: If Request.ForgeVersion IsNot Nothing Then ForgeFolder = TempMcFolder & "versions\" & Request.MinecraftName & "-forge-" & Request.ForgeVersion Dim NeoForgeFolder As String = Nothing If Request.NeoForgeEntry IsNot Nothing Then Request.NeoForgeVersion = If(Request.NeoForgeVersion, Request.NeoForgeEntry.Version) - If Request.NeoForgeVersion IsNot Nothing Then NeoForgeFolder = TempMcFolder & "versions\" & Request.NeoForgeVersion + If Request.NeoForgeVersion IsNot Nothing Then NeoForgeFolder = TempMcFolder & "versions\" & If(Request.NeoForgeVersion.StartsWithF("1.20.1"), "1.20.1-forge-", "") & Request.NeoForgeVersion.Replace("1.20.1-", "") Dim FabricFolder As String = Nothing If Request.FabricVersion IsNot Nothing Then FabricFolder = TempMcFolder & "versions\fabric-loader-" & Request.FabricVersion & "-" & Request.MinecraftName Dim LiteLoaderFolder As String = Nothing From 7d50ed1ca6aae2462836fac022dc3c68a1aa381f Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sat, 22 Jun 2024 00:23:18 +0800 Subject: [PATCH 20/36] =?UTF-8?q?fix:=201.20.1=20NeoForge=20=E8=BF=91?= =?UTF-8?q?=E6=9C=9F=E7=89=88=E6=9C=AC=E6=97=A0=E6=B3=95=E5=AE=89=E8=A3=85?= =?UTF-8?q?=EF=BC=88Json=20=E8=B7=AF=E5=BE=84=E9=94=99=E8=AF=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 866027ca..6d5fa435 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2583,7 +2583,7 @@ Retry: If Request.ForgeVersion IsNot Nothing Then ForgeFolder = TempMcFolder & "versions\" & Request.MinecraftName & "-forge-" & Request.ForgeVersion Dim NeoForgeFolder As String = Nothing If Request.NeoForgeEntry IsNot Nothing Then Request.NeoForgeVersion = If(Request.NeoForgeVersion, Request.NeoForgeEntry.Version) - If Request.NeoForgeVersion IsNot Nothing Then NeoForgeFolder = TempMcFolder & "versions\" & If(Request.NeoForgeVersion.StartsWithF("1.20.1"), "1.20.1-forge-", "") & Request.NeoForgeVersion.Replace("1.20.1-", "") + If Request.NeoForgeVersion IsNot Nothing Then NeoForgeFolder = TempMcFolder & "versions\" & If(Request.NeoForgeVersion.StartsWithF("1.20.1") OrElse Request.NeoForgeVersion.StartsWithF("47."), "1.20.1-forge-", "") & Request.NeoForgeVersion.Replace("1.20.1-", "") Dim FabricFolder As String = Nothing If Request.FabricVersion IsNot Nothing Then FabricFolder = TempMcFolder & "versions\fabric-loader-" & Request.FabricVersion & "-" & Request.MinecraftName Dim LiteLoaderFolder As String = Nothing @@ -2601,6 +2601,7 @@ Retry: If OptiFineFolder IsNot Nothing Then Log("[Download] OptiFine 缓存:" & OptiFineFolder) If ForgeFolder IsNot Nothing Then Log("[Download] Forge 缓存:" & ForgeFolder) If NeoForgeFolder IsNot Nothing Then Log("[Download] NeoForge 缓存:" & NeoForgeFolder) + If Request.NeoForgeVersion IsNot Nothing Then Log("[Download] NeoForge 版本:" & Request.NeoForgeVersion) If FabricFolder IsNot Nothing Then Log("[Download] Fabric 缓存:" & FabricFolder) If LiteLoaderFolder IsNot Nothing Then Log("[Download] LiteLoader 缓存:" & LiteLoaderFolder) Log("[Download] 对应的原版版本:" & Request.MinecraftName) From 70a6b6a946482d0092388ab81e54bce835f5306e Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sat, 22 Jun 2024 00:23:53 +0800 Subject: [PATCH 21/36] =?UTF-8?q?chores:=20=E5=88=A0=E9=99=A4=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb | 1 - 1 file changed, 1 deletion(-) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 6d5fa435..1b892aa1 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2601,7 +2601,6 @@ Retry: If OptiFineFolder IsNot Nothing Then Log("[Download] OptiFine 缓存:" & OptiFineFolder) If ForgeFolder IsNot Nothing Then Log("[Download] Forge 缓存:" & ForgeFolder) If NeoForgeFolder IsNot Nothing Then Log("[Download] NeoForge 缓存:" & NeoForgeFolder) - If Request.NeoForgeVersion IsNot Nothing Then Log("[Download] NeoForge 版本:" & Request.NeoForgeVersion) If FabricFolder IsNot Nothing Then Log("[Download] Fabric 缓存:" & FabricFolder) If LiteLoaderFolder IsNot Nothing Then Log("[Download] LiteLoader 缓存:" & LiteLoaderFolder) Log("[Download] 对应的原版版本:" & Request.MinecraftName) From 61ac6270cb2a167d10f23b490b536592e1a13c0b Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sat, 22 Jun 2024 08:46:10 +0800 Subject: [PATCH 22/36] =?UTF-8?q?fix:=201.20.1=20NeoForge=20=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=AE=89=E8=A3=85=EF=BC=88Json=20=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E9=94=99=E8=AF=AF=EF=BC=89=20fix:=20NeoForge?= =?UTF-8?q?=20=E7=89=88=E6=9C=AC=E5=88=86=E7=B1=BB=E9=94=99=E8=AF=AF=20fix?= =?UTF-8?q?:=20=E9=94=99=E8=AF=AF=E5=9C=B0=E6=8F=90=E7=A4=BA=20NeoForge=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=B8=8D=E5=8F=AF=E4=BD=BF=E7=94=A8=20Mod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb | 4 ++-- Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb | 5 +++-- Plain Craft Launcher 2/Pages/PageSelectRight.xaml.vb | 6 +++++- .../Pages/PageVersion/PageVersionModDisabled.xaml | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb index f1cdb964..930e47ab 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb @@ -291,7 +291,7 @@ Public Module ModMinecraft Public ReadOnly Property Modable As Boolean Get If Not IsLoaded Then Load() - Return Version.HasFabric OrElse Version.HasForge OrElse Version.HasLiteLoader OrElse + Return Version.HasFabric OrElse Version.HasForge OrElse Version.HasLiteLoader OrElse Version.HasNeoForge OrElse DisplayType = McVersionCardType.API '#223 End Get End Property @@ -923,7 +923,7 @@ ExitDataLoad: ''' Public HasNeoForge As Boolean = False ''' - ''' NeoForge 版本号,如 31.1.2、14.23.5.2847。 + ''' NeoForge 版本号,如 21.0.2-beta、47.1.79。 ''' Public NeoForgeVersion As String = "" diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 1b892aa1..7f858060 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2030,7 +2030,7 @@ Retry: Loaders.Add(New LoaderDownload("下载 NeoForge 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) '安装(需要原版 Jar) - Log("[Download] 检测为新版 NeoForge:" & Version) + Log("[Download] 检测到的 NeoForge 版本:" & Version) Dim Libs As List(Of McLibToken) = Nothing Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 NeoForge 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) @@ -2583,7 +2583,7 @@ Retry: If Request.ForgeVersion IsNot Nothing Then ForgeFolder = TempMcFolder & "versions\" & Request.MinecraftName & "-forge-" & Request.ForgeVersion Dim NeoForgeFolder As String = Nothing If Request.NeoForgeEntry IsNot Nothing Then Request.NeoForgeVersion = If(Request.NeoForgeVersion, Request.NeoForgeEntry.Version) - If Request.NeoForgeVersion IsNot Nothing Then NeoForgeFolder = TempMcFolder & "versions\" & If(Request.NeoForgeVersion.StartsWithF("1.20.1") OrElse Request.NeoForgeVersion.StartsWithF("47."), "1.20.1-forge-", "") & Request.NeoForgeVersion.Replace("1.20.1-", "") + If Request.NeoForgeVersion IsNot Nothing Then NeoForgeFolder = TempMcFolder & "versions\" & If(Request.NeoForgeVersion.StartsWithF("1.20.1") OrElse Request.NeoForgeVersion.StartsWithF("47."), "1.20.1-forge-", "") & Request.NeoForgeVersion.Replace("1.20.1-forge-", "").Replace("1.20.1-", "") Dim FabricFolder As String = Nothing If Request.FabricVersion IsNot Nothing Then FabricFolder = TempMcFolder & "versions\fabric-loader-" & Request.FabricVersion & "-" & Request.MinecraftName Dim LiteLoaderFolder As String = Nothing @@ -2601,6 +2601,7 @@ Retry: If OptiFineFolder IsNot Nothing Then Log("[Download] OptiFine 缓存:" & OptiFineFolder) If ForgeFolder IsNot Nothing Then Log("[Download] Forge 缓存:" & ForgeFolder) If NeoForgeFolder IsNot Nothing Then Log("[Download] NeoForge 缓存:" & NeoForgeFolder) + If Request.NeoForgeVersion IsNot Nothing Then Log("[Download] NeoForge 版本:" & Request.NeoForgeVersion) If FabricFolder IsNot Nothing Then Log("[Download] Fabric 缓存:" & FabricFolder) If LiteLoaderFolder IsNot Nothing Then Log("[Download] LiteLoader 缓存:" & LiteLoaderFolder) Log("[Download] 对应的原版版本:" & Request.MinecraftName) diff --git a/Plain Craft Launcher 2/Pages/PageSelectRight.xaml.vb b/Plain Craft Launcher 2/Pages/PageSelectRight.xaml.vb index 1709a4a6..afc5db45 100644 --- a/Plain Craft Launcher 2/Pages/PageSelectRight.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageSelectRight.xaml.vb @@ -38,19 +38,23 @@ CardName = "常规版本" Case McVersionCardType.API Dim IsForgeExists As Boolean = False + Dim IsNeoExists As Boolean = False Dim IsFabricExists As Boolean = False Dim IsLiteExists As Boolean = False For Each Version As McVersion In Card.Value If Version.Version.HasFabric Then IsFabricExists = True If Version.Version.HasLiteLoader Then IsLiteExists = True If Version.Version.HasForge Then IsForgeExists = True + If Version.Version.HasNeoForge Then IsNeoExists = True Next - If If(IsLiteExists, 1, 0) + If(IsForgeExists, 1, 0) + If(IsFabricExists, 1, 0) > 1 Then + If If(IsLiteExists, 1, 0) + If(IsForgeExists, 1, 0) + If(IsFabricExists, 1, 0) + If(IsNeoExists, 1, 0) > 1 Then CardName = "可安装 Mod" ElseIf IsForgeExists Then CardName = "Forge 版本" ElseIf IsLiteExists Then CardName = "LiteLoader 版本" + ElseIf IsNeoExists Then + CardName = "NeoForge 版本" Else CardName = "Fabric 版本" End If diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionModDisabled.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionModDisabled.xaml index cfbd13a0..77a6099d 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionModDisabled.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionModDisabled.xaml @@ -22,7 +22,7 @@ - + From 3f5c29264fa212b8b8f727460a0660ee36e806fd Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Wed, 26 Jun 2024 21:27:08 +0800 Subject: [PATCH 23/36] =?UTF-8?q?feat(neoforge):=20NeoForge=20=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E6=BA=90=E7=89=88=E6=9C=AC=E5=88=97=E8=A1=A8=20feat(n?= =?UTF-8?q?eoforge):=20NeoForge=20Minecraft=20=E7=89=88=E6=9C=AC=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=88=E5=AE=98=E6=96=B9=E6=BA=90=20Only=EF=BC=89?= =?UTF-8?q?=20fix:=20NeoForge=20=E6=89=8B=E5=8A=A8=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=8A=A0=E8=BD=BD=EF=BC=88?= =?UTF-8?q?=E5=8F=AA=E4=BF=AE=E4=BA=86=E4=B8=80=E5=8D=8A=EF=BC=89=20ui:=20?= =?UTF-8?q?=E5=9C=A8=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85=E7=9A=84=20NeoFor?= =?UTF-8?q?ge=20=E5=8D=A1=E7=89=87=E4=B8=AD=E6=98=BE=E7=A4=BA=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=A8=B3=E5=AE=9A=E7=89=88=E5=92=8C=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=20chores:=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 168 ++++++++++++++++-- .../Pages/PageDownload/ModDownloadLib.vb | 22 ++- .../PageDownload/PageDownloadNeoForge.xaml | 7 +- .../PageDownload/PageDownloadNeoForge.xaml.vb | 37 +++- 4 files changed, 208 insertions(+), 26 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index b1df6c33..d5cfe708 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -721,6 +721,108 @@ #End Region +#Region "DlNeoForgeList | NeoForge Minecraft 版本列表" + + Public Structure DlNeoForgeListResult + ''' + ''' 数据来源名称,如“Official”,“BMCLAPI”。 + ''' + Public SourceName As String + ''' + ''' 是否为官方的实时数据。 + ''' + Public IsOfficial As Boolean + ''' + ''' 获取到的数据。 + ''' + Public Value As List(Of String) + End Structure + + ''' + ''' NeoForge 版本列表,主加载器。 + ''' + Public DlNeoForgeListLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Main", AddressOf DlNeoForgeListMain) + Private Sub DlNeoForgeListMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult)) + Select Case Setup.Get("ToolDownloadVersion") + Case 0 + DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From { + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 30), + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 60) + }, Loader.IsForceRestarting) + Case 1 + DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From { + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 5), + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 35) + }, Loader.IsForceRestarting) + Case Else + DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From { + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 60), + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 60) + }, Loader.IsForceRestarting) + End Select + End Sub + + ''' + ''' NeoForge 版本列表,官方源。 + ''' + Public DlNeoForgeListOfficialLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Official", AddressOf DlNeoForgeListOfficialMain) + Private Sub DlNeoForgeListOfficialMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult)) + 'Dim Result As String = NetGetCodeByRequestRetry("https://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.2.4.html", Encoding.Default, "text/html", UseBrowserUserAgent:=True) + 'If Result.Length < 200 Then Throw New Exception("获取到的版本列表长度不足(" & Result & ")") + ''获取所有版本信息 + 'Dim Names As List(Of String) = RegexSearch(Result, "(?<=a href=""index_)[0-9.]+(_pre[0-9]?)?(?=.html)") + 'If Names.Count < 10 Then Throw New Exception("获取到的版本数量不足(" & Result & ")") + 'Loader.Output = New DlNeoForgeListResult With {.IsOfficial = True, .SourceName = "NeoForge 官方源", .Value = Names} + Dim ResultLatest As String + Dim VersionsJArray As JArray + Try + ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True) + Catch ex As Exception + If GetExceptionSummary(ex).Contains("(404)") Then + Throw New Exception("没有可用版本") + Else + Throw + End If + End Try + If ResultLatest.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & ResultLatest & ")") + VersionsJArray = GetJson(ResultLatest)("versions") + Dim Versions As List(Of String) = New List(Of String) + Versions.Add("1.20.1") + Try + For Each Token As String In VersionsJArray + Dim Version As String = Token.ToString().Replace("neoforge-", "") + Dim Inherit As String = "1." & Version.ToString().Split(".")(0) & "." & Token.ToString().Split(".")(1) + If Inherit.EndsWith(".0") Then + Inherit = Inherit.Replace(".0", "") + End If + If Versions.Contains(Inherit) Then + Continue For + Else + Versions.Add(Inherit) + End If + Next + Catch ex As Exception + MyMsgBox(ex.ToString(), "错误") + Throw New Exception("版本列表解析失败(" & VersionsJArray.ToString & ")", ex) + End Try + If Not Versions.Any() Then Throw New Exception("没有可用版本") + Loader.Output = New DlNeoForgeListResult With {.IsOfficial = True, .SourceName = "NeoForge 官方源", .Value = Versions} + End Sub + + ''' + ''' NeoForge 版本列表,BMCLAPI。 + ''' + 'Public DlNeoForgeListBmclapiLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Bmclapi", AddressOf DlNeoForgeListBmclapiMain) + 'Private Sub DlNeoForgeListBmclapiMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult)) + ' Dim Result As String = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/forge/minecraft", Encoding.Default) + ' If Result.Length < 200 Then Throw New Exception("获取到的版本列表长度不足(" & Result & ")") + ' '获取所有版本信息 + ' Dim Names As List(Of String) = RegexSearch(Result, "[0-9.]+(_pre[0-9]?)?") + ' If Names.Count < 10 Then Throw New Exception("获取到的版本数量不足(" & Result & ")") + ' Loader.Output = New DlNeoForgeListResult With {.IsOfficial = False, .SourceName = "BMCLAPI", .Value = Names} + 'End Sub +#End Region + #Region "DlNeoForgeVersion | NeoForge 版本列表" Public Class DlNeoForgeVersionEntry @@ -811,7 +913,6 @@ ''' ''' NeoForge 版本列表,主加载器。 ''' - Public DlNeoForgeListLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeList Main", AddressOf DlNeoForgeVersionMain) Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) 'BMCLAPI 不会返回完整的 NeoForge 版本列表,而貌似也没有办法获取 NeoForge 支持的所有 Minecraft 版本 Dim DlNeoForgeVersionOfficialLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Official", AddressOf DlNeoForgeVersionOfficialMain) Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) @@ -838,10 +939,15 @@ ''' NeoForge 版本列表,官方源。 ''' Public Sub DlNeoForgeVersionOfficialMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) - Dim Result As String - Dim ResultJson As JObject + Dim ResultLatest As String + Dim ResultLegacy As String + Dim ResultJson As String + Dim ResultLatestJson As JObject + Dim ResultLegacyJson As JObject + Dim VersionsJArray As JArray Try - Result = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True) + ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True) + ResultLegacy = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/forge", UseBrowserUserAgent:=True) Catch ex As Exception If GetExceptionSummary(ex).Contains("(404)") Then Throw New Exception("没有可用版本") @@ -849,10 +955,52 @@ Throw End If End Try - If Result.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & Result & ")") - ResultJson = GetJson(Result) - Dim VersionArray As Array = ResultJson("versions") + If ResultLatest.Length < 50 AndAlso ResultLegacy.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & ResultLatest & ")") + ResultLatestJson = GetJson(ResultLatest) + ResultLegacyJson = GetJson(ResultLegacy) + If Loader.Input IsNot Nothing Then + If Loader.Input Is "1.20.1" Then + VersionsJArray = ResultLegacyJson("versions") + Else + VersionsJArray = ResultLatestJson("versions") + End If + Else + VersionsJArray = ResultLatestJson("versions") + End If Dim Versions As New List(Of DlNeoForgeVersionEntry) + Try + For Each Token As String In VersionsJArray + Dim StdVersion As String + Dim IsBeta As Boolean + Dim rawVersion As String = Token.ToString() + If rawVersion.Contains("-beta") Then + StdVersion = Token.ToString().Replace("neoforge-", "").Replace("-beta", "") + IsBeta = True + Else + StdVersion = Token.ToString().Replace("neoforge-", "") + IsBeta = False + End If + Dim Inherit As String = "1." & StdVersion.ToString().Split(".")(0) & "." & StdVersion.ToString().Split(".")(1) + If Inherit.EndsWith(".0") Then + Inherit = Inherit.Replace(".0", "") + End If + Dim Entry = New DlNeoForgeVersionEntry + If Loader.Input IsNot Nothing Then + If Inherit Is Loader.Input Then + Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Versions.Add(Entry) + Continue For + Else + Continue For + End If + End If + Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Versions.Add(Entry) + Next + Catch ex As Exception + MyMsgBox(ex.ToString(), "错误") + Throw New Exception("版本列表解析失败(" & VersionsJArray.ToString & ")", ex) + End Try If Not Versions.Any() Then Throw New Exception("没有可用版本") Loader.Output = Versions End Sub @@ -865,8 +1013,7 @@ Dim Versions As New List(Of DlNeoForgeVersionEntry) Try For Each Token As JObject In Json - Dim Name As String '存储 rawVersion,貌似变化更加频繁 - Dim StdVersion As String '存储 version,相对规则 + Dim StdVersion As String Dim IsBeta As Boolean Dim rawVersion As String = Token("rawVersion") If rawVersion.Contains("-beta") Then @@ -876,9 +1023,8 @@ StdVersion = Token("version").ToString().Replace("neoforge-", "").Replace("1.20.1-", "") IsBeta = False End If - Name = rawVersion Dim Inherit As String = Token("mcversion") - Dim Entry = New DlNeoForgeVersionEntry With {.Version = Name, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Dim Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} Versions.Add(Entry) Next Catch ex As Exception diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 7f858060..f6d2f4ea 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2187,16 +2187,28 @@ Retry: #Region "NeoForge 下载菜单" Public Sub NeoForgeDownloadListItemPreload(Stack As StackPanel, Entrys As List(Of DlNeoForgeVersionEntry), OnClick As MyListItem.ClickEventHandler, IsSaveOnly As Boolean) - '获取最新版本 - Dim FreshVersion As DlNeoForgeVersionEntry = Nothing + '获取最新稳定版和测试版 + Dim FreshStableVersion As DlNeoForgeVersionEntry = Nothing + Dim FreshBetaVersion As DlNeoForgeVersionEntry = Nothing If Entrys.Any Then - FreshVersion = Entrys.Last() + For Each Entry In Entrys + If Entry.IsBeta Then + FreshBetaVersion = Entry + Else + FreshStableVersion = Entry + End If + Next Else Log("[System] 未找到可用的 NeoForge 版本", LogLevel.Debug) End If '显示各个版本 - If FreshVersion IsNot Nothing Then - Dim Fresh = NeoForgeDownloadListItem(FreshVersion, OnClick, IsSaveOnly) + If FreshStableVersion IsNot Nothing Then + Dim Fresh = NeoForgeDownloadListItem(FreshStableVersion, OnClick, IsSaveOnly) + Fresh.Info = "最新版" & If(Fresh.Info = "", "", "," & Fresh.Info) + Stack.Children.Add(Fresh) + End If + If FreshBetaVersion IsNot Nothing Then + Dim Fresh = NeoForgeDownloadListItem(FreshBetaVersion, OnClick, IsSaveOnly) Fresh.Info = "最新版" & If(Fresh.Info = "", "", "," & Fresh.Info) Stack.Children.Add(Fresh) End If diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml index aae4da7a..f72fb9d8 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml @@ -17,10 +17,11 @@ - + + + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb index fcb44919..2e6f3e8b 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb @@ -1,7 +1,7 @@ Public Class PageDownloadNeoForge Private Sub LoaderInit() Handles Me.Initialized - PageLoaderInit(Load, PanLoad, CardVersions, CardTip, DlNeoForgeListLoader, AddressOf Load_OnFinish) + PageLoaderInit(Load, PanLoad, PanMain, CardTip, DlNeoForgeListLoader, AddressOf Load_OnFinish) End Sub Private Sub Init() Handles Me.Loaded PanBack.ScrollToHome() @@ -10,21 +10,44 @@ Private Sub Load_OnFinish() '结果数据化 Try - Dim Versions As List(Of DlNeoForgeVersionEntry) = DlNeoForgeListLoader.Output - PanVersions.Children.Clear() - For Each Version In Versions - PanVersions.Children.Add(NeoForgeDownloadListItem(Version, AddressOf NeoForge_Selected, True)) + Dim Versions = Sort(DlNeoForgeListLoader.Output.Value, AddressOf VersionSortBoolean) + 'Dim Versions As List(Of DlNeoForgeVersionEntry) = DlNeoForgeListLoader.Output + PanMain.Children.Clear() + For Each Version As String In Versions + '增加卡片 + Dim NewCard As New MyCard With {.Title = Version.Replace("_p", " P"), .Margin = New Thickness(0, 0, 0, 15), .SwapType = 5} + Dim NewStack As New StackPanel With {.Margin = New Thickness(20, MyCard.SwapedHeight, 18, 0), .VerticalAlignment = VerticalAlignment.Top, .RenderTransform = New TranslateTransform(0, 0), .Tag = Version} + NewCard.Children.Add(NewStack) + NewCard.SwapControl = NewStack + NewCard.IsSwaped = True + PanMain.Children.Add(NewCard) Next - CardVersions.Title = "版本列表 (" & Versions.Count & ")" Catch ex As Exception Log(ex, "可视化 NeoForge 版本列表出错", LogLevel.Feedback) End Try End Sub + Public Sub NeoForge_StateChanged(sender As MyLoading, newState As MyLoading.MyLoadingState, oldState As MyLoading.MyLoadingState) + If newState <> MyLoading.MyLoadingState.Stop Then Exit Sub + Dim Card As MyCard = CType(sender.Parent, FrameworkElement).Parent + Dim Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry)) = sender.State + '载入列表 + Card.SwapControl.Children.Clear() + Card.SwapControl.Tag = Loader.Output + Card.SwapType = 6 + Card.StackInstall() + End Sub + Public Sub NeoForge_Click(sender As MyLoading, e As MouseButtonEventArgs) + If sender.State.LoadingState = MyLoading.MyLoadingState.Error Then + CType(sender.State, LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))).Start(IsForceRestart:=True) + End If + End Sub Private Sub NeoForge_Selected(sender As MyListItem, e As EventArgs) McDownloadNeoForgeSave(sender.Tag) End Sub - + Public Sub DownloadStart(sender As MyListItem, e As Object) + McDownloadNeoForge(sender.Tag) + End Sub Private Sub BtnWeb_Click(sender As Object, e As EventArgs) Handles BtnWeb.Click OpenWebsite("https://neoforged.net/") End Sub From 707b6eec1469c7a1b9a8844da79216dc92330ec3 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Wed, 26 Jun 2024 22:13:11 +0800 Subject: [PATCH 24/36] =?UTF-8?q?fix:=20NeoForge=20=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E7=89=88=E6=9C=AC=E5=88=97=E8=A1=A8=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=AD=A3=E5=B8=B8=E5=8A=A0=E8=BD=BD=EF=BC=88=E4=BF=AE?= =?UTF-8?q?=E5=AE=8C=E4=BA=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Controls/MyCard.vb | 13 +++++++++++++ .../Modules/Minecraft/ModDownload.vb | 6 ------ .../Pages/PageDownload/PageDownloadNeoForge.xaml.vb | 5 ++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Plain Craft Launcher 2/Controls/MyCard.vb b/Plain Craft Launcher 2/Controls/MyCard.vb index 11b76698..0cb673ff 100644 --- a/Plain Craft Launcher 2/Controls/MyCard.vb +++ b/Plain Craft Launcher 2/Controls/MyCard.vb @@ -128,6 +128,16 @@ ForgeDownloadListItemPreload(Stack, Stack.Tag, AddressOf ForgeSave_Click, True) Case 8 CompFilesCardPreload(Stack, Stack.Tag) + Case 13 + Dim LoadingPickaxe As New MyLoading With {.Text = "正在获取版本列表", .Margin = New Thickness(5)} + Dim Loader = New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Main", AddressOf DlNeoForgeVersionMain) + LoadingPickaxe.State = Loader + Loader.Start(Stack.Tag) + AddHandler LoadingPickaxe.StateChanged, AddressOf FrmDownloadNeoForge.NeoForge_StateChanged + AddHandler LoadingPickaxe.Click, AddressOf FrmDownloadNeoForge.NeoForge_Click + Stack.Children.Add(LoadingPickaxe) + Case 14 + NeoForgeDownloadListItemPreload(Stack, Stack.Tag, AddressOf NeoForgeSave_Click, True) End Select '实现控件虚拟化 For Each Data As Object In Stack.Tag @@ -171,6 +181,9 @@ Stack.Children.Add(CType(Data, HelpEntry).ToListItem) Case 12 Stack.Children.Add(FabricDownloadListItem(CType(Data, JObject), AddressOf FrmDownloadInstall.Fabric_Selected)) + Case 13 + Case 14 + Stack.Children.Add(NeoForgeDownloadListItem(Data, AddressOf NeoForgeSave_Click, True)) Case Else Log("未知的虚拟化种类:" & Type, LogLevel.Feedback) End Select diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index d5cfe708..a8656ccc 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -767,12 +767,6 @@ ''' Public DlNeoForgeListOfficialLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Official", AddressOf DlNeoForgeListOfficialMain) Private Sub DlNeoForgeListOfficialMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult)) - 'Dim Result As String = NetGetCodeByRequestRetry("https://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.2.4.html", Encoding.Default, "text/html", UseBrowserUserAgent:=True) - 'If Result.Length < 200 Then Throw New Exception("获取到的版本列表长度不足(" & Result & ")") - ''获取所有版本信息 - 'Dim Names As List(Of String) = RegexSearch(Result, "(?<=a href=""index_)[0-9.]+(_pre[0-9]?)?(?=.html)") - 'If Names.Count < 10 Then Throw New Exception("获取到的版本数量不足(" & Result & ")") - 'Loader.Output = New DlNeoForgeListResult With {.IsOfficial = True, .SourceName = "NeoForge 官方源", .Value = Names} Dim ResultLatest As String Dim VersionsJArray As JArray Try diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb index 2e6f3e8b..b0eabde8 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb @@ -11,11 +11,10 @@ '结果数据化 Try Dim Versions = Sort(DlNeoForgeListLoader.Output.Value, AddressOf VersionSortBoolean) - 'Dim Versions As List(Of DlNeoForgeVersionEntry) = DlNeoForgeListLoader.Output PanMain.Children.Clear() For Each Version As String In Versions '增加卡片 - Dim NewCard As New MyCard With {.Title = Version.Replace("_p", " P"), .Margin = New Thickness(0, 0, 0, 15), .SwapType = 5} + Dim NewCard As New MyCard With {.Title = Version.Replace("_p", " P"), .Margin = New Thickness(0, 0, 0, 15), .SwapType = 13} Dim NewStack As New StackPanel With {.Margin = New Thickness(20, MyCard.SwapedHeight, 18, 0), .VerticalAlignment = VerticalAlignment.Top, .RenderTransform = New TranslateTransform(0, 0), .Tag = Version} NewCard.Children.Add(NewStack) NewCard.SwapControl = NewStack @@ -34,7 +33,7 @@ '载入列表 Card.SwapControl.Children.Clear() Card.SwapControl.Tag = Loader.Output - Card.SwapType = 6 + Card.SwapType = 14 Card.StackInstall() End Sub Public Sub NeoForge_Click(sender As MyLoading, e As MouseButtonEventArgs) From 2cfa9b2015be952edb2898dc702ec05c331a3110 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Wed, 26 Jun 2024 23:43:37 +0800 Subject: [PATCH 25/36] =?UTF-8?q?feat:=20NeoForge=20BMCLAPI=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96=20fix:=20?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E7=9A=84=E6=8E=92=E5=BA=8F=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=BC=9A=E5=AF=BC=E8=87=B4=20IDE=20=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 51 +++++++++++++------ .../Pages/PageDownload/ModDownloadLib.vb | 4 +- .../PageDownload/PageDownloadInstall.xaml.vb | 5 +- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index a8656ccc..45006dca 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -746,18 +746,18 @@ Select Case Setup.Get("ToolDownloadVersion") Case 0 DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From { - New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 30), + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListBmclapiLoader, 30), New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 60) }, Loader.IsForceRestarting) Case 1 DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From { New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 5), - New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 35) + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListBmclapiLoader, 35) }, Loader.IsForceRestarting) Case Else DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)) From { New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 60), - New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListOfficialLoader, 60) + New KeyValuePair(Of LoaderTask(Of Integer, DlNeoForgeListResult), Integer)(DlNeoForgeListBmclapiLoader, 60) }, Loader.IsForceRestarting) End Select End Sub @@ -806,15 +806,31 @@ ''' ''' NeoForge 版本列表,BMCLAPI。 ''' - 'Public DlNeoForgeListBmclapiLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Bmclapi", AddressOf DlNeoForgeListBmclapiMain) - 'Private Sub DlNeoForgeListBmclapiMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult)) - ' Dim Result As String = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/forge/minecraft", Encoding.Default) - ' If Result.Length < 200 Then Throw New Exception("获取到的版本列表长度不足(" & Result & ")") - ' '获取所有版本信息 - ' Dim Names As List(Of String) = RegexSearch(Result, "[0-9.]+(_pre[0-9]?)?") - ' If Names.Count < 10 Then Throw New Exception("获取到的版本数量不足(" & Result & ")") - ' Loader.Output = New DlNeoForgeListResult With {.IsOfficial = False, .SourceName = "BMCLAPI", .Value = Names} - 'End Sub + Public DlNeoForgeListBmclapiLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Bmclapi", AddressOf DlNeoForgeListBmclapiMain) + Private Sub DlNeoForgeListBmclapiMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult)) + Dim Versions As List(Of String) = New List(Of String) + Dim ClientVersions As JArray = DlClientListLoader.Output.Value("versions") 'BMCLAPI 不能返回所有 NeoForge 版本,获取 MC 版本列表进行遍历 + Dim ClientReleases As List(Of String) = New List(Of String) + + For Each Client In ClientVersions '排除快照版或远古版等特殊版本 + Dim ClientVersionString = Client("id").ToString() + If Not (ClientVersionString.ContainsF("a") OrElse ClientVersionString.ContainsF("b") OrElse ClientVersionString.ContainsF("c") OrElse ClientVersionString.ContainsF("w") OrElse ClientVersionString.ContainsF("pre") OrElse ClientVersionString.ContainsF("Pre") OrElse ClientVersionString.ContainsF("rc") OrElse ClientVersionString.ContainsF("b") OrElse ClientVersionString.ContainsF("rd") OrElse ClientVersionString.ContainsF("inf")) Then + ClientReleases.Add(ClientVersionString) + End If + Next + + For Each Release In ClientReleases + If Int(Release.Split(".")(1)) > 19 Then '如果游戏版本低于 1.20 就不进行请求 + Dim Json As String = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/neoforge/list/" & Release) + If Json IsNot "[]" Then '如果这个版本不支持 NeoForge,BMCLAPI 会直接返回一个空的 Json 序列,这里直接用字符串处理了 + Versions.Add(Release) + Versions.Remove("1.20") + End If + End If + Next + + Loader.Output = New DlNeoForgeListResult With {.IsOfficial = False, .SourceName = "BMCLAPI", .Value = Versions} + End Sub #End Region #Region "DlNeoForgeVersion | NeoForge 版本列表" @@ -907,7 +923,7 @@ ''' ''' NeoForge 版本列表,主加载器。 ''' - Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) 'BMCLAPI 不会返回完整的 NeoForge 版本列表,而貌似也没有办法获取 NeoForge 支持的所有 Minecraft 版本 + Public Sub DlNeoForgeVersionMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) Dim DlNeoForgeVersionOfficialLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Official", AddressOf DlNeoForgeVersionOfficialMain) Dim DlNeoForgeVersionBmclapiLoader As New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion Bmclapi", AddressOf DlNeoForgeVersionBmclapiMain) Select Case Setup.Get("ToolDownloadVersion") @@ -935,7 +951,6 @@ Public Sub DlNeoForgeVersionOfficialMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) Dim ResultLatest As String Dim ResultLegacy As String - Dim ResultJson As String Dim ResultLatestJson As JObject Dim ResultLegacyJson As JObject Dim VersionsJArray As JArray @@ -996,7 +1011,9 @@ Throw New Exception("版本列表解析失败(" & VersionsJArray.ToString & ")", ex) End Try If Not Versions.Any() Then Throw New Exception("没有可用版本") - Loader.Output = Versions + Dim VersionsArray = Versions.ToList() + VersionsArray.Reverse() + Loader.Output = VersionsArray End Sub ''' @@ -1026,7 +1043,9 @@ Throw New Exception("版本列表解析失败(" & Json.ToString & ")", ex) End Try If Not Versions.Any() Then Throw New Exception("没有可用版本") - Loader.Output = Versions + Dim VersionsArray = Versions.ToList() + VersionsArray.Reverse() + Loader.Output = VersionsArray End Sub #End Region diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index f6d2f4ea..bd9674ff 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2191,7 +2191,9 @@ Retry: Dim FreshStableVersion As DlNeoForgeVersionEntry = Nothing Dim FreshBetaVersion As DlNeoForgeVersionEntry = Nothing If Entrys.Any Then - For Each Entry In Entrys + Dim VersionsArray = Entrys.ToList() + VersionsArray.Reverse() + For Each Entry In VersionsArray If Entry.IsBeta Then FreshBetaVersion = Entry Else diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index 6fd4e6e8..a58d4cbf 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -974,11 +974,8 @@ If Not Loader.Output.Any() Then Exit Sub PanNeoForge.Children.Clear() - Dim VersionsArray As Array = Versions.ToArray() - VersionsArray.Reverse(VersionsArray) - 'Versions = Sort(Versions, Function(a, b) New Version(a.Version) > New Version(b.Version)).ToList NeoForgeDownloadListItemPreload(PanNeoForge, Versions, AddressOf NeoForge_Selected, False) - For Each Version In VersionsArray + For Each Version In Versions PanNeoForge.Children.Add(NeoForgeDownloadListItem(Version, AddressOf NeoForge_Selected, False)) Next Catch ex As Exception From ee10caa84e3ce3dacc9546d57330e54bb07a1335 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Wed, 26 Jun 2024 23:55:58 +0800 Subject: [PATCH 26/36] =?UTF-8?q?fix:=20NeoForge=20=E5=AE=98=E6=96=B9?= =?UTF-8?q?=E6=BA=90=E4=B8=8D=E5=8F=AF=E7=94=A8=20chores:=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 45006dca..257551ed 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -981,21 +981,19 @@ For Each Token As String In VersionsJArray Dim StdVersion As String Dim IsBeta As Boolean - Dim rawVersion As String = Token.ToString() + Dim rawVersion As String = Token If rawVersion.Contains("-beta") Then - StdVersion = Token.ToString().Replace("neoforge-", "").Replace("-beta", "") + StdVersion = Token.Replace("neoforge-", "").Replace("-beta", "") IsBeta = True Else - StdVersion = Token.ToString().Replace("neoforge-", "") + StdVersion = Token.Replace("neoforge-", "") IsBeta = False End If - Dim Inherit As String = "1." & StdVersion.ToString().Split(".")(0) & "." & StdVersion.ToString().Split(".")(1) - If Inherit.EndsWith(".0") Then - Inherit = Inherit.Replace(".0", "") - End If + Dim Inherit As String = "1." & StdVersion.Split(".")(0) & "." & StdVersion.Split(".")(1) + Inherit = Inherit.Replace(".0", "") Dim Entry = New DlNeoForgeVersionEntry If Loader.Input IsNot Nothing Then - If Inherit Is Loader.Input Then + If Inherit Is Loader.Input.ToString() Then Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} Versions.Add(Entry) Continue For From 6efaa0961658575e1b639aa17a73c67f87798d4f Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Thu, 27 Jun 2024 08:04:09 +0800 Subject: [PATCH 27/36] =?UTF-8?q?fix:=20=E5=AE=98=E6=96=B9=E6=BA=90?= =?UTF-8?q?=E6=80=BB=E6=98=AF=20Fallback=20=E5=88=B0=20BMCLAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 257551ed..6a8e4b2f 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -993,11 +993,15 @@ Inherit = Inherit.Replace(".0", "") Dim Entry = New DlNeoForgeVersionEntry If Loader.Input IsNot Nothing Then - If Inherit Is Loader.Input.ToString() Then + If Inherit.Contains(Loader.Input.ToString().Replace("1.", "")) Then Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Hint(Entry.StdVersion) + Log(Entry.StdVersion) Versions.Add(Entry) Continue For Else + Hint("匹配失败: " & Inherit & " 但是请求的版本是 " & Loader.Input.ToString()) + Log("匹配失败: " & Inherit & " 但是请求的版本是 " & Loader.Input.ToString()) Continue For End If End If From ac6ed8d9865fb2047812ae033afbbe981305f142 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Thu, 27 Jun 2024 08:05:06 +0800 Subject: [PATCH 28/36] chores: Clean up --- Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 6a8e4b2f..3d4c5d4e 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -995,13 +995,9 @@ If Loader.Input IsNot Nothing Then If Inherit.Contains(Loader.Input.ToString().Replace("1.", "")) Then Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} - Hint(Entry.StdVersion) - Log(Entry.StdVersion) Versions.Add(Entry) Continue For Else - Hint("匹配失败: " & Inherit & " 但是请求的版本是 " & Loader.Input.ToString()) - Log("匹配失败: " & Inherit & " 但是请求的版本是 " & Loader.Input.ToString()) Continue For End If End If From 1b53489cf3a37cc987ab2d6af03d2116310cebf4 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Thu, 27 Jun 2024 14:09:31 +0800 Subject: [PATCH 29/36] =?UTF-8?q?fix:=20BMCLAPI=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=9A=84=20Neo=20=E5=88=97=E8=A1=A8=E6=97=B6?= =?UTF-8?q?=E4=BC=9A=E6=84=8F=E5=A4=96=E7=9A=84=E5=8C=85=E5=90=AB=201.20?= =?UTF-8?q?=20fix:=20NeoForge=201.20.1=20=E5=AE=98=E6=96=B9=E6=BA=90?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=88=97=E8=A1=A8=E4=B8=8D=E8=83=BD=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 25 +++++++++++-------- .../Pages/PageDownload/ModDownloadLib.vb | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 3d4c5d4e..8f238e9b 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -822,9 +822,8 @@ For Each Release In ClientReleases If Int(Release.Split(".")(1)) > 19 Then '如果游戏版本低于 1.20 就不进行请求 Dim Json As String = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/neoforge/list/" & Release) - If Json IsNot "[]" Then '如果这个版本不支持 NeoForge,BMCLAPI 会直接返回一个空的 Json 序列,这里直接用字符串处理了 + If Not Json.Contains("[]") Then '如果这个版本不支持 NeoForge,BMCLAPI 会直接返回一个空的 Json 序列,这里直接用字符串处理了 Versions.Add(Release) - Versions.Remove("1.20") End If End If Next @@ -954,6 +953,7 @@ Dim ResultLatestJson As JObject Dim ResultLegacyJson As JObject Dim VersionsJArray As JArray + Dim IsLegacyNeo As Boolean = False Try ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True) ResultLegacy = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/forge", UseBrowserUserAgent:=True) @@ -968,8 +968,9 @@ ResultLatestJson = GetJson(ResultLatest) ResultLegacyJson = GetJson(ResultLegacy) If Loader.Input IsNot Nothing Then - If Loader.Input Is "1.20.1" Then + If Loader.Input.ToString().Contains("1.20.1") Then VersionsJArray = ResultLegacyJson("versions") + IsLegacyNeo = True Else VersionsJArray = ResultLatestJson("versions") End If @@ -983,26 +984,30 @@ Dim IsBeta As Boolean Dim rawVersion As String = Token If rawVersion.Contains("-beta") Then - StdVersion = Token.Replace("neoforge-", "").Replace("-beta", "") + StdVersion = Token.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") IsBeta = True Else - StdVersion = Token.Replace("neoforge-", "") + StdVersion = Token.Replace("neoforge-", "").Replace("1.20.1-", "") IsBeta = False End If Dim Inherit As String = "1." & StdVersion.Split(".")(0) & "." & StdVersion.Split(".")(1) Inherit = Inherit.Replace(".0", "") + If IsLegacyNeo Then Inherit = "1.20.1" Dim Entry = New DlNeoForgeVersionEntry If Loader.Input IsNot Nothing Then - If Inherit.Contains(Loader.Input.ToString().Replace("1.", "")) Then + If IsLegacyNeo Then Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} Versions.Add(Entry) - Continue For Else - Continue For + If Inherit.Contains(Loader.Input.ToString().Replace("1.", "")) Then + Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Versions.Add(Entry) + End If End If + Else + Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Versions.Add(Entry) End If - Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} - Versions.Add(Entry) Next Catch ex As Exception MyMsgBox(ex.ToString(), "错误") diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index bd9674ff..ee623b29 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -2197,6 +2197,7 @@ Retry: If Entry.IsBeta Then FreshBetaVersion = Entry Else + If Entry.StdVersion.Contains("47.1.82") Then Continue For FreshStableVersion = Entry End If Next From b61081fad9152275ceb2e96c8b30ec5825d8d071 Mon Sep 17 00:00:00 2001 From: youzi-2333 Date: Thu, 27 Jun 2024 18:30:47 +0800 Subject: [PATCH 30/36] =?UTF-8?q?:ok=5Fhand:=20=E4=BF=AE=E6=94=B9=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=BE=99=E7=8C=AB=E7=9A=84=E5=AE=A1=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Icons/{NeoForged.png => NeoForge.png} | Bin .../Modules/Minecraft/ModDownload.vb | 62 ++++++++---------- .../Modules/Minecraft/ModMinecraft.vb | 3 +- .../Pages/PageDownload/ModDownloadLib.vb | 54 +++++++-------- .../PageDownload/PageDownloadInstall.xaml | 2 +- .../PageDownload/PageDownloadInstall.xaml.vb | 8 +-- .../Pages/PageVersion/PageVersionOverall.xaml | 2 +- Plain Craft Launcher 2/Resources/Custom.xaml | 2 +- 8 files changed, 63 insertions(+), 70 deletions(-) rename Plain Craft Launcher 2/Images/Icons/{NeoForged.png => NeoForge.png} (100%) diff --git a/Plain Craft Launcher 2/Images/Icons/NeoForged.png b/Plain Craft Launcher 2/Images/Icons/NeoForge.png similarity index 100% rename from Plain Craft Launcher 2/Images/Icons/NeoForged.png rename to Plain Craft Launcher 2/Images/Icons/NeoForge.png diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 8f238e9b..1d5f353d 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -770,7 +770,7 @@ Dim ResultLatest As String Dim VersionsJArray As JArray Try - ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True) + ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True, IsJson:=True) Catch ex As Exception If GetExceptionSummary(ex).Contains("(404)") Then Throw New Exception("没有可用版本") @@ -780,24 +780,19 @@ End Try If ResultLatest.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & ResultLatest & ")") VersionsJArray = GetJson(ResultLatest)("versions") - Dim Versions As List(Of String) = New List(Of String) + Dim Versions As New List(Of String) Versions.Add("1.20.1") Try For Each Token As String In VersionsJArray - Dim Version As String = Token.ToString().Replace("neoforge-", "") - Dim Inherit As String = "1." & Version.ToString().Split(".")(0) & "." & Token.ToString().Split(".")(1) - If Inherit.EndsWith(".0") Then - Inherit = Inherit.Replace(".0", "") - End If - If Versions.Contains(Inherit) Then - Continue For - Else - Versions.Add(Inherit) - End If + Dim Version As String = Token.Replace("neoforge-", "") + Dim Inherit As String = $"1.{Version.ToString().Split(".")(0)}.{Token.ToString().Split(".")(1)}" + If Inherit.EndsWith(".0") Then Inherit = Inherit.Replace(".0", "") + Versions.Add(Inherit) Next + Versions.Distinct() '去重 Catch ex As Exception - MyMsgBox(ex.ToString(), "错误") - Throw New Exception("版本列表解析失败(" & VersionsJArray.ToString & ")", ex) + Log(ex, LogLevel.Feedback) + 'Throw New Exception("版本列表解析失败(" & VersionsJArray.ToString & ")", ex) End Try If Not Versions.Any() Then Throw New Exception("没有可用版本") Loader.Output = New DlNeoForgeListResult With {.IsOfficial = True, .SourceName = "NeoForge 官方源", .Value = Versions} @@ -808,11 +803,11 @@ ''' Public DlNeoForgeListBmclapiLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Bmclapi", AddressOf DlNeoForgeListBmclapiMain) Private Sub DlNeoForgeListBmclapiMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult)) - Dim Versions As List(Of String) = New List(Of String) - Dim ClientVersions As JArray = DlClientListLoader.Output.Value("versions") 'BMCLAPI 不能返回所有 NeoForge 版本,获取 MC 版本列表进行遍历 - Dim ClientReleases As List(Of String) = New List(Of String) + Dim Versions As New List(Of String) + Dim ClientVersions As JArray = DlClientListLoader.Output.Value("versions") 'BMCLAPI 不能返回所有 NeoForge 版本,获取 MC 版本列表进行遍历 + Dim ClientReleases As New List(Of String) - For Each Client In ClientVersions '排除快照版或远古版等特殊版本 + For Each Client In ClientVersions '排除快照版或远古版等特殊版本 Dim ClientVersionString = Client("id").ToString() If Not (ClientVersionString.ContainsF("a") OrElse ClientVersionString.ContainsF("b") OrElse ClientVersionString.ContainsF("c") OrElse ClientVersionString.ContainsF("w") OrElse ClientVersionString.ContainsF("pre") OrElse ClientVersionString.ContainsF("Pre") OrElse ClientVersionString.ContainsF("rc") OrElse ClientVersionString.ContainsF("b") OrElse ClientVersionString.ContainsF("rd") OrElse ClientVersionString.ContainsF("inf")) Then ClientReleases.Add(ClientVersionString) @@ -820,11 +815,10 @@ Next For Each Release In ClientReleases - If Int(Release.Split(".")(1)) > 19 Then '如果游戏版本低于 1.20 就不进行请求 - Dim Json As String = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/neoforge/list/" & Release) - If Not Json.Contains("[]") Then '如果这个版本不支持 NeoForge,BMCLAPI 会直接返回一个空的 Json 序列,这里直接用字符串处理了 - Versions.Add(Release) - End If + If Int(Release.Split(".")(1)) <= 19 Then Continue For '如果游戏版本低于 1.20 就不进行请求 + Dim Json As String = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/neoforge/list/" & Release) + If Not Json.Contains("[]") Then '如果这个版本不支持 NeoForge,BMCLAPI 会直接返回一个空的 Json 序列,这里直接用字符串处理了 + Versions.Add(Release) End If Next @@ -838,7 +832,7 @@ ''' ''' 完整的版本名,如 “neoforge-20.4.30-beta”。 ''' - Public Version As String + Public VersionName As String ''' ''' 对应的 Minecraft 版本,如“1.12.2”。 ''' @@ -866,7 +860,7 @@ ''' ''' 标准的版本号,如 “20.4.30”。 ''' - Public StdVersion As String + Public VersionCode As String Public Structure DlNeoForgeListResult ''' ''' 数据来源名称,如“Official”,“BMCLAPI”。 @@ -886,7 +880,7 @@ ''' Public ReadOnly Property Build As Integer Get - Dim Version = Me.Version.Split(".") + Dim Version = Me.VersionName.Split(".") If Version(0) < 15 Then Return Version(Version.Count - 1) Else @@ -899,7 +893,7 @@ ''' Public ReadOnly Property FileVersion As String Get - Return Version & If(Branch Is Nothing, "", "-" & Branch) + Return VersionName & If(Branch Is Nothing, "", "-" & Branch) End Get End Property ''' @@ -907,10 +901,10 @@ ''' Public ReadOnly Property FileName As String Get - If StdVersion.StartsWith("47.") Then 'NeoForge 1.20.1 的版本命名有些特殊... - Return "forge-" & "1.20.1" & "-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" + If VersionCode.StartsWith("47.") Then 'NeoForge 1.20.1 的版本命名有些特殊... + Return "forge-" & "1.20.1" & "-" & VersionCode & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" Else - Return "neoforge-" & StdVersion & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" + Return "neoforge-" & VersionCode & If(IsBeta, "-beta", "") & "-" & "installer" & "." & "jar" End If End Get End Property @@ -996,16 +990,16 @@ Dim Entry = New DlNeoForgeVersionEntry If Loader.Input IsNot Nothing Then If IsLegacyNeo Then - Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion} Versions.Add(Entry) Else If Inherit.Contains(Loader.Input.ToString().Replace("1.", "")) Then - Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion} Versions.Add(Entry) End If End If Else - Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion} Versions.Add(Entry) End If Next @@ -1038,7 +1032,7 @@ IsBeta = False End If Dim Inherit As String = Token("mcversion") - Dim Entry = New DlNeoForgeVersionEntry With {.Version = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .StdVersion = StdVersion} + Dim Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion} Versions.Add(Entry) Next Catch ex As Exception diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb index 930e47ab..620134d0 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb @@ -1,5 +1,4 @@ Imports System.IO.Compression -Imports MS.Internal Public Module ModMinecraft @@ -762,7 +761,7 @@ ExitDataLoad: Case McVersionState.Forge Logo = PathImage & "Blocks/Anvil.png" Case McVersionState.NeoForge - Logo = PathImage & "Icons/NeoForged.png" + Logo = PathImage & "Icons/NeoForge.png" Case McVersionState.Fabric Logo = PathImage & "Blocks/Fabric.png" Case McVersionState.OptiFine diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index ee623b29..bbe980ab 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1700,10 +1700,10 @@ Retry: Public Sub McDownloadNeoForge(DownloadInfo As DlNeoForgeVersionEntry) '初始化参数 - Dim Id As String = DownloadInfo.Inherit & "-neoforge-" & DownloadInfo.Version - Dim Target As String = PathTemp & "Cache\Code\NeoForgeInstall-" & DownloadInfo.Version & "_" & GetUuid() & "." & DownloadInfo.FileSuffix + Dim Id As String = DownloadInfo.Inherit & "-neoforge-" & DownloadInfo.VersionName + Dim Target As String = PathTemp & "Cache\Code\NeoForgeInstall-" & DownloadInfo.VersionName & "_" & GetUuid() & "." & DownloadInfo.FileSuffix Dim VersionFolder As String = PathMcFolder & "versions\" & Id & "\" - Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version + Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.VersionName Try '重复任务检查 @@ -1727,7 +1727,7 @@ Retry: End If '启动 - Dim Loader As New LoaderCombo(Of String)(DisplayName & " 下载", McDownloadNeoForgeLoader(DownloadInfo.Version, DownloadInfo.Inherit, DownloadInfo)) With {.OnStateChanged = AddressOf McInstallState} + Dim Loader As New LoaderCombo(Of String)(DisplayName & " 下载", McDownloadNeoForgeLoader(DownloadInfo.VersionName, DownloadInfo.Inherit, DownloadInfo)) With {.OnStateChanged = AddressOf McInstallState} Loader.Start(VersionFolder) LoaderTaskbarAdd(Loader) FrmMain.BtnExtraDownload.ShowRefresh() @@ -1746,7 +1746,7 @@ Retry: Public Sub McDownloadNeoForgeSave(DownloadInfo As DlNeoForgeVersionEntry) Try Dim Target As String = SelectAs("选择保存位置", DownloadInfo.FileName, "NeoForge 文件 (*." & DownloadInfo.FileSuffix & ")|*." & DownloadInfo.FileSuffix) - Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version + Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.VersionName If Not Target.Contains("\") Then Exit Sub '重复任务检查 @@ -1765,15 +1765,15 @@ Retry: Loaders.Add(New LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))("获取下载地址", Sub(Task As LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))) Dim Files As New List(Of NetFile) - If DownloadInfo.StdVersion.StartsWith("47.") Then '1.20.1 NeoForge 下载地址不同 + If DownloadInfo.VersionCode.StartsWith("47.") Then '1.20.1 NeoForge 下载地址不同 Files.Add(New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName + "https://bmclapi2.bangbang93.com/maven/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) Else Files.Add(New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName + "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) End If Task.Output = Files @@ -1963,22 +1963,22 @@ Retry: McFolder = If(McFolder, PathMcFolder) If DownloadRawInfo Is Nothing Then '兜底,有的时候 DownloadInfo 可能是空的 If Version.Contains("-beta") Then - DownloadInfo.Version = Version + DownloadInfo.VersionName = Version Version = Version.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") - DownloadInfo.StdVersion = Version + DownloadInfo.VersionCode = Version DownloadInfo.IsBeta = True Else - DownloadInfo.Version = Version + DownloadInfo.VersionName = Version Version = Version.Replace("neoforge-", "").Replace("1.20.1-", "") - DownloadInfo.StdVersion = Version + DownloadInfo.VersionCode = Version DownloadInfo.IsBeta = False End If Else DownloadInfo = DownloadRawInfo - Version = DownloadInfo.StdVersion + Version = DownloadInfo.VersionCode End If Dim IsCustomFolder As Boolean = McFolder <> PathMcFolder - Dim Id As String = DownloadInfo.Version + Dim Id As String = DownloadInfo.VersionName Dim InstallerAddress As String = PathTemp & "Cache\Code\NeoForgeInstall-" & Version & "_" & RandomInteger(0, 100000) Dim VersionFolder As String = McFolder & "versions\" & Id & "\" Dim DisplayName As String = "NeoForge " & Inherit & " - " & Version @@ -1995,7 +1995,7 @@ Retry: Task.Progress = 0.8 '查找对应版本 For Each NeoForgeVersion In NeoForgeLoader.Output - If NeoForgeVersion.Version = Version Then + If NeoForgeVersion.VersionName = Version Then DownloadInfo = NeoForgeVersion Exit Sub End If @@ -2012,16 +2012,16 @@ Retry: ClientDownloadLoader = McDownloadClient(NetPreDownloadBehaviour.ExitWhileExistsOrDownloading, Inherit) End If Dim Files - If DownloadInfo.StdVersion.StartsWith("47.") Then '1.20.1 NeoForge 下载地址不同 + If DownloadInfo.VersionCode.StartsWith("47.") Then '1.20.1 NeoForge 下载地址不同 Dim FilesLegacy As New List(Of NetFile) From {New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName + "https://bmclapi2.bangbang93.com/maven/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} Files = FilesLegacy Else Dim FilesLatest As New List(Of NetFile) From {New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.StdVersion & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName + "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, + "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} Files = FilesLatest End If @@ -2197,7 +2197,7 @@ Retry: If Entry.IsBeta Then FreshBetaVersion = Entry Else - If Entry.StdVersion.Contains("47.1.82") Then Continue For + If Entry.VersionCode.Contains("47.1.82") Then Continue For FreshStableVersion = Entry End If Next @@ -2221,12 +2221,12 @@ Retry: Public Function NeoForgeDownloadListItem(Entry As DlNeoForgeVersionEntry, OnClick As MyListItem.ClickEventHandler, IsSaveOnly As Boolean) As MyListItem '建立控件 Dim NewItem As New MyListItem With { - .Title = If(Entry.IsBeta, Entry.StdVersion & "-beta", Entry.StdVersion), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, + .Title = If(Entry.IsBeta, Entry.VersionCode & "-beta", Entry.VersionCode), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, .Info = If(Entry.IsBeta, "测试版", "稳定版") & If(Entry.ReleaseTime = "", If(ModeDebug, If(Entry.Category IsNot Nothing, "种类:" & Entry.Category, "") & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), "发布于 " & Entry.ReleaseTime & If(ModeDebug, ",种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), - .Logo = PathImage & "Icons/NeoForged.png" + .Logo = PathImage & "Icons/NeoForge.png" } AddHandler NewItem.Click, OnClick '建立菜单 @@ -2268,7 +2268,7 @@ Retry: Else Version = sender.Parent.Parent.Tag End If - OpenWebsite("https://maven.neoforged.net/releases/net/neoforged/neoforge/" & Version.StdVersion & "/" & Version.Version & "-changelog.txt") + OpenWebsite("https://maven.neoforged.net/releases/net/neoforged/neoforge/" & Version.VersionCode & "/" & Version.VersionName & "-changelog.txt") End Sub Public Sub NeoForgeSave_Click(sender As Object, e As RoutedEventArgs) Dim Version As DlNeoForgeVersionEntry @@ -2597,7 +2597,7 @@ Retry: If Request.ForgeEntry IsNot Nothing Then Request.ForgeVersion = If(Request.ForgeVersion, Request.ForgeEntry.Version) If Request.ForgeVersion IsNot Nothing Then ForgeFolder = TempMcFolder & "versions\" & Request.MinecraftName & "-forge-" & Request.ForgeVersion Dim NeoForgeFolder As String = Nothing - If Request.NeoForgeEntry IsNot Nothing Then Request.NeoForgeVersion = If(Request.NeoForgeVersion, Request.NeoForgeEntry.Version) + If Request.NeoForgeEntry IsNot Nothing Then Request.NeoForgeVersion = If(Request.NeoForgeVersion, Request.NeoForgeEntry.VersionName) If Request.NeoForgeVersion IsNot Nothing Then NeoForgeFolder = TempMcFolder & "versions\" & If(Request.NeoForgeVersion.StartsWithF("1.20.1") OrElse Request.NeoForgeVersion.StartsWithF("47."), "1.20.1-forge-", "") & Request.NeoForgeVersion.Replace("1.20.1-forge-", "").Replace("1.20.1-", "") Dim FabricFolder As String = Nothing If Request.FabricVersion IsNot Nothing Then FabricFolder = TempMcFolder & "versions\fabric-loader-" & Request.FabricVersion & "-" & Request.MinecraftName diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml index b16b8646..9676cfa2 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml @@ -89,7 +89,7 @@ - + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index a58d4cbf..a2ff68d2 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -384,7 +384,7 @@ Else BtnNeoForgeClear.Visibility = Visibility.Visible ImgNeoForge.Visibility = Visibility.Visible - LabNeoForge.Text = SelectedNeoForge.StdVersion & If(SelectedNeoForge.IsBeta, "-beta", "") + LabNeoForge.Text = SelectedNeoForge.VersionCode & If(SelectedNeoForge.IsBeta, "-beta", "") LabNeoForge.Foreground = ColorGray1 End If 'Fabric @@ -499,7 +499,7 @@ Name += "-Forge_" & SelectedForge.Version End If If SelectedNeoForge IsNot Nothing Then - Name += "-NeoForge_" & SelectedNeoForge.StdVersion & If(SelectedNeoForge.IsBeta, "-beta", "") + Name += "-NeoForge_" & SelectedNeoForge.VersionCode & If(SelectedNeoForge.IsBeta, "-beta", "") End If If SelectedLiteLoader IsNot Nothing Then Name += "-LiteLoader" @@ -521,7 +521,7 @@ Info += ", Forge " & SelectedForge.Version End If If SelectedNeoForge IsNot Nothing Then - Info += ", NeoForge " & SelectedNeoForge.StdVersion & If(SelectedNeoForge.IsBeta, "-beta", "") + Info += ", NeoForge " & SelectedNeoForge.VersionCode & If(SelectedNeoForge.IsBeta, "-beta", "") End If If SelectedLiteLoader IsNot Nothing Then Info += ", LiteLoader" @@ -541,7 +541,7 @@ ElseIf SelectedForge IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Anvil.png" ElseIf SelectedNeoForge IsNot Nothing Then - Return "pack://application:,,,/images/Icons/NeoForged.png" + Return "pack://application:,,,/images/Icons/NeoForge.png" ElseIf SelectedLiteLoader IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Egg.png" ElseIf SelectedOptiFine IsNot Nothing Then diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml index 50b7b9f8..4f0ad737 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml @@ -37,7 +37,7 @@ - + diff --git a/Plain Craft Launcher 2/Resources/Custom.xaml b/Plain Craft Launcher 2/Resources/Custom.xaml index f0236e47..1d5bb85d 100644 --- a/Plain Craft Launcher 2/Resources/Custom.xaml +++ b/Plain Craft Launcher 2/Resources/Custom.xaml @@ -202,7 +202,7 @@ - + Date: Thu, 27 Jun 2024 19:43:39 +0800 Subject: [PATCH 31/36] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Images/{Icons => Blocks}/NeoForge.png | Bin .../Modules/Minecraft/ModDownload.vb | 76 +++++------------- .../Modules/Minecraft/ModMinecraft.vb | 20 ++--- .../Pages/PageDownload/ModDownloadLib.vb | 29 +++---- .../PageDownload/PageDownloadInstall.xaml | 2 +- .../PageDownload/PageDownloadInstall.xaml.vb | 3 +- .../Pages/PageVersion/PageVersionOverall.xaml | 2 +- .../Plain Craft Launcher 2.vbproj | 2 +- Plain Craft Launcher 2/Resources/Custom.xaml | 2 +- 9 files changed, 42 insertions(+), 94 deletions(-) rename Plain Craft Launcher 2/Images/{Icons => Blocks}/NeoForge.png (100%) diff --git a/Plain Craft Launcher 2/Images/Icons/NeoForge.png b/Plain Craft Launcher 2/Images/Blocks/NeoForge.png similarity index 100% rename from Plain Craft Launcher 2/Images/Icons/NeoForge.png rename to Plain Craft Launcher 2/Images/Blocks/NeoForge.png diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 1d5f353d..43d683e7 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -785,14 +785,16 @@ Try For Each Token As String In VersionsJArray Dim Version As String = Token.Replace("neoforge-", "") - Dim Inherit As String = $"1.{Version.ToString().Split(".")(0)}.{Token.ToString().Split(".")(1)}" + Dim Inherit As String = $"1.{Version.Split(".")(0)}.{Token.Split(".")(1)}" If Inherit.EndsWith(".0") Then Inherit = Inherit.Replace(".0", "") - Versions.Add(Inherit) + If Versions.Contains(Inherit) Then + Continue For + Else + Versions.Add(Inherit) + End If Next - Versions.Distinct() '去重 Catch ex As Exception Log(ex, LogLevel.Feedback) - 'Throw New Exception("版本列表解析失败(" & VersionsJArray.ToString & ")", ex) End Try If Not Versions.Any() Then Throw New Exception("没有可用版本") Loader.Output = New DlNeoForgeListResult With {.IsOfficial = True, .SourceName = "NeoForge 官方源", .Value = Versions} @@ -808,9 +810,8 @@ Dim ClientReleases As New List(Of String) For Each Client In ClientVersions '排除快照版或远古版等特殊版本 - Dim ClientVersionString = Client("id").ToString() - If Not (ClientVersionString.ContainsF("a") OrElse ClientVersionString.ContainsF("b") OrElse ClientVersionString.ContainsF("c") OrElse ClientVersionString.ContainsF("w") OrElse ClientVersionString.ContainsF("pre") OrElse ClientVersionString.ContainsF("Pre") OrElse ClientVersionString.ContainsF("rc") OrElse ClientVersionString.ContainsF("b") OrElse ClientVersionString.ContainsF("rd") OrElse ClientVersionString.ContainsF("inf")) Then - ClientReleases.Add(ClientVersionString) + If RegexCheck(Client("id").ToString(), "[0,9.]+") Then + ClientReleases.Add(Client("id").ToString()) End If Next @@ -846,10 +847,6 @@ ''' Public Hash As String = Nothing ''' - ''' 安装类型。有 installer、client、universal 三种。 - ''' - Public Category As String - ''' ''' 版本分支。若无分支则为 Nothing。 ''' Public Branch As String = Nothing @@ -876,19 +873,6 @@ Public Value As JObject End Structure ''' - ''' 构建数。 - ''' - Public ReadOnly Property Build As Integer - Get - Dim Version = Me.VersionName.Split(".") - If Version(0) < 15 Then - Return Version(Version.Count - 1) - Else - Return Version(Version.Count - 1) + 10000 - End If - End Get - End Property - ''' ''' 用于下载的文件版本名。可能在 Version 的基础上添加了分支。 ''' Public ReadOnly Property FileVersion As String @@ -908,10 +892,6 @@ End If End Get End Property - ''' - ''' 文件扩展名。 - ''' - Public FileSuffix As String = "jar" End Class ''' ''' NeoForge 版本列表,主加载器。 @@ -944,13 +924,9 @@ Public Sub DlNeoForgeVersionOfficialMain(Loader As LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))) Dim ResultLatest As String Dim ResultLegacy As String - Dim ResultLatestJson As JObject - Dim ResultLegacyJson As JObject - Dim VersionsJArray As JArray - Dim IsLegacyNeo As Boolean = False Try - ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True) - ResultLegacy = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/forge", UseBrowserUserAgent:=True) + ResultLatest = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True, IsJson:=True) + ResultLegacy = NetGetCodeByDownload("https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/forge", UseBrowserUserAgent:=True, IsJson:=True) Catch ex As Exception If GetExceptionSummary(ex).Contains("(404)") Then Throw New Exception("没有可用版本") @@ -959,15 +935,13 @@ End If End Try If ResultLatest.Length < 50 AndAlso ResultLegacy.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & ResultLatest & ")") - ResultLatestJson = GetJson(ResultLatest) - ResultLegacyJson = GetJson(ResultLegacy) - If Loader.Input IsNot Nothing Then - If Loader.Input.ToString().Contains("1.20.1") Then - VersionsJArray = ResultLegacyJson("versions") - IsLegacyNeo = True - Else - VersionsJArray = ResultLatestJson("versions") - End If + Dim ResultLatestJson As JObject = GetJson(ResultLatest) + Dim ResultLegacyJson As JObject = GetJson(ResultLegacy) + Dim VersionsJArray As JArray + Dim IsLegacyNeo As Boolean = False + If Loader.Input IsNot Nothing AndAlso Loader.Input.ToString().Contains("1.20.1") Then + VersionsJArray = ResultLegacyJson("versions") + IsLegacyNeo = True Else VersionsJArray = ResultLatestJson("versions") End If @@ -984,19 +958,14 @@ StdVersion = Token.Replace("neoforge-", "").Replace("1.20.1-", "") IsBeta = False End If - Dim Inherit As String = "1." & StdVersion.Split(".")(0) & "." & StdVersion.Split(".")(1) - Inherit = Inherit.Replace(".0", "") - If IsLegacyNeo Then Inherit = "1.20.1" + Dim Inherit As String = $"1.{StdVersion.Split(".")(0)}.{StdVersion.Split(".")(1)}" + If Inherit.EndsWithF(".0") Then Inherit.Remove(Inherit.LastIndexOfF(".0"), 1) + Inherit = If(IsLegacyNeo, "1.20.1", Inherit) Dim Entry = New DlNeoForgeVersionEntry If Loader.Input IsNot Nothing Then - If IsLegacyNeo Then + If IsLegacyNeo OrElse Inherit.Contains(Loader.Input.ToString().Replace("1.", "")) Then Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion} Versions.Add(Entry) - Else - If Inherit.Contains(Loader.Input.ToString().Replace("1.", "")) Then - Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion} - Versions.Add(Entry) - End If End If Else Entry = New DlNeoForgeVersionEntry With {.VersionName = rawVersion, .Inherit = Inherit, .IsBeta = IsBeta, .VersionCode = StdVersion} @@ -1004,8 +973,7 @@ End If Next Catch ex As Exception - MyMsgBox(ex.ToString(), "错误") - Throw New Exception("版本列表解析失败(" & VersionsJArray.ToString & ")", ex) + Log(ex, LogLevel.Feedback) End Try If Not Versions.Any() Then Throw New Exception("没有可用版本") Dim VersionsArray = Versions.ToList() diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb index 620134d0..676d5b10 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb @@ -761,7 +761,7 @@ ExitDataLoad: Case McVersionState.Forge Logo = PathImage & "Blocks/Anvil.png" Case McVersionState.NeoForge - Logo = PathImage & "Icons/NeoForge.png" + Logo = PathImage & "Blocks/NeoForge.png" Case McVersionState.Fabric Logo = PathImage & "Blocks/Fabric.png" Case McVersionState.OptiFine @@ -979,25 +979,15 @@ ExitDataLoad: Else Throw New Exception("无效的 Fabric 版本:" & ForgeVersion) End If - ElseIf HasForge Then - If ForgeVersion = "未知版本" Then Return 0 - Dim SubVersions = ForgeVersion.Split(".") + ElseIf HasForge OrElse HasNeoForge Then + If ForgeVersion = "未知版本" AndAlso NeoForgeVersion = "未知版本" Then Return 0 + Dim SubVersions = If(HasForge, ForgeVersion.Split("."), NeoForgeVersion.Split(".")) If SubVersions.Length = 4 Then _SortCode = Val(SubVersions(0)) * 1000000 + Val(SubVersions(1)) * 10000 + Val(SubVersions(3)) ElseIf SubVersions.Length = 3 Then _SortCode = Val(SubVersions(0)) * 1000000 + Val(SubVersions(1)) * 10000 + Val(SubVersions(2)) Else - Throw New Exception("无效的 Forge 版本:" & ForgeVersion) - End If - ElseIf HasNeoForge Then - If NeoForgeVersion = "未知版本" Then Return 0 - Dim SubVersions = NeoForgeVersion.Split(".") - If SubVersions.Length = 4 Then - _SortCode = Val(SubVersions(0)) * 1000000 + Val(SubVersions(1)) * 10000 + Val(SubVersions(3)) - ElseIf SubVersions.Length = 3 Then - _SortCode = Val(SubVersions(0)) * 1000000 + Val(SubVersions(1)) * 10000 + Val(SubVersions(2)) - Else - Throw New Exception("无效的 NeoForge 版本:" & NeoForgeVersion) + Throw New Exception(If(HasForge, "无效的 Forge 版本:" & ForgeVersion, "无效的 NeoForge 版本:" & NeoForgeVersion)) End If ElseIf HasOptiFine Then If OptiFineVersion = "未知版本" Then Return 0 diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index bbe980ab..b63f82a6 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1701,7 +1701,7 @@ Retry: Public Sub McDownloadNeoForge(DownloadInfo As DlNeoForgeVersionEntry) '初始化参数 Dim Id As String = DownloadInfo.Inherit & "-neoforge-" & DownloadInfo.VersionName - Dim Target As String = PathTemp & "Cache\Code\NeoForgeInstall-" & DownloadInfo.VersionName & "_" & GetUuid() & "." & DownloadInfo.FileSuffix + Dim Target As String = PathTemp & "Cache\Code\NeoForgeInstall-" & DownloadInfo.VersionName & "_" & GetUuid() & ".jar" Dim VersionFolder As String = PathMcFolder & "versions\" & Id & "\" Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.VersionName Try @@ -1745,7 +1745,7 @@ Retry: End Sub Public Sub McDownloadNeoForgeSave(DownloadInfo As DlNeoForgeVersionEntry) Try - Dim Target As String = SelectAs("选择保存位置", DownloadInfo.FileName, "NeoForge 文件 (*." & DownloadInfo.FileSuffix & ")|*." & DownloadInfo.FileSuffix) + Dim Target As String = SelectAs("选择保存位置", DownloadInfo.FileName, "NeoForge 文件 (*.jar)") Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.VersionName If Not Target.Contains("\") Then Exit Sub @@ -2011,20 +2011,11 @@ Retry: If IsCustomFolder Then Throw New Exception("如果没有指定原版下载器,则不能指定 MC 安装文件夹") ClientDownloadLoader = McDownloadClient(NetPreDownloadBehaviour.ExitWhileExistsOrDownloading, Inherit) End If - Dim Files - If DownloadInfo.VersionCode.StartsWith("47.") Then '1.20.1 NeoForge 下载地址不同 - Dim FilesLegacy As New List(Of NetFile) From {New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName - }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} - Files = FilesLegacy - Else - Dim FilesLatest As New List(Of NetFile) From {New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName + Dim IsLegacyNeo As Boolean = DownloadInfo.VersionCode.StartsWith("47.") + Dim Files As New List(Of NetFile) From {New NetFile({ + $"https://bmclapi2.bangbang93.com/maven/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}", + $"https://maven.neoforged.net/releases/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}" }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} - Files = FilesLatest - End If Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) Loaders.Add(New LoaderDownload("下载 NeoForge 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) @@ -2224,9 +2215,9 @@ Retry: .Title = If(Entry.IsBeta, Entry.VersionCode & "-beta", Entry.VersionCode), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, .Info = If(Entry.IsBeta, "测试版", "稳定版") & If(Entry.ReleaseTime = "", - If(ModeDebug, If(Entry.Category IsNot Nothing, "种类:" & Entry.Category, "") & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), - "发布于 " & Entry.ReleaseTime & If(ModeDebug, ",种类:" & Entry.Category & If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), - .Logo = PathImage & "Icons/NeoForge.png" + If(ModeDebug, If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), + "发布于 " & Entry.ReleaseTime & If(ModeDebug, If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), + .Logo = PathImage & "Blocks/NeoForge.png" } AddHandler NewItem.Click, OnClick '建立菜单 @@ -2559,7 +2550,7 @@ Retry: Public Function McInstallLoader(Request As McInstallRequest, Optional DontFixLibraries As Boolean = False) As List(Of LoaderBase) '获取缓存目录 Dim PathInstallTemp As String - If PathTemp.Contains(" ") AndAlso (Request.ForgeEntry IsNot Nothing Or Request.NeoForgeEntry IsNot Nothing) Then + If PathTemp.Contains(" ") AndAlso (Request.ForgeEntry IsNot Nothing OrElse Request.NeoForgeEntry IsNot Nothing) Then PathInstallTemp = OsDrive & "ProgramData\PCL\Install\" Else PathInstallTemp = PathTemp & "Install\" diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml index 9676cfa2..1cf0a2d5 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml @@ -89,7 +89,7 @@ - + diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index a2ff68d2..1adeb061 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -541,7 +541,7 @@ ElseIf SelectedForge IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Anvil.png" ElseIf SelectedNeoForge IsNot Nothing Then - Return "pack://application:,,,/images/Icons/NeoForge.png" + Return "pack://application:,,,/images/Blocks/NeoForge.png" ElseIf SelectedLiteLoader IsNot Nothing Then Return "pack://application:,,,/images/Blocks/Egg.png" ElseIf SelectedOptiFine IsNot Nothing Then @@ -946,7 +946,6 @@ End If If Loader.State <> LoadState.Finished Then Return "获取版本列表失败:未知错误,状态为 " & GetStringFromEnum(Loader.State) For Each Version In Loader.Output - If Version.Category = "universal" OrElse Version.Category = "client" Then Continue For '跳过无法自动安装的版本 If SelectedForge IsNot Nothing Then Return "与 Forge 不兼容" If SelectedFabric IsNot Nothing Then Return "与 Fabric 不兼容" Return Nothing diff --git a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml index 4f0ad737..d461c047 100644 --- a/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml +++ b/Plain Craft Launcher 2/Pages/PageVersion/PageVersionOverall.xaml @@ -37,7 +37,7 @@ - + diff --git a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj index 663d1ee2..73310617 100644 --- a/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj +++ b/Plain Craft Launcher 2/Plain Craft Launcher 2.vbproj @@ -924,7 +924,7 @@ - + \ No newline at end of file diff --git a/Plain Craft Launcher 2/Resources/Custom.xaml b/Plain Craft Launcher 2/Resources/Custom.xaml index 1d5bb85d..bf12a825 100644 --- a/Plain Craft Launcher 2/Resources/Custom.xaml +++ b/Plain Craft Launcher 2/Resources/Custom.xaml @@ -202,7 +202,7 @@ - + Date: Fri, 28 Jun 2024 09:44:55 +0800 Subject: [PATCH 32/36] =?UTF-8?q?refactor:=20=E5=90=88=E5=B9=B6=20Forge=20?= =?UTF-8?q?=E5=92=8C=20NeoForge=20=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 11 +- .../Pages/PageDownload/ModDownloadLib.vb | 656 +++--------------- .../PageDownload/PageDownloadNeoForge.xaml.vb | 4 +- 3 files changed, 116 insertions(+), 555 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 43d683e7..eeb04889 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -787,12 +787,9 @@ Dim Version As String = Token.Replace("neoforge-", "") Dim Inherit As String = $"1.{Version.Split(".")(0)}.{Token.Split(".")(1)}" If Inherit.EndsWith(".0") Then Inherit = Inherit.Replace(".0", "") - If Versions.Contains(Inherit) Then - Continue For - Else - Versions.Add(Inherit) - End If + Versions.Add(Inherit) Next + Versions = Versions.Distinct().ToList() Catch ex As Exception Log(ex, LogLevel.Feedback) End Try @@ -892,6 +889,10 @@ End If End Get End Property + ''' + ''' 文件扩展名 + ''' + Public ReadOnly Property FileSuffix As String = ".jar" End Class ''' ''' NeoForge 版本列表,主加载器。 diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index b63f82a6..71ccef52 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1005,15 +1005,16 @@ Retry: #End Region -#Region "Forge 下载" +#Region "Forge / NeoForge 下载" - Public Sub McDownloadForge(DownloadInfo As DlForgeVersionEntry) + Public Sub McDownloadForge(IsNeo As Boolean, Optional DownloadForgeInfo As DlForgeVersionEntry = Nothing, Optional DownloadNeoInfo As DlNeoForgeVersionEntry = Nothing) + Dim DownloadInfo = If(IsNeo, DownloadNeoInfo, DownloadForgeInfo) '老版本提示 If DownloadInfo.Category = "client" Then If MyMsgBox("该 Forge 版本过于古老,PCL 暂不支持该版本的自动安装。" & vbCrLf & "若你仍然希望继续,PCL 将把安装程序下载到你指定的位置,但不会进行安装。", "版本过老", "继续", "取消") = 1 Then - McDownloadForgeSave(DownloadInfo) + McDownloadForgeSave(IsNeo, DownloadInfo) End If Exit Sub End If @@ -1021,15 +1022,15 @@ Retry: If MyMsgBox("该 Forge 版本过于古老,PCL 暂不支持该版本的自动安装。" & vbCrLf & "若你仍然希望继续,PCL 将把安装程序下载到你指定的位置,但不会进行安装。", "版本过老", "继续", "取消") = 1 Then - McDownloadForgeSave(DownloadInfo) + McDownloadForgeSave(IsNeo, DownloadInfo) End If Exit Sub End If '初始化参数 - Dim Id As String = DownloadInfo.Inherit & "-forge-" & DownloadInfo.Version - Dim Target As String = PathTemp & "Cache\Code\ForgeInstall-" & DownloadInfo.Version & "_" & GetUuid() & "." & DownloadInfo.FileSuffix + Dim Id As String = DownloadInfo.Inherit & $"-{If(IsNeo, "neo", "")}forge-" & DownloadInfo.Version + Dim Target As String = PathTemp & $"Cache\Code\{If(IsNeo, "Neo", "")}ForgeInstall-" & DownloadInfo.Version & "_" & GetUuid() & "." & DownloadInfo.FileSuffix Dim VersionFolder As String = PathMcFolder & "versions\" & Id & "\" - Dim DisplayName As String = "Forge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version + Dim DisplayName As String = $"{If(IsNeo, "Neo", "")}Forge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version Try '重复任务检查 @@ -1053,14 +1054,14 @@ Retry: End If '启动 - Dim Loader As New LoaderCombo(Of String)(DisplayName & " 下载", McDownloadForgeLoader(DownloadInfo.Version, DownloadInfo.Inherit, DownloadInfo)) With {.OnStateChanged = AddressOf McInstallState} + Dim Loader As New LoaderCombo(Of String)(DisplayName & " 下载", McDownloadForgeLoader(IsNeo, DownloadInfo.Version, DownloadInfo.Inherit, DownloadInfo)) With {.OnStateChanged = AddressOf McInstallState} Loader.Start(VersionFolder) LoaderTaskbarAdd(Loader) FrmMain.BtnExtraDownload.ShowRefresh() FrmMain.BtnExtraDownload.Ribble() Catch ex As Exception - Log(ex, "开始 Forge 下载失败", LogLevel.Feedback) + Log(ex, $"开始 {If(IsNeo, "Neo", "")}Forge 下载失败", LogLevel.Feedback) Finally '删除安装包 Try @@ -1069,10 +1070,11 @@ Retry: End Try End Try End Sub - Public Sub McDownloadForgeSave(DownloadInfo As DlForgeVersionEntry) + Public Sub McDownloadForgeSave(IsNeo As Boolean, Optional DownloadForgeInfo As DlForgeVersionEntry = Nothing, Optional DownloadNeoInfo As DlNeoForgeVersionEntry = Nothing) + Dim DownloadInfo = If(IsNeo, DownloadNeoInfo, DownloadForgeInfo) Try - Dim Target As String = SelectAs("选择保存位置", DownloadInfo.FileName, "Forge 文件 (*." & DownloadInfo.FileSuffix & ")|*." & DownloadInfo.FileSuffix) - Dim DisplayName As String = "Forge " & DownloadInfo.Inherit & " - " & DownloadInfo.Version + Dim Target As String = SelectAs("选择保存位置", DownloadInfo.FileName, $"{If(IsNeo, "Neo", "")}Forge 文件 (*." & DownloadInfo.FileSuffix & ")|*." & DownloadInfo.FileSuffix) + Dim DisplayName As String = $"{If(IsNeo, "Neo", "")}Forge " & DownloadInfo.Inherit & " - " & If(IsNeo, DownloadInfo.VersionCode, DownloadInfo.Version) If Not Target.Contains("\") Then Exit Sub '重复任务检查 @@ -1088,31 +1090,47 @@ Retry: '构造步骤加载器 Dim Loaders As New List(Of LoaderBase) '获取下载地址 - Loaders.Add(New LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))("获取下载地址", - Sub(Task As LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))) - Dim Files As New List(Of NetFile) - Files.Add(New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, - "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName - }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) - Task.Output = Files - End Sub) With {.ProgressWeight = 0.1, .Show = False}) + If IsNeo Then + 'NeoForge + Loaders.Add(New LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))("获取下载地址", + Sub(Task As LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))) + Dim Files As New List(Of NetFile) + Dim IsLegacyNeo As Boolean = DownloadInfo.VersionCode.StartsWith("47.") + Files.Add(New NetFile({ + $"https://bmclapi2.bangbang93.com/maven/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}", + $"https://maven.neoforged.net/releases/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}" + }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) + Task.Output = Files + End Sub) With {.ProgressWeight = 0.1, .Show = False}) + Else + 'Forge + Loaders.Add(New LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))("获取下载地址", + Sub(Task As LoaderTask(Of DlForgeVersionEntry, List(Of NetFile))) + Dim Files As New List(Of NetFile) + Files.Add(New NetFile({ + "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, + "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName + }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) + Task.Output = Files + End Sub) With {.ProgressWeight = 0.1, .Show = False}) + End If '下载 Loaders.Add(New LoaderDownload("下载主文件", New List(Of NetFile)) With {.ProgressWeight = 6}) '启动 - Dim Loader As New LoaderCombo(Of DlForgeVersionEntry)(DisplayName & " 下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave} + Dim Loader = If(IsNeo, New LoaderCombo(Of DlNeoForgeVersionEntry)(DisplayName & " 下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave}, + New LoaderCombo(Of DlForgeVersionEntry)(DisplayName & " 下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave}) Loader.Start(DownloadInfo) LoaderTaskbarAdd(Loader) FrmMain.BtnExtraDownload.ShowRefresh() FrmMain.BtnExtraDownload.Ribble() Catch ex As Exception - Log(ex, "开始 Forge 下载失败", LogLevel.Feedback) + Log(ex, $"开始 {If(IsNeo, "Neo", "")}Forge 下载失败", LogLevel.Feedback) End Try End Sub - Private Sub ForgeInjector(Target As String, Task As LoaderTask(Of Boolean, Boolean), McFolder As String, UseJavaWrapper As Boolean) + Private Sub ForgeInjector(Target As String, Task As LoaderTask(Of Boolean, Boolean), McFolder As String, UseJavaWrapper As Boolean, IsNeoForge As Boolean) '选择 Java Dim Java As JavaEntry SyncLock JavaLock @@ -1153,7 +1171,7 @@ Retry: .RedirectStandardError = True, .RedirectStandardOutput = True } - Log("[Download] 开始安装 Forge:" & Arguments) + Log($"[Download] 开始安装 {If(IsNeoForge, "Neo", "")}Forge:" & Arguments) Dim process As New Process With {.StartInfo = Info} Dim LastResults As New Queue(Of String) Using outputWaitHandle As New AutoResetEvent(False) @@ -1170,11 +1188,11 @@ Retry: End If Catch ex As ObjectDisposedException Catch ex As Exception - Log(ex, "读取 Forge 安装器信息失败") + Log(ex, $"读取 {If(IsNeoForge, "Neo", "")}Forge 安装器信息失败") End Try Try If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then - Log("[Installer] 由于任务取消,已中止 Forge 安装") + Log($"[Installer] 由于任务取消,已中止 {If(IsNeoForge, "Neo", "")}Forge 安装") process.Kill() End If Catch @@ -1193,11 +1211,11 @@ Retry: End If Catch ex As ObjectDisposedException Catch ex As Exception - Log(ex, "读取 Forge 安装器错误信息失败") + Log(ex, $"读取 {If(IsNeoForge, "Neo", "")}Forge 安装器错误信息失败") End Try Try If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then - Log("[Installer] 由于任务取消,已中止 Forge 安装") + Log($"[Installer] 由于任务取消,已中止 {If(IsNeoForge, "Neo", "")}Forge 安装") process.Kill() End If Catch @@ -1222,7 +1240,7 @@ Retry: For i As Integer = Math.Max(0, LastResults.Count - 5) To LastResults.Count - 1 '最后 5 行 LastLines &= vbCrLf & LastResults(i) Next - Throw New Exception("Forge 安装器出错,日志结束部分为:" & LastLines) + Throw New Exception($"{If(IsNeoForge, "Neo", "")}Forge 安装器出错,日志结束部分为:" & LastLines) End Using End Using End SyncLock @@ -1273,31 +1291,43 @@ Retry: End Sub ''' - ''' 获取下载某个 Forge 版本的加载器列表。 + ''' 获取下载某个 Forge / NeoForge 版本的加载器列表。 ''' - Private Function McDownloadForgeLoader(Version As String, Inherit As String, Optional DownloadInfo As DlForgeVersionEntry = Nothing, Optional McFolder As String = Nothing, Optional ClientDownloadLoader As LoaderCombo(Of String) = Nothing, Optional ClientFolder As String = Nothing, Optional FixLibrary As Boolean = True) As List(Of LoaderBase) + Private Function McDownloadForgeLoader(IsNeo As Boolean, Version As String, Inherit As String, Optional DownloadForgeInfo As DlForgeVersionEntry = Nothing, Optional DownloadNeoInfo As DlNeoForgeVersionEntry = Nothing, Optional McFolder As String = Nothing, Optional ClientDownloadLoader As LoaderCombo(Of String) = Nothing, Optional ClientFolder As String = Nothing, Optional FixLibrary As Boolean = True) As List(Of LoaderBase) '参数初始化 + Dim DownloadInfo = If(IsNeo, DownloadNeoInfo, DownloadForgeInfo) + If DownloadNeoInfo Is Nothing AndAlso IsNeo Then '兜底,有的时候 DownloadInfo 可能是空的 + DownloadInfo.VersionName = Version + Version = Version.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") + DownloadInfo.VersionCode = Version + If Version.Contains("-beta") Then DownloadInfo.IsBeta = True + ElseIf IsNeo Then + DownloadInfo = DownloadNeoInfo + Version = DownloadInfo.VersionCode + Else + DownloadInfo = DownloadForgeInfo + End If McFolder = If(McFolder, PathMcFolder) - If Version.StartsWithF("1.") AndAlso Version.Contains("-") Then + If Not IsNeo AndAlso Version.StartsWithF("1.") AndAlso Version.Contains("-") Then '类似 1.19.3-41.2.8 格式,优先使用 Version 中要求的版本而非 Inherit(例如 1.19.3 却使用了 1.19 的 Forge) Inherit = Version.Before("-") Version = Version.After("-") End If Dim IsCustomFolder As Boolean = McFolder <> PathMcFolder - Dim Id As String = Inherit & "-forge-" & Version - Dim InstallerAddress As String = PathTemp & "Cache\Code\ForgeInstall-" & Version & "_" & RandomInteger(0, 100000) + Dim Id As String = If(IsNeo, DownloadInfo.VersionName, Inherit & "-forge-" & Version) + Dim InstallerAddress As String = PathTemp & $"Cache\Code\{If(IsNeo, "Neo", "")}ForgeInstall-" & Version & "_" & RandomInteger(0, 100000) Dim VersionFolder As String = McFolder & "versions\" & Id & "\" - Dim DisplayName As String = "Forge " & Inherit & " - " & Version + Dim DisplayName As String = $"{If(IsNeo, "Neo", "")}Forge " & Inherit & " - " & Version Dim Loaders As New List(Of LoaderBase) Dim LibVersionFolder As String = PathMcFolder & "versions\" & Id & "\" '作为 Lib 文件目标的版本文件夹 '获取下载信息 If DownloadInfo Is Nothing Then - Loaders.Add(New LoaderTask(Of String, String)("获取 Forge 详细信息", + Loaders.Add(New LoaderTask(Of String, String)($"获取 {If(IsNeo, "Neo", "")}Forge 详细信息", Sub(Task As LoaderTask(Of String, String)) - '获取 Forge 版本列表 - Dim ForgeLoader = New LoaderTask(Of String, List(Of DlForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlForgeVersionMain) + '获取 Forge / NeoForge 版本列表 + Dim ForgeLoader = If(IsNeo, New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlNeoForgeVersionMain), New LoaderTask(Of String, List(Of DlForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlForgeVersionMain)) ForgeLoader.WaitForExit(Inherit) Task.Progress = 0.8 '查找对应版本 @@ -1307,11 +1337,11 @@ Retry: Exit Sub End If Next - Throw New Exception("未能找到 Forge " & Inherit & "-" & Version & " 的详细信息!") + Throw New Exception($"未能找到 {If(IsNeo, "Neo", "")}Forge " & Inherit & "-" & Version & " 的详细信息!") End Sub) With {.ProgressWeight = 3}) End If - '下载 Forge 主文件 - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("准备下载 Forge", + '下载 Forge / NeoForge 主文件 + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"准备下载 {If(IsNeo, "Neo", "")}Forge", Sub(Task As LoaderTask(Of String, List(Of NetFile))) '启动依赖版本的下载 If ClientDownloadLoader Is Nothing Then @@ -1319,19 +1349,28 @@ Retry: ClientDownloadLoader = McDownloadClient(NetPreDownloadBehaviour.ExitWhileExistsOrDownloading, Inherit) End If '添加主文件 - Dim Files As New List(Of NetFile) From {New NetFile({ + Dim Files + If IsNeo Then 'NeoForge + Dim IsLegacyNeo As Boolean = DownloadInfo.VersionCode.StartsWith("47.") + Files = New List(Of NetFile) From {New NetFile({ + $"https://bmclapi2.bangbang93.com/maven/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}", + $"https://maven.neoforged.net/releases/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}" + }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} + Else 'Forge + Files = New List(Of NetFile) From {New NetFile({ "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} + End If Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) - Loaders.Add(New LoaderDownload("下载 Forge 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) + Loaders.Add(New LoaderDownload($"下载 {If(IsNeo, "Neo", "")}Forge 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) '安装(仅在新版安装时需要原版 Jar) If Version.Before(".") >= 20 Then - Log("[Download] 检测为新版 Forge:" & Version) + Log($"[Download] 检测为{If(IsNeo, " Neo", "新版 ")}Forge:" & Version) Dim Libs As List(Of McLibToken) = Nothing - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Forge 支持库文件", + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"分析 {If(IsNeo, "Neo", "")}Forge 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = New List(Of NetFile) Dim Installer As ZipArchive = Nothing @@ -1357,27 +1396,27 @@ Retry: Log("[Download] 需要下载 Mappings:" & Address) End If Task.Progress = 0.8 - '去除其中的原始 Forge 项 + '去除其中的原始 Forge / NeoForge 项 For i = 0 To Libs.Count - 1 - If Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & ".jar") OrElse + If Libs(i).LocalPath.EndsWithF($"{If(IsNeo, "neo", "")}forge-" & Inherit & "-" & Version & ".jar") OrElse Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & "-client.jar") Then - Log("[Download] 已从待下载 Forge 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug) + Log($"[Download] 已从待下载 {If(IsNeo, "Neo", "")}Forge 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug) Libs.RemoveAt(i) Exit For End If Next Task.Output = McLibFixFromLibToken(Libs, PathMcFolder) Catch ex As Exception - Throw New Exception("获取新版 Forge 支持库列表失败", ex) + Throw New Exception($"获取{If(IsNeo, " Neo", "新版 ")}Forge 支持库列表失败", ex) Finally '释放文件 If Installer IsNot Nothing Then Installer.Dispose() End Try End Sub) With {.ProgressWeight = 2}) - Loaders.Add(New LoaderDownload("下载 Forge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) - Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 Forge 支持库文件", + Loaders.Add(New LoaderDownload($"下载 {If(IsNeo, "Neo", "")}Forge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) + Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)($"获取 {If(IsNeo, "Neo", "")}Forge 支持库文件", Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) -#Region "Forge 文件" +#Region "Forge / NeoForge 文件" If IsCustomFolder Then For Each LibFile As McLibToken In Libs Dim RealPath As String = LibFile.LocalPath.Replace(PathMcFolder, McFolder) @@ -1385,7 +1424,7 @@ Retry: Directory.CreateDirectory(IO.Path.GetDirectoryName(RealPath)) CopyFile(LibFile.LocalPath, RealPath) End If - If ModeDebug Then Log("[Download] 复制的 Forge 支持库文件:" & LibFile.LocalPath) + If ModeDebug Then Log($"[Download] 复制的 {If(IsNeo, "Neo", "")}Forge 支持库文件:" & LibFile.LocalPath) Next End If #End Region @@ -1395,7 +1434,7 @@ Retry: Dim TargetLoaders As List(Of LoaderBase) = ClientDownloadLoader.GetLoaderList.Where(Function(l) l.Name = McDownloadClientLibName OrElse l.Name = McDownloadClientJsonName). Where(Function(l) l.State <> LoadState.Finished).ToList - If TargetLoaders.Any Then Log("[Download] Forge 安装正在等待原版文件下载完成") + If TargetLoaders.Any Then Log($"[Download] {If(IsNeo, "Neo", "")}Forge 安装正在等待原版文件下载完成") Do While TargetLoaders.Any AndAlso Not Task.IsAborted TargetLoaders = TargetLoaders.Where(Function(l) l.State <> LoadState.Finished).ToList Thread.Sleep(50) @@ -1415,11 +1454,11 @@ Retry: End SyncLock #End Region End Sub) With {.ProgressWeight = 0.1, .Show = False}) - Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 Forge(方式 A)", + Loaders.Add(New LoaderTask(Of Boolean, Boolean)(If(IsNeo, "安装 NeoForge", "安装 Forge(方式 A)"), Sub(Task As LoaderTask(Of Boolean, Boolean)) Dim Installer As ZipArchive = Nothing Try - Log("[Download] 开始进行新版方式 Forge 安装:" & InstallerAddress) + Log($"[Download] 开始进行{If(IsNeo, " Neo", "新版方式 ")}Forge 安装:" & InstallerAddress) '记录当前文件夹列表(在新建目标文件夹之前) Dim OldList = New DirectoryInfo(McFolder & "versions\").EnumerateDirectories. Select(Function(i) i.FullName).ToList() @@ -1440,15 +1479,15 @@ Retry: WriteFile(PathTemp & "Cache\forge_installer.jar", GetResources("ForgeInstaller")) Task.Progress = 0.06 '运行注入器 - ForgeInjector(InstallerAddress, Task, McFolder, UseJavaWrapper) + ForgeInjector(InstallerAddress, Task, McFolder, UseJavaWrapper, False) Task.Progress = 0.97 Catch ex As Exception If UseJavaWrapper Then - Log(ex, "使用 JavaWrapper 安装 Forge 失败,将不使用 JavaWrapper 并重试") + Log(ex, $"使用 JavaWrapper 安装 {If(IsNeo, "Neo", "")}Forge 失败,将不使用 JavaWrapper 并重试") UseJavaWrapper = False GoTo Retry Else - Throw New Exception("运行 Forge 安装器失败", ex) + Throw New Exception($"运行 {If(IsNeo, "Neo", "")}Forge 安装器失败", ex) End If End Try '拷贝新增的版本 Json @@ -1457,7 +1496,7 @@ Retry: If DeltaList.Count > 1 Then '它可能和 OptiFine 安装同时运行,导致增加的文件不止一个(这导致了 #151) '也可能是因为 Forge 安装器的 Bug,生成了一个名字错误的文件夹,所以需要检查文件夹是否为空 - DeltaList = DeltaList.Where(Function(l) l.Name.Contains("forge") AndAlso l.EnumerateFiles.Any).ToList + DeltaList = DeltaList.Where(Function(l) l.Name.Contains($"{If(IsNeo, "neo", "")}forge") AndAlso l.EnumerateFiles.Any).ToList End If If DeltaList.Count = 1 Then '如果没有新增文件夹,那么预测的文件夹名就是正确的 Dim JsonFile As FileInfo = DeltaList(0).EnumerateFiles.First() @@ -1466,14 +1505,14 @@ Retry: '新建 mods 文件夹 Directory.CreateDirectory(New McVersion(VersionFolder).GetPathIndie(True) & "mods\") Catch ex As Exception - Throw New Exception("安装新 Forge 版本失败", ex) + Throw New Exception($"安装新 {If(IsNeo, "Neo", "")}Forge 版本失败", ex) Finally '清理文件 Try If Installer IsNot Nothing Then Installer.Dispose() If File.Exists(InstallerAddress) Then File.Delete(InstallerAddress) Catch ex As Exception - Log(ex, "安装 Forge 清理文件时出错") + Log(ex, $"安装 {If(IsNeo, "Neo", "")}Forge 清理文件时出错") End Try End Try End Sub) With {.ProgressWeight = 10}) @@ -1534,8 +1573,8 @@ Retry: End Sub) With {.ProgressWeight = 1}) If FixLibrary Then If IsCustomFolder Then Throw New Exception("若需要补全支持库,就不能自定义 MC 文件夹") - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 Forge 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(VersionFolder))) With {.ProgressWeight = 1, .Show = False}) - Loaders.Add(New LoaderDownload("下载 Forge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 11}) + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"分析 {If(IsNeo, "Neo", "")}Forge 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(VersionFolder))) With {.ProgressWeight = 1, .Show = False}) + Loaders.Add(New LoaderDownload($"下载 {If(IsNeo, "Neo", "")}Forge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 11}) End If End If @@ -1634,7 +1673,7 @@ Retry: Else Version = sender.Parent.Parent.Tag End If - McDownloadForgeSave(Version) + McDownloadForgeSave(False, Version) End Sub #End Region @@ -1696,485 +1735,6 @@ Retry: #End Region -#Region "NeoForge 下载" - - Public Sub McDownloadNeoForge(DownloadInfo As DlNeoForgeVersionEntry) - '初始化参数 - Dim Id As String = DownloadInfo.Inherit & "-neoforge-" & DownloadInfo.VersionName - Dim Target As String = PathTemp & "Cache\Code\NeoForgeInstall-" & DownloadInfo.VersionName & "_" & GetUuid() & ".jar" - Dim VersionFolder As String = PathMcFolder & "versions\" & Id & "\" - Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.VersionName - Try - - '重复任务检查 - SyncLock LoaderTaskbarLock - For i = 0 To LoaderTaskbar.Count - 1 - If LoaderTaskbar(i).Name = DisplayName & " 下载" Then - Hint("该版本正在下载中!", HintType.Critical) - Exit Sub - End If - Next - End SyncLock - - '已有版本检查 - If File.Exists(VersionFolder & Id & ".json") Then - If MyMsgBox("版本 " & Id & " 已存在,是否重新下载?" & vbCrLf & "这会覆盖版本的 Json 和 Jar 文件,但不会影响版本隔离的文件。", "版本已存在", "继续", "取消") = 1 Then - File.Delete(VersionFolder & Id & ".jar") - File.Delete(VersionFolder & Id & ".json") - Else - Exit Sub - End If - End If - - '启动 - Dim Loader As New LoaderCombo(Of String)(DisplayName & " 下载", McDownloadNeoForgeLoader(DownloadInfo.VersionName, DownloadInfo.Inherit, DownloadInfo)) With {.OnStateChanged = AddressOf McInstallState} - Loader.Start(VersionFolder) - LoaderTaskbarAdd(Loader) - FrmMain.BtnExtraDownload.ShowRefresh() - FrmMain.BtnExtraDownload.Ribble() - - Catch ex As Exception - Log(ex, "开始 NeoForge 下载失败", LogLevel.Feedback) - Finally - '删除安装包 - Try - If File.Exists(Target) Then File.Delete(Target) - Catch - End Try - End Try - End Sub - Public Sub McDownloadNeoForgeSave(DownloadInfo As DlNeoForgeVersionEntry) - Try - Dim Target As String = SelectAs("选择保存位置", DownloadInfo.FileName, "NeoForge 文件 (*.jar)") - Dim DisplayName As String = "NeoForge " & DownloadInfo.Inherit & " - " & DownloadInfo.VersionName - If Not Target.Contains("\") Then Exit Sub - - '重复任务检查 - SyncLock LoaderTaskbarLock - For i = 0 To LoaderTaskbar.Count - 1 - If LoaderTaskbar(i).Name = DisplayName & " 下载" Then - Hint("该版本正在下载中!", HintType.Critical) - Exit Sub - End If - Next - End SyncLock - - '构造步骤加载器 - Dim Loaders As New List(Of LoaderBase) - '获取下载地址 - Loaders.Add(New LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))("获取下载地址", - Sub(Task As LoaderTask(Of DlNeoForgeVersionEntry, List(Of NetFile))) - Dim Files As New List(Of NetFile) - If DownloadInfo.VersionCode.StartsWith("47.") Then '1.20.1 NeoForge 下载地址不同 - Files.Add(New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/forge/" & "1.20.1-" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName - }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) - Else - Files.Add(New NetFile({ - "https://bmclapi2.bangbang93.com/maven/net/neoforged/neoforge/" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName, - "https://maven.neoforged.net/releases/net/neoforged/neoforge/" & DownloadInfo.VersionCode & If(DownloadInfo.IsBeta, "-beta", "") & "/" & DownloadInfo.FileName - }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) - End If - Task.Output = Files - End Sub) With {.ProgressWeight = 0.1, .Show = False}) - '下载 - Loaders.Add(New LoaderDownload("下载主文件", New List(Of NetFile)) With {.ProgressWeight = 6}) - - '启动 - Dim Loader As New LoaderCombo(Of DlNeoForgeVersionEntry)(DisplayName & " 下载", Loaders) With {.OnStateChanged = AddressOf DownloadStateSave} - Loader.Start(DownloadInfo) - LoaderTaskbarAdd(Loader) - FrmMain.BtnExtraDownload.ShowRefresh() - FrmMain.BtnExtraDownload.Ribble() - - Catch ex As Exception - Log(ex, "开始 NeoForge 下载失败", LogLevel.Feedback) - End Try - End Sub - - Private Sub NeoForgeInjector(Target As String, Task As LoaderTask(Of Boolean, Boolean), McFolder As String, UseJavaWrapper As Boolean) - '选择 Java - Dim Java As JavaEntry - SyncLock JavaLock - Java = JavaSelect("已取消安装。", New Version(1, 8, 0, 60)) - If Java Is Nothing Then - If Not JavaDownloadConfirm("Java 8 或更高版本") Then Throw New Exception("由于未找到 Java,已取消安装。") - '开始自动下载 - Dim JavaLoader = JavaFixLoaders(17) - Try - JavaLoader.Start(17, IsForceRestart:=True) - Do While JavaLoader.State = LoadState.Loading AndAlso Not Task.IsAborted - Thread.Sleep(10) - Loop - Finally - JavaLoader.Abort() '确保取消时中止 Java 下载 - End Try - '检查下载结果 - Java = JavaSelect("已取消安装。", New Version(1, 8, 0, 60)) - If Task.IsAborted Then Exit Sub - If Java Is Nothing Then Throw New Exception("由于未找到 Java,已取消安装。") - End If - End SyncLock - '添加 Java Wrapper 作为主 Jar - Dim Arguments As String - If UseJavaWrapper Then - Arguments = $"-Doolloo.jlw.tmpdir=""{GetJavaWrapperDir()}"" -cp ""{PathTemp}Cache\neoforge_installer.jar;{Target}"" -jar ""{ExtractJavaWrapper()}"" com.bangbang93.ForgeInstaller ""{McFolder}" - Else - Arguments = $"-cp ""{PathTemp}Cache\neoforge_installer.jar;{Target}"" com.bangbang93.ForgeInstaller ""{McFolder}" - End If - If Java.VersionCode >= 9 Then Arguments = "--add-exports cpw.mods.bootstraplauncher/cpw.mods.bootstraplauncher=ALL-UNNAMED " & Arguments - '开始启动 - SyncLock InstallSyncLock - Dim Info = New ProcessStartInfo With { - .FileName = Java.PathJavaw, - .Arguments = Arguments, - .UseShellExecute = False, - .CreateNoWindow = True, - .RedirectStandardError = True, - .RedirectStandardOutput = True - } - Log("[Download] 开始安装 NeoForge:" & Arguments) - Dim process As New Process With {.StartInfo = Info} - Dim LastResults As New Queue(Of String) - Using outputWaitHandle As New AutoResetEvent(False) - Using errorWaitHandle As New AutoResetEvent(False) - AddHandler process.OutputDataReceived, - Function(sender, e) - Try - If e.Data Is Nothing Then - outputWaitHandle.[Set]() - Else - LastResults.Enqueue(e.Data) - If LastResults.Count > 100 Then LastResults.Dequeue() - NeoForgeInjectorLine(e.Data, Task) - End If - Catch ex As ObjectDisposedException - Catch ex As Exception - Log(ex, "读取 NeoForge 安装器信息失败") - End Try - Try - If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then - Log("[Installer] 由于任务取消,已中止 NeoForge 安装") - process.Kill() - End If - Catch - End Try - Return Nothing - End Function - AddHandler process.ErrorDataReceived, - Function(sender, e) - Try - If e.Data Is Nothing Then - errorWaitHandle.[Set]() - Else - LastResults.Enqueue(e.Data) - If LastResults.Count > 100 Then LastResults.Dequeue() - NeoForgeInjectorLine(e.Data, Task) - End If - Catch ex As ObjectDisposedException - Catch ex As Exception - Log(ex, "读取 NeoForge 安装器错误信息失败") - End Try - Try - If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then - Log("[Installer] 由于任务取消,已中止 NeoForge 安装") - process.Kill() - End If - Catch - End Try - Return Nothing - End Function - process.Start() - process.BeginOutputReadLine() - process.BeginErrorReadLine() - '等待 - Do Until process.HasExited - Thread.Sleep(10) - Loop - '输出 - outputWaitHandle.WaitOne(10000) - errorWaitHandle.WaitOne(10000) - process.Dispose() - '检查是否安装成功:最后两行中是否有 true(true 可能在倒数第二行,见 #832) - If LastResults.Last = "true" OrElse (LastResults.Count >= 2 AndAlso LastResults(LastResults.Count - 2) = "true") Then Exit Sub - Log(Join(LastResults, vbCrLf)) - Dim LastLines As String = "" - For i As Integer = Math.Max(0, LastResults.Count - 5) To LastResults.Count - 1 '最后 5 行 - LastLines &= vbCrLf & LastResults(i) - Next - Throw New Exception("NeoForge 安装器出错,日志结束部分为:" & LastLines) - End Using - End Using - End SyncLock - End Sub - Private Sub NeoForgeInjectorLine(Content As String, Task As LoaderTask(Of Boolean, Boolean)) - If Content.StartsWithF(" Data") OrElse Content.StartsWithF(" Slim") Then - If ModeDebug Then Log("[Installer] " & Content) - ElseIf Content.StartsWithF(" Reading patch ") Then - If ModeDebug Then Log("[Installer] " & Content) - Task.Progress = 0.86 - Else - Select Case Content - Case "Extracting json" - Log("[Installer] " & Content) - Task.Progress = 0.07 - Case "Downloading libraries" - Log("[Installer] " & Content) - Task.Progress = 0.08 - Case " File exists: Checksum validated." - If ModeDebug Then Log("[Installer] " & Content) - Task.Progress += 0.003 - Case "Building Processors" - Task.Progress = 0.38 - Case "Task: DOWNLOAD_MOJMAPS" 'B - Task.Progress = 0.4 - Case "Task: MERGE_MAPPING" 'B - Task.Progress = 0.6 - Case "Splitting: " - Task.Progress = 0.62 - Case "Parameter Annotations" 'B - Task.Progress = 0.66 - Case "Processing Complete" 'B - Task.Progress = 0.7 - Case "Remapping final jar" 'A - Task.Progress = 0.72 - Case "Remapping jar... 50%" 'A - Task.Progress = 0.76 - Case "Remapping jar... 100%" 'A - Task.Progress = 0.81 - Case "Injecting profile" - Task.Progress = 0.91 - Case Else - If ModeDebug Then Log("[Installer] " & Content) - Exit Sub - End Select - Log("[Installer] " & Content) - End If - End Sub - - ''' - ''' 获取下载某个 NeoForge 版本的加载器列表。 - ''' - Private Function McDownloadNeoForgeLoader(Version As String, Inherit As String, Optional DownloadRawInfo As DlNeoForgeVersionEntry = Nothing, Optional McFolder As String = Nothing, Optional ClientDownloadLoader As LoaderCombo(Of String) = Nothing, Optional ClientFolder As String = Nothing, Optional FixLibrary As Boolean = True) As List(Of LoaderBase) - - '参数初始化 - Dim DownloadInfo As New DlNeoForgeVersionEntry - McFolder = If(McFolder, PathMcFolder) - If DownloadRawInfo Is Nothing Then '兜底,有的时候 DownloadInfo 可能是空的 - If Version.Contains("-beta") Then - DownloadInfo.VersionName = Version - Version = Version.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") - DownloadInfo.VersionCode = Version - DownloadInfo.IsBeta = True - Else - DownloadInfo.VersionName = Version - Version = Version.Replace("neoforge-", "").Replace("1.20.1-", "") - DownloadInfo.VersionCode = Version - DownloadInfo.IsBeta = False - End If - Else - DownloadInfo = DownloadRawInfo - Version = DownloadInfo.VersionCode - End If - Dim IsCustomFolder As Boolean = McFolder <> PathMcFolder - Dim Id As String = DownloadInfo.VersionName - Dim InstallerAddress As String = PathTemp & "Cache\Code\NeoForgeInstall-" & Version & "_" & RandomInteger(0, 100000) - Dim VersionFolder As String = McFolder & "versions\" & Id & "\" - Dim DisplayName As String = "NeoForge " & Inherit & " - " & Version - Dim Loaders As New List(Of LoaderBase) - Dim LibVersionFolder As String = PathMcFolder & "versions\" & Id & "\" '作为 Lib 文件目标的版本文件夹 - - '获取下载信息 - If DownloadInfo Is Nothing Then - Loaders.Add(New LoaderTask(Of String, String)("获取 NeoForge 详细信息", - Sub(Task As LoaderTask(Of String, String)) - '获取 NeoForge 版本列表 - Dim NeoForgeLoader = New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("McDownloadNeoForgeLoader " & Inherit, AddressOf DlNeoForgeVersionMain) - NeoForgeLoader.WaitForExit(Inherit) - Task.Progress = 0.8 - '查找对应版本 - For Each NeoForgeVersion In NeoForgeLoader.Output - If NeoForgeVersion.VersionName = Version Then - DownloadInfo = NeoForgeVersion - Exit Sub - End If - Next - Throw New Exception("未能找到 NeoForge " & Inherit & "-" & Version & " 的详细信息!") - End Sub) With {.ProgressWeight = 3}) - End If - '下载 NeoForge 主文件 - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("准备下载 NeoForge", - Sub(Task As LoaderTask(Of String, List(Of NetFile))) - '启动依赖版本的下载 - If ClientDownloadLoader Is Nothing Then - If IsCustomFolder Then Throw New Exception("如果没有指定原版下载器,则不能指定 MC 安装文件夹") - ClientDownloadLoader = McDownloadClient(NetPreDownloadBehaviour.ExitWhileExistsOrDownloading, Inherit) - End If - Dim IsLegacyNeo As Boolean = DownloadInfo.VersionCode.StartsWith("47.") - Dim Files As New List(Of NetFile) From {New NetFile({ - $"https://bmclapi2.bangbang93.com/maven/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}", - $"https://maven.neoforged.net/releases/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}" - }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} - Task.Output = Files - End Sub) With {.ProgressWeight = 0.5, .Show = False}) - Loaders.Add(New LoaderDownload("下载 NeoForge 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) - - '安装(需要原版 Jar) - Log("[Download] 检测到的 NeoForge 版本:" & Version) - Dim Libs As List(Of McLibToken) = Nothing - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))("分析 NeoForge 支持库文件", - Sub(Task As LoaderTask(Of String, List(Of NetFile))) - Task.Output = New List(Of NetFile) - Dim Installer As ZipArchive = Nothing - Try - '解压并获取、合并两个 Json 的信息 - Installer = New ZipArchive(New FileStream(InstallerAddress, FileMode.Open)) - Task.Progress = 0.2 - Dim Json As JObject = GetJson(ReadFile(Installer.GetEntry("install_profile.json").Open)) - Dim Json2 As JObject = GetJson(ReadFile(Installer.GetEntry("version.json").Open)) - Json.Merge(Json2) - '获取 Lib 下载信息 - Libs = McLibListGetWithJson(Json, True) - '添加 Mappings 下载信息 - If Json("data") IsNot Nothing AndAlso Json("data")("MOJMAPS") IsNot Nothing Then - '下载原版 Json 文件 - Task.Progress = 0.4 - Dim RawJson As JObject = GetJson(NetGetCodeByDownload(DlSourceLauncherOrMetaGet(DlClientListGet(Inherit)), IsJson:=True)) - '[net.minecraft:client:1.17.1-20210706.113038:mappings@txt] 或 @tsrg] - Dim OriginalName As String = Json("data")("MOJMAPS")("client").ToString.Trim("[]".ToCharArray()).Before("@") - Dim Address = McLibGet(OriginalName).Replace(".jar", "-mappings." & Json("data")("MOJMAPS")("client").ToString.Trim("[]".ToCharArray()).Split("@")(1)) - Libs.Add(New McLibToken With {.IsJumpLoader = False, .IsNatives = False, .LocalPath = Address, .OriginalName = OriginalName, - .Url = RawJson("downloads")("client_mappings")("url"), .Size = RawJson("downloads")("client_mappings")("size"), .SHA1 = RawJson("downloads")("client_mappings")("sha1")}) - Log("[Download] 需要下载 Mappings:" & Address) - End If - Task.Progress = 0.8 - '去除其中的原始 NeoForge 项 - For i = 0 To Libs.Count - 1 - If Libs(i).LocalPath.EndsWithF("neoforge-" & Inherit & "-" & Version & ".jar") OrElse - Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & "-client.jar") Then - Log("[Download] 已从待下载 NeoForge 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug) - Libs.RemoveAt(i) - Exit For - End If - Next - Task.Output = McLibFixFromLibToken(Libs, PathMcFolder) - Catch ex As Exception - Throw New Exception("获取 NeoForge 支持库列表失败", ex) - Finally - '释放文件 - If Installer IsNot Nothing Then Installer.Dispose() - End Try - End Sub) With {.ProgressWeight = 2}) - Loaders.Add(New LoaderDownload("下载 NeoForge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) - Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)("获取 NeoForge 支持库文件", - Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) -#Region "NeoForge 文件" - If IsCustomFolder Then - For Each LibFile As McLibToken In Libs - Dim RealPath As String = LibFile.LocalPath.Replace(PathMcFolder, McFolder) - If Not File.Exists(RealPath) Then - Directory.CreateDirectory(IO.Path.GetDirectoryName(RealPath)) - CopyFile(LibFile.LocalPath, RealPath) - End If - If ModeDebug Then Log("[Download] 复制的 NeoForge 支持库文件:" & LibFile.LocalPath) - Next - End If -#End Region -#Region "原版文件" - '等待原版文件下载完成 - If ClientDownloadLoader Is Nothing Then Exit Sub - Dim TargetLoaders As List(Of LoaderBase) = - ClientDownloadLoader.GetLoaderList.Where(Function(l) l.Name = McDownloadClientLibName OrElse l.Name = McDownloadClientJsonName). - Where(Function(l) l.State <> LoadState.Finished).ToList - If TargetLoaders.Any Then Log("[Download] NeoForge 安装正在等待原版文件下载完成") - Do While TargetLoaders.Any AndAlso Not Task.IsAborted - TargetLoaders = TargetLoaders.Where(Function(l) l.State <> LoadState.Finished).ToList - Thread.Sleep(50) - Loop - If Task.IsAborted Then Exit Sub - '拷贝原版文件 - If Not IsCustomFolder Then Exit Sub - SyncLock VanillaSyncLock - Dim ClientName As String = GetFolderNameFromPath(ClientFolder) - Directory.CreateDirectory(McFolder & "versions\" & Inherit) - If Not File.Exists(McFolder & "versions\" & Inherit & "\" & Inherit & ".json") Then - CopyFile(ClientFolder & ClientName & ".json", McFolder & "versions\" & Inherit & "\" & Inherit & ".json") - End If - If Not File.Exists(McFolder & "versions\" & Inherit & "\" & Inherit & ".jar") Then - CopyFile(ClientFolder & ClientName & ".jar", McFolder & "versions\" & Inherit & "\" & Inherit & ".jar") - End If - End SyncLock -#End Region - End Sub) With {.ProgressWeight = 0.1, .Show = False}) - Loaders.Add(New LoaderTask(Of Boolean, Boolean)("安装 NeoForge", - Sub(Task As LoaderTask(Of Boolean, Boolean)) - Dim Installer As ZipArchive = Nothing - Try - Log("[Download] 开始进行 NeoForge 安装:" & InstallerAddress) - '记录当前文件夹列表(在新建目标文件夹之前) - Dim OldList = New DirectoryInfo(McFolder & "versions\").EnumerateDirectories. - Select(Function(i) i.FullName).ToList() - '解压并获取信息 - Installer = New ZipArchive(New FileStream(InstallerAddress, FileMode.Open)) - Dim Json As JObject = GetJson(ReadFile(Installer.GetEntry("install_profile.json").Open)) - '新建目标版本文件夹 - Directory.CreateDirectory(VersionFolder) - Task.Progress = 0.04 - '释放 launcher_installer.json - McFolderLauncherProfilesJsonCreate(McFolder) - Task.Progress = 0.05 - '运行 NeoForge 安装器 - Dim UseJavaWrapper As Boolean = True -Retry: - Try - '释放 NeoForge 注入器 - WriteFile(PathTemp & "Cache\neoforge_installer.jar", GetResources("ForgeInstaller")) - Task.Progress = 0.06 - '运行注入器 - NeoForgeInjector(InstallerAddress, Task, McFolder, UseJavaWrapper) - Task.Progress = 0.97 - Catch ex As Exception - If UseJavaWrapper Then - Log(ex, "使用 JavaWrapper 安装 NeoForge 失败,将不使用 JavaWrapper 并重试") - UseJavaWrapper = False - GoTo Retry - Else - Throw New Exception("运行 NeoForge 安装器失败", ex) - End If - End Try - '拷贝新增的版本 Json - Dim DeltaList = New DirectoryInfo(McFolder & "versions\").EnumerateDirectories. - SkipWhile(Function(i) OldList.Contains(i.FullName)).ToList() - If DeltaList.Count > 1 Then - '它可能和 OptiFine 安装同时运行,导致增加的文件不止一个(这导致了 #151) - '也可能是因为 NeoForge 安装器的 Bug,生成了一个名字错误的文件夹,所以需要检查文件夹是否为空 - DeltaList = DeltaList.Where(Function(l) l.Name.Contains("neoforge") AndAlso l.EnumerateFiles.Any).ToList - End If - If DeltaList.Count = 1 Then '如果没有新增文件夹,那么预测的文件夹名就是正确的 - Dim JsonFile As FileInfo = DeltaList(0).EnumerateFiles.First() - WriteFile(VersionFolder & Id & ".json", ReadFile(JsonFile.FullName)) - End If - '新建 mods 文件夹 - Directory.CreateDirectory(New McVersion(VersionFolder).GetPathIndie(True) & "mods\") - Catch ex As Exception - Throw New Exception("安装新 NeoForge 版本失败", ex) - Finally - '清理文件 - Try - If Installer IsNot Nothing Then Installer.Dispose() - If File.Exists(InstallerAddress) Then File.Delete(InstallerAddress) - Catch ex As Exception - Log(ex, "安装 NeoForge 清理文件时出错") - End Try - End Try - End Sub) With {.ProgressWeight = 10}) - - Return Loaders - End Function - -#End Region - #Region "NeoForge 下载菜单" Public Sub NeoForgeDownloadListItemPreload(Stack As StackPanel, Entrys As List(Of DlNeoForgeVersionEntry), OnClick As MyListItem.ClickEventHandler, IsSaveOnly As Boolean) @@ -2270,7 +1830,7 @@ Retry: Else Version = sender.Parent.Parent.Tag End If - McDownloadNeoForgeSave(Version) + McDownloadForgeSave(True, , Version) End Sub #End Region @@ -2642,11 +2202,11 @@ Retry: End If 'Forge If Request.ForgeVersion IsNot Nothing Then - LoaderList.Add(New LoaderCombo(Of String)("下载 Forge " & Request.ForgeVersion, McDownloadForgeLoader(Request.ForgeVersion, Request.MinecraftName, Request.ForgeEntry, TempMcFolder, ClientLoader, Request.TargetVersionFolder, False)) With {.Show = False, .ProgressWeight = 25, .Block = Request.FabricVersion Is Nothing AndAlso Request.LiteLoaderEntry Is Nothing AndAlso Request.NeoForgeEntry Is Nothing}) + LoaderList.Add(New LoaderCombo(Of String)("下载 Forge " & Request.ForgeVersion, McDownloadForgeLoader(False, Request.ForgeVersion, Request.MinecraftName, Request.ForgeEntry, , TempMcFolder, ClientLoader, Request.TargetVersionFolder, False)) With {.Show = False, .ProgressWeight = 25, .Block = Request.FabricVersion Is Nothing AndAlso Request.LiteLoaderEntry Is Nothing AndAlso Request.NeoForgeEntry Is Nothing}) End If 'NeoForge If Request.NeoForgeVersion IsNot Nothing Then - LoaderList.Add(New LoaderCombo(Of String)("下载 NeoForge " & Request.NeoForgeVersion, McDownloadNeoForgeLoader(Request.NeoForgeVersion, Request.MinecraftName, Request.NeoForgeEntry, TempMcFolder, ClientLoader, Request.TargetVersionFolder, False)) With {.Show = False, .ProgressWeight = 25, .Block = Request.ForgeEntry Is Nothing AndAlso Request.FabricVersion Is Nothing AndAlso Request.LiteLoaderEntry Is Nothing}) + LoaderList.Add(New LoaderCombo(Of String)("下载 NeoForge " & Request.NeoForgeVersion, McDownloadForgeLoader(True, Request.NeoForgeVersion, Request.MinecraftName, , Request.NeoForgeEntry, TempMcFolder, ClientLoader, Request.TargetVersionFolder, False)) With {.Show = False, .ProgressWeight = 25, .Block = Request.ForgeEntry Is Nothing AndAlso Request.FabricVersion Is Nothing AndAlso Request.LiteLoaderEntry Is Nothing}) End If 'LiteLoader If Request.LiteLoaderEntry IsNot Nothing Then diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb index b0eabde8..bdd3b017 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadNeoForge.xaml.vb @@ -42,10 +42,10 @@ End If End Sub Private Sub NeoForge_Selected(sender As MyListItem, e As EventArgs) - McDownloadNeoForgeSave(sender.Tag) + McDownloadForgeSave(True, sender.Tag) End Sub Public Sub DownloadStart(sender As MyListItem, e As Object) - McDownloadNeoForge(sender.Tag) + McDownloadForge(True, sender.Tag) End Sub Private Sub BtnWeb_Click(sender As Object, e As EventArgs) Handles BtnWeb.Click OpenWebsite("https://neoforged.net/") From 4dba7c969cb88d41e4e96e56479759ae6b545f60 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Fri, 28 Jun 2024 22:00:01 +0800 Subject: [PATCH 33/36] =?UTF-8?q?chores:=20=E4=BB=A3=E7=A0=81=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7=E5=92=8C=E7=9B=B8=E5=85=B3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/PageDownload/ModDownloadLib.vb | 72 ++++++++++--------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 71ccef52..a90fb771 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1171,7 +1171,8 @@ Retry: .RedirectStandardError = True, .RedirectStandardOutput = True } - Log($"[Download] 开始安装 {If(IsNeoForge, "Neo", "")}Forge:" & Arguments) + Dim LoaderName As String = If(IsNeoForge, "NeoForge", "Forge") + Log($"[Download] 开始安装 {LoaderName}:" & Arguments) Dim process As New Process With {.StartInfo = Info} Dim LastResults As New Queue(Of String) Using outputWaitHandle As New AutoResetEvent(False) @@ -1188,11 +1189,11 @@ Retry: End If Catch ex As ObjectDisposedException Catch ex As Exception - Log(ex, $"读取 {If(IsNeoForge, "Neo", "")}Forge 安装器信息失败") + Log(ex, $"读取 {LoaderName} 安装器信息失败") End Try Try If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then - Log($"[Installer] 由于任务取消,已中止 {If(IsNeoForge, "Neo", "")}Forge 安装") + Log($"[Installer] 由于任务取消,已中止 {LoaderName} 安装") process.Kill() End If Catch @@ -1211,11 +1212,11 @@ Retry: End If Catch ex As ObjectDisposedException Catch ex As Exception - Log(ex, $"读取 {If(IsNeoForge, "Neo", "")}Forge 安装器错误信息失败") + Log(ex, $"读取 {LoaderName} 安装器错误信息失败") End Try Try If Task.State = LoadState.Aborted AndAlso Not process.HasExited Then - Log($"[Installer] 由于任务取消,已中止 {If(IsNeoForge, "Neo", "")}Forge 安装") + Log($"[Installer] 由于任务取消,已中止 {LoaderName} 安装") process.Kill() End If Catch @@ -1240,7 +1241,7 @@ Retry: For i As Integer = Math.Max(0, LastResults.Count - 5) To LastResults.Count - 1 '最后 5 行 LastLines &= vbCrLf & LastResults(i) Next - Throw New Exception($"{If(IsNeoForge, "Neo", "")}Forge 安装器出错,日志结束部分为:" & LastLines) + Throw New Exception($"{LoaderName} 安装器出错,日志结束部分为:" & LastLines) End Using End Using End SyncLock @@ -1297,14 +1298,16 @@ Retry: '参数初始化 Dim DownloadInfo = If(IsNeo, DownloadNeoInfo, DownloadForgeInfo) - If DownloadNeoInfo Is Nothing AndAlso IsNeo Then '兜底,有的时候 DownloadInfo 可能是空的 - DownloadInfo.VersionName = Version - Version = Version.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") - DownloadInfo.VersionCode = Version - If Version.Contains("-beta") Then DownloadInfo.IsBeta = True - ElseIf IsNeo Then - DownloadInfo = DownloadNeoInfo - Version = DownloadInfo.VersionCode + If IsNeo Then '兜底,有的时候 DownloadInfo 可能是空的 + If DownloadNeoInfo Is Nothing Then + DownloadInfo.VersionName = Version + Version = Version.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") + DownloadInfo.VersionCode = Version + If Version.Contains("-beta") Then DownloadInfo.IsBeta = True + Else + DownloadInfo = DownloadNeoInfo + Version = DownloadInfo.VersionCode + End If Else DownloadInfo = DownloadForgeInfo End If @@ -1314,17 +1317,18 @@ Retry: Inherit = Version.Before("-") Version = Version.After("-") End If + Dim LoaderName As String = If(IsNeo, "NeoForge", "Forge") Dim IsCustomFolder As Boolean = McFolder <> PathMcFolder Dim Id As String = If(IsNeo, DownloadInfo.VersionName, Inherit & "-forge-" & Version) - Dim InstallerAddress As String = PathTemp & $"Cache\Code\{If(IsNeo, "Neo", "")}ForgeInstall-" & Version & "_" & RandomInteger(0, 100000) + Dim InstallerAddress As String = PathTemp & $"Cache\Code\{LoaderName}Install-" & Version & "_" & RandomInteger(0, 100000) Dim VersionFolder As String = McFolder & "versions\" & Id & "\" - Dim DisplayName As String = $"{If(IsNeo, "Neo", "")}Forge " & Inherit & " - " & Version + Dim DisplayName As String = $"{LoaderName} " & Inherit & " - " & Version Dim Loaders As New List(Of LoaderBase) Dim LibVersionFolder As String = PathMcFolder & "versions\" & Id & "\" '作为 Lib 文件目标的版本文件夹 '获取下载信息 If DownloadInfo Is Nothing Then - Loaders.Add(New LoaderTask(Of String, String)($"获取 {If(IsNeo, "Neo", "")}Forge 详细信息", + Loaders.Add(New LoaderTask(Of String, String)($"获取 {LoaderName} 详细信息", Sub(Task As LoaderTask(Of String, String)) '获取 Forge / NeoForge 版本列表 Dim ForgeLoader = If(IsNeo, New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlNeoForgeVersionMain), New LoaderTask(Of String, List(Of DlForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlForgeVersionMain)) @@ -1337,11 +1341,11 @@ Retry: Exit Sub End If Next - Throw New Exception($"未能找到 {If(IsNeo, "Neo", "")}Forge " & Inherit & "-" & Version & " 的详细信息!") + Throw New Exception($"未能找到 {LoaderName} " & Inherit & "-" & Version & " 的详细信息!") End Sub) With {.ProgressWeight = 3}) End If '下载 Forge / NeoForge 主文件 - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"准备下载 {If(IsNeo, "Neo", "")}Forge", + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"准备下载 {LoaderName}", Sub(Task As LoaderTask(Of String, List(Of NetFile))) '启动依赖版本的下载 If ClientDownloadLoader Is Nothing Then @@ -1364,13 +1368,13 @@ Retry: End If Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) - Loaders.Add(New LoaderDownload($"下载 {If(IsNeo, "Neo", "")}Forge 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) + Loaders.Add(New LoaderDownload($"下载 {LoaderName} 主文件", New List(Of NetFile)) With {.ProgressWeight = 9}) '安装(仅在新版安装时需要原版 Jar) If Version.Before(".") >= 20 Then Log($"[Download] 检测为{If(IsNeo, " Neo", "新版 ")}Forge:" & Version) Dim Libs As List(Of McLibToken) = Nothing - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"分析 {If(IsNeo, "Neo", "")}Forge 支持库文件", + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"分析 {LoaderName} 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = New List(Of NetFile) Dim Installer As ZipArchive = Nothing @@ -1400,7 +1404,7 @@ Retry: For i = 0 To Libs.Count - 1 If Libs(i).LocalPath.EndsWithF($"{If(IsNeo, "neo", "")}forge-" & Inherit & "-" & Version & ".jar") OrElse Libs(i).LocalPath.EndsWithF("forge-" & Inherit & "-" & Version & "-client.jar") Then - Log($"[Download] 已从待下载 {If(IsNeo, "Neo", "")}Forge 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug) + Log($"[Download] 已从待下载 {LoaderName} 支持库中移除:" & Libs(i).LocalPath, LogLevel.Debug) Libs.RemoveAt(i) Exit For End If @@ -1413,8 +1417,8 @@ Retry: If Installer IsNot Nothing Then Installer.Dispose() End Try End Sub) With {.ProgressWeight = 2}) - Loaders.Add(New LoaderDownload($"下载 {If(IsNeo, "Neo", "")}Forge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) - Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)($"获取 {If(IsNeo, "Neo", "")}Forge 支持库文件", + Loaders.Add(New LoaderDownload($"下载 {LoaderName} 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 12}) + Loaders.Add(New LoaderTask(Of List(Of NetFile), Boolean)($"获取 {LoaderName} 支持库文件", Sub(Task As LoaderTask(Of List(Of NetFile), Boolean)) #Region "Forge / NeoForge 文件" If IsCustomFolder Then @@ -1424,7 +1428,7 @@ Retry: Directory.CreateDirectory(IO.Path.GetDirectoryName(RealPath)) CopyFile(LibFile.LocalPath, RealPath) End If - If ModeDebug Then Log($"[Download] 复制的 {If(IsNeo, "Neo", "")}Forge 支持库文件:" & LibFile.LocalPath) + If ModeDebug Then Log($"[Download] 复制的 {LoaderName} 支持库文件:" & LibFile.LocalPath) Next End If #End Region @@ -1434,7 +1438,7 @@ Retry: Dim TargetLoaders As List(Of LoaderBase) = ClientDownloadLoader.GetLoaderList.Where(Function(l) l.Name = McDownloadClientLibName OrElse l.Name = McDownloadClientJsonName). Where(Function(l) l.State <> LoadState.Finished).ToList - If TargetLoaders.Any Then Log($"[Download] {If(IsNeo, "Neo", "")}Forge 安装正在等待原版文件下载完成") + If TargetLoaders.Any Then Log($"[Download] {LoaderName} 安装正在等待原版文件下载完成") Do While TargetLoaders.Any AndAlso Not Task.IsAborted TargetLoaders = TargetLoaders.Where(Function(l) l.State <> LoadState.Finished).ToList Thread.Sleep(50) @@ -1483,11 +1487,11 @@ Retry: Task.Progress = 0.97 Catch ex As Exception If UseJavaWrapper Then - Log(ex, $"使用 JavaWrapper 安装 {If(IsNeo, "Neo", "")}Forge 失败,将不使用 JavaWrapper 并重试") + Log(ex, $"使用 JavaWrapper 安装 {LoaderName} 失败,将不使用 JavaWrapper 并重试") UseJavaWrapper = False GoTo Retry Else - Throw New Exception($"运行 {If(IsNeo, "Neo", "")}Forge 安装器失败", ex) + Throw New Exception($"运行 {LoaderName} 安装器失败", ex) End If End Try '拷贝新增的版本 Json @@ -1505,14 +1509,14 @@ Retry: '新建 mods 文件夹 Directory.CreateDirectory(New McVersion(VersionFolder).GetPathIndie(True) & "mods\") Catch ex As Exception - Throw New Exception($"安装新 {If(IsNeo, "Neo", "")}Forge 版本失败", ex) + Throw New Exception($"安装新 {LoaderName} 版本失败", ex) Finally '清理文件 Try If Installer IsNot Nothing Then Installer.Dispose() If File.Exists(InstallerAddress) Then File.Delete(InstallerAddress) Catch ex As Exception - Log(ex, $"安装 {If(IsNeo, "Neo", "")}Forge 清理文件时出错") + Log(ex, $"安装 {LoaderName} 清理文件时出错") End Try End Try End Sub) With {.ProgressWeight = 10}) @@ -1573,8 +1577,8 @@ Retry: End Sub) With {.ProgressWeight = 1}) If FixLibrary Then If IsCustomFolder Then Throw New Exception("若需要补全支持库,就不能自定义 MC 文件夹") - Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"分析 {If(IsNeo, "Neo", "")}Forge 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(VersionFolder))) With {.ProgressWeight = 1, .Show = False}) - Loaders.Add(New LoaderDownload($"下载 {If(IsNeo, "Neo", "")}Forge 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 11}) + Loaders.Add(New LoaderTask(Of String, List(Of NetFile))($"分析 {LoaderName} 支持库文件", Sub(Task As LoaderTask(Of String, List(Of NetFile))) Task.Output = McLibFix(New McVersion(VersionFolder))) With {.ProgressWeight = 1, .Show = False}) + Loaders.Add(New LoaderDownload($"下载 {LoaderName} 支持库文件", New List(Of NetFile)) With {.ProgressWeight = 11}) End If End If @@ -1673,7 +1677,7 @@ Retry: Else Version = sender.Parent.Parent.Tag End If - McDownloadForgeSave(False, Version) + McDownloadForgeSave(False, DownloadForgeInfo:=Version) End Sub #End Region @@ -1830,7 +1834,7 @@ Retry: Else Version = sender.Parent.Parent.Tag End If - McDownloadForgeSave(True, , Version) + McDownloadForgeSave(True, DownloadNeoInfo:=Version) End Sub #End Region From 3c44a55b37f23866cda59513983d92e1739112f0 Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 30 Jun 2024 15:01:06 +0800 Subject: [PATCH 34/36] =?UTF-8?q?refactor:=20NeoForge=20BMCLAPI=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=88=97=E8=A1=A8=EF=BC=88=E7=88=B1=E6=9D=A5?= =?UTF-8?q?=E8=87=AA=20bangbang93=EF=BC=89=20fix:=20=E5=AE=89=E8=A3=85=20N?= =?UTF-8?q?eoForge=20=E6=95=B4=E5=90=88=E5=8C=85=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=20chores:=20=E5=9C=A8=E4=BD=8E=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=88<=3D1.19=EF=BC=89=E7=9A=84=E8=87=AA=E5=8A=A8=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E7=95=8C=E9=9D=A2=E5=B0=86=E4=B8=8D=E4=BC=9A=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=20NeoForge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 43 +++++++++++-------- .../Pages/PageDownload/ModDownloadLib.vb | 2 +- .../PageDownload/PageDownloadInstall.xaml.vb | 30 +++++++------ 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index eeb04889..5bc31314 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -802,24 +802,33 @@ ''' Public DlNeoForgeListBmclapiLoader As New LoaderTask(Of Integer, DlNeoForgeListResult)("DlNeoForgeList Bmclapi", AddressOf DlNeoForgeListBmclapiMain) Private Sub DlNeoForgeListBmclapiMain(Loader As LoaderTask(Of Integer, DlNeoForgeListResult)) - Dim Versions As New List(Of String) - Dim ClientVersions As JArray = DlClientListLoader.Output.Value("versions") 'BMCLAPI 不能返回所有 NeoForge 版本,获取 MC 版本列表进行遍历 - Dim ClientReleases As New List(Of String) - - For Each Client In ClientVersions '排除快照版或远古版等特殊版本 - If RegexCheck(Client("id").ToString(), "[0,9.]+") Then - ClientReleases.Add(Client("id").ToString()) - End If - Next - - For Each Release In ClientReleases - If Int(Release.Split(".")(1)) <= 19 Then Continue For '如果游戏版本低于 1.20 就不进行请求 - Dim Json As String = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/neoforge/list/" & Release) - If Not Json.Contains("[]") Then '如果这个版本不支持 NeoForge,BMCLAPI 会直接返回一个空的 Json 序列,这里直接用字符串处理了 - Versions.Add(Release) + Dim ResultLatest As String + Dim VersionsJArray As JArray + Try + ResultLatest = NetGetCodeByDownload("https://bmclapi2.bangbang93.com/neoforge/meta/api/maven/details/releases/net/neoforged/neoforge", UseBrowserUserAgent:=True, IsJson:=True) + Catch ex As Exception + If GetExceptionSummary(ex).Contains("(404)") Then + Throw New Exception("没有可用版本") + Else + Throw End If - Next - + End Try + If ResultLatest.Length < 50 Then Throw New Exception("获取到的版本列表长度不足(" & ResultLatest & ")") + VersionsJArray = GetJson(ResultLatest)("name") + Dim Versions As New List(Of String) + Versions.Add("1.20.1") + Try + For Each Token As String In VersionsJArray("name") + Dim Version As String = Token.Replace("neoforge-", "") + Dim Inherit As String = $"1.{Version.Split(".")(0)}.{Token.Split(".")(1)}" + If Inherit.EndsWith(".0") Then Inherit = Inherit.Replace(".0", "") + Versions.Add(Inherit) + Next + Versions = Versions.Distinct().ToList() + Catch ex As Exception + Log(ex, LogLevel.Feedback) + End Try + If Not Versions.Any() Then Throw New Exception("没有可用版本") Loader.Output = New DlNeoForgeListResult With {.IsOfficial = False, .SourceName = "BMCLAPI", .Value = Versions} End Sub #End Region diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index a90fb771..7d87ce39 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1300,7 +1300,7 @@ Retry: Dim DownloadInfo = If(IsNeo, DownloadNeoInfo, DownloadForgeInfo) If IsNeo Then '兜底,有的时候 DownloadInfo 可能是空的 If DownloadNeoInfo Is Nothing Then - DownloadInfo.VersionName = Version + DownloadInfo = New DlNeoForgeVersionEntry With {.VersionName = Version} Version = Version.Replace("neoforge-", "").Replace("-beta", "").Replace("1.20.1-", "") DownloadInfo.VersionCode = Version If Version.Contains("-beta") Then DownloadInfo.IsBeta = True diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index 1adeb061..687c827a 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -372,20 +372,24 @@ LabForge.Foreground = ColorGray1 End If 'NeoForge - Dim NeoForgeError As String = LoadNeoForgeGetError() - CardNeoForge.MainSwap.Visibility = If(NeoForgeError Is Nothing, Visibility.Visible, Visibility.Collapsed) - If NeoForgeError IsNot Nothing Then CardNeoForge.IsSwaped = True - SetNeoForgeInfoShow(CardNeoForge.IsSwaped) - If SelectedNeoForge Is Nothing Then - BtnNeoForgeClear.Visibility = Visibility.Collapsed - ImgNeoForge.Visibility = Visibility.Collapsed - LabNeoForge.Text = If(NeoForgeError, "点击选择") - LabNeoForge.Foreground = ColorGray4 + If Not SelectedMinecraftId.Contains("1.") OrElse Val(SelectedMinecraftId.Split(".")(1)) <= 19 Then + CardNeoForge.Visibility = Visibility.Collapsed Else - BtnNeoForgeClear.Visibility = Visibility.Visible - ImgNeoForge.Visibility = Visibility.Visible - LabNeoForge.Text = SelectedNeoForge.VersionCode & If(SelectedNeoForge.IsBeta, "-beta", "") - LabNeoForge.Foreground = ColorGray1 + Dim NeoForgeError As String = LoadNeoForgeGetError() + CardNeoForge.MainSwap.Visibility = If(NeoForgeError Is Nothing, Visibility.Visible, Visibility.Collapsed) + If NeoForgeError IsNot Nothing Then CardNeoForge.IsSwaped = True + SetNeoForgeInfoShow(CardNeoForge.IsSwaped) + If SelectedNeoForge Is Nothing Then + BtnNeoForgeClear.Visibility = Visibility.Collapsed + ImgNeoForge.Visibility = Visibility.Collapsed + LabNeoForge.Text = If(NeoForgeError, "点击选择") + LabNeoForge.Foreground = ColorGray4 + Else + BtnNeoForgeClear.Visibility = Visibility.Visible + ImgNeoForge.Visibility = Visibility.Visible + LabNeoForge.Text = SelectedNeoForge.VersionCode & If(SelectedNeoForge.IsBeta, "-beta", "") + LabNeoForge.Foreground = ColorGray1 + End If End If 'Fabric If SelectedMinecraftId.Contains("1.") AndAlso Val(SelectedMinecraftId.Split(".")(1)) <= 13 Then From bec5ddd833a09a8eb8763d85884fc94706ac287a Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 30 Jun 2024 17:19:34 +0800 Subject: [PATCH 35/36] =?UTF-8?q?chores:=20=E4=BB=A3=E7=A0=81=E6=B8=85?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/Minecraft/ModDownload.vb | 22 +------------------ .../Modules/Minecraft/ModMinecraft.vb | 8 +++---- .../Modules/Minecraft/ModModpack.vb | 5 +---- .../Pages/PageDownload/ModDownloadLib.vb | 13 +++++------ 4 files changed, 11 insertions(+), 37 deletions(-) diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb index 5bc31314..9f454a96 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb @@ -841,22 +841,10 @@ ''' Public VersionName As String ''' - ''' 对应的 Minecraft 版本,如“1.12.2”。 + ''' 对应的 Minecraft 版本,如“1.20.4”。 ''' Public Inherit As String ''' - ''' 发布时间,格式为“yyyy/MM/dd HH:mm”。 - ''' - Public ReleaseTime As String - ''' - ''' 文件的 MD5 或 SHA1(BMCLAPI 的老版本是 MD5,新版本是 SHA1;官方源总是 MD5)。 - ''' - Public Hash As String = Nothing - ''' - ''' 版本分支。若无分支则为 Nothing。 - ''' - Public Branch As String = Nothing - ''' ''' 是否是 Beta 版。若未提供则默认为 False。 ''' Public IsBeta As Boolean = False @@ -879,14 +867,6 @@ Public Value As JObject End Structure ''' - ''' 用于下载的文件版本名。可能在 Version 的基础上添加了分支。 - ''' - Public ReadOnly Property FileVersion As String - Get - Return VersionName & If(Branch Is Nothing, "", "-" & Branch) - End Get - End Property - ''' ''' 即将下载的文件全名。 ''' Public ReadOnly Property FileName As String diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb index 676d5b10..64ffbe89 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb @@ -1208,10 +1208,10 @@ OnLoaded: .McCodeSub = ReadIni(Version.Path & "PCL\Setup.ini", "VersionOriginalSub", -1), .IsApiLoaded = True } - VersionInfo.HasFabric = VersionInfo.FabricVersion.Count > 1 - VersionInfo.HasForge = VersionInfo.ForgeVersion.Count > 1 - VersionInfo.HasNeoForge = VersionInfo.NeoForgeVersion.Count > 1 - VersionInfo.HasOptiFine = VersionInfo.OptiFineVersion.Count > 1 + VersionInfo.HasFabric = VersionInfo.FabricVersion.Any() + VersionInfo.HasForge = VersionInfo.ForgeVersion.Any() + VersionInfo.HasNeoForge = VersionInfo.NeoForgeVersion.Any() + VersionInfo.HasOptiFine = VersionInfo.OptiFineVersion.Any() Version.Version = VersionInfo End If diff --git a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb index 20ab3fcb..c64aaef8 100644 --- a/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb +++ b/Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb @@ -388,10 +388,7 @@ Retry: Case "forge" 'eg. 14.23.5.2859 / 1.19-41.1.0 ForgeVersion = Entry.Value.ToString Log("[ModPack] 整合包 Forge 版本:" & ForgeVersion) - Case "neoforge" 'eg. 20.6.98-beta - NeoForgeVersion = Entry.Value.ToString - Log("[ModPack] 整合包 NeoForge 版本:" & NeoForgeVersion) - Case "neo-forge" 'eg. 20.6.98-beta / 有些早期的 Modrinth 整合包可能会写成这样,也检测一下 + Case "neoforge", "neo-forge" 'eg. 20.6.98-beta NeoForgeVersion = Entry.Value.ToString Log("[ModPack] 整合包 NeoForge 版本:" & NeoForgeVersion) Case "fabric-loader" 'eg. 0.14.14 diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 7d87ce39..9da7e8b7 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1099,7 +1099,7 @@ Retry: Files.Add(New NetFile({ $"https://bmclapi2.bangbang93.com/maven/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}", $"https://maven.neoforged.net/releases/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}" - }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) + }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=If(IsNeo, Nothing, DownloadInfo.Hash)))) Task.Output = Files End Sub) With {.ProgressWeight = 0.1, .Show = False}) Else @@ -1110,7 +1110,7 @@ Retry: Files.Add(New NetFile({ "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & DownloadInfo.Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName - }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))) + }, Target, New FileChecker(MinSize:=64 * 1024, Hash:=If(IsNeo, Nothing, DownloadInfo.Hash)))) Task.Output = Files End Sub) With {.ProgressWeight = 0.1, .Show = False}) End If @@ -1359,12 +1359,12 @@ Retry: Files = New List(Of NetFile) From {New NetFile({ $"https://bmclapi2.bangbang93.com/maven/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}", $"https://maven.neoforged.net/releases/net/neoforged/{If(IsLegacyNeo, "", "neo")}forge/{If(IsLegacyNeo, "1.20.1-", "")}{DownloadInfo.VersionCode}{If(DownloadInfo.IsBeta, "-beta", "")}/{DownloadInfo.FileName}" - }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} + }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=If(IsNeo, Nothing, DownloadInfo.Hash)))} Else 'Forge Files = New List(Of NetFile) From {New NetFile({ "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" & Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName, "https://files.minecraftforge.net/maven/net/minecraftforge/forge/" & Inherit & "-" & DownloadInfo.FileVersion & "/" & DownloadInfo.FileName - }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=DownloadInfo.Hash))} + }, InstallerAddress, New FileChecker(MinSize:=64 * 1024, Hash:=If(IsNeo, Nothing, DownloadInfo.Hash)))} End If Task.Output = Files End Sub) With {.ProgressWeight = 0.5, .Show = False}) @@ -1777,10 +1777,7 @@ Retry: '建立控件 Dim NewItem As New MyListItem With { .Title = If(Entry.IsBeta, Entry.VersionCode & "-beta", Entry.VersionCode), .SnapsToDevicePixels = True, .Height = 42, .Type = MyListItem.CheckType.Clickable, .Tag = Entry, - .Info = If(Entry.IsBeta, "测试版", "稳定版") & - If(Entry.ReleaseTime = "", - If(ModeDebug, If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), ""), - "发布于 " & Entry.ReleaseTime & If(ModeDebug, If(Entry.Branch Is Nothing, "", ",开发分支:" & Entry.Branch), "")), + .Info = If(Entry.IsBeta, "测试版", "稳定版"), .Logo = PathImage & "Blocks/NeoForge.png" } AddHandler NewItem.Click, OnClick From 7921184a58dfd95e28e8df0f4cad04d486b36f8f Mon Sep 17 00:00:00 2001 From: Pigeon0v0 Date: Sun, 30 Jun 2024 21:05:41 +0800 Subject: [PATCH 36/36] =?UTF-8?q?chores:=20=E4=B8=80=E4=BA=9B=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=92=8C=E5=91=BD=E5=90=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb | 2 +- .../Pages/PageDownload/PageDownloadInstall.xaml.vb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb index 9da7e8b7..2e0d06f5 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/ModDownloadLib.vb @@ -1331,7 +1331,7 @@ Retry: Loaders.Add(New LoaderTask(Of String, String)($"获取 {LoaderName} 详细信息", Sub(Task As LoaderTask(Of String, String)) '获取 Forge / NeoForge 版本列表 - Dim ForgeLoader = If(IsNeo, New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlNeoForgeVersionMain), New LoaderTask(Of String, List(Of DlForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlForgeVersionMain)) + Dim ForgeLoader = If(IsNeo, New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("McDownloadNeoForgeLoader " & Inherit, AddressOf DlNeoForgeVersionMain), New LoaderTask(Of String, List(Of DlForgeVersionEntry))("McDownloadForgeLoader " & Inherit, AddressOf DlForgeVersionMain)) ForgeLoader.WaitForExit(Inherit) Task.Progress = 0.8 '查找对应版本 diff --git a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb index 687c827a..0539f226 100644 --- a/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb +++ b/Plain Craft Launcher 2/Pages/PageDownload/PageDownloadInstall.xaml.vb @@ -75,7 +75,7 @@ End If '启动 NeoForge 加载 - If SelectedMinecraftId.StartsWith("1.") Then + If SelectedMinecraftId.StartsWith("1.") AndAlso Int(SelectedMinecraftId.Split(".")(1)) > 19 Then Dim NeoForgeLoader = New LoaderTask(Of String, List(Of DlNeoForgeVersionEntry))("DlNeoForgeVersion " & SelectedMinecraftId, AddressOf DlNeoForgeVersionMain) LoadNeoForge.State = NeoForgeLoader NeoForgeLoader.Start(SelectedMinecraftId)