Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quilt 支持 #4214

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Plain Craft Launcher 2/Controls/MyCard.vb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
Stack.Children.Add(FabricDownloadListItem(CType(Data, JObject), AddressOf FrmDownloadInstall.Fabric_Selected))
Case 13
Stack.Children.Add(NeoForgeDownloadListItem(Data, AddressOf NeoForgeSave_Click, True))
Case 14
Stack.Children.Add(QuiltDownloadListItem(CType(Data, JObject), AddressOf FrmDownloadInstall.Quilt_Selected))
Case Else
Log("未知的虚拟化种类:" & Type, LogLevel.Feedback)
End Select
Expand Down
1 change: 1 addition & 0 deletions Plain Craft Launcher 2/FormMain.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ Install:
DownloadForge = 6
DownloadNeoForge = 7
DownloadFabric = 8
DownloadQuilt = 10
DownloadLiteLoader = 9
DownloadMod = 11
DownloadPack = 12
Expand Down
Binary file added Plain Craft Launcher 2/Images/Blocks/Quilt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,95 @@

#End Region

#Region "DlQuiltList | Quilt 列表"

Public Structure DlQuiltListResult
''' <summary>
''' 数据来源名称,如“Official”,“BMCLAPI”。
''' </summary>
Public SourceName As String
''' <summary>
''' 是否为官方的实时数据。
''' </summary>
Public IsOfficial As Boolean
''' <summary>
''' 获取到的游戏列表数据。
''' </summary>
Public GameValue As JArray
''' <summary>
''' 获取到的加载器列表数据。
''' </summary>
Public LoaderValue As JArray
''' <summary>
''' 获取到的安装器列表数据。
''' </summary>
Public InstallerValue As JArray
End Structure

''' <summary>
''' Quilt 列表,主加载器。
''' </summary>
Public DlQuiltListLoader As New LoaderTask(Of Integer, DlQuiltListResult)("DlQuiltList Main", AddressOf DlQuiltListMain)
Private Sub DlQuiltListMain(Loader As LoaderTask(Of Integer, DlQuiltListResult))
Select Case Setup.Get("ToolDownloadVersion")
Case 0
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)) From {
New KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)(DlQuiltListOfficialLoader, 30),
New KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)(DlQuiltListOfficialLoader, 60)
}, Loader.IsForceRestarting)
Case 1
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)) From {
New KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)(DlQuiltListOfficialLoader, 5),
New KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)(DlQuiltListOfficialLoader, 35)
}, Loader.IsForceRestarting)
Case Else
DlSourceLoader(Loader, New List(Of KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)) From {
New KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)(DlQuiltListOfficialLoader, 60),
New KeyValuePair(Of LoaderTask(Of Integer, DlQuiltListResult), Integer)(DlQuiltListOfficialLoader, 60)
}, Loader.IsForceRestarting)
End Select
End Sub

''' <summary>
''' Quilt 列表,官方源。
''' </summary>
Public DlQuiltListOfficialLoader As New LoaderTask(Of Integer, DlQuiltListResult)("DlQuiltList Official", AddressOf DlQuiltListOfficialMain)
Private Sub DlQuiltListOfficialMain(Loader As LoaderTask(Of Integer, DlQuiltListResult))
Dim GameResult As JArray = NetGetCodeByRequestRetry("https://meta.quiltmc.org/v3/versions/game", IsJson:=True)
Dim LoaderResult As JArray = NetGetCodeByRequestRetry("https://meta.quiltmc.org/v3/versions/loader", IsJson:=True)
Dim InstallerResult As JArray = NetGetCodeByRequestRetry("https://meta.quiltmc.org/v3/versions/installer", IsJson:=True)
Pigeon0v0 marked this conversation as resolved.
Show resolved Hide resolved
Try
Dim Output = New DlQuiltListResult With {.IsOfficial = True, .SourceName = "Quilt 官方源", .GameValue = GameResult, .LoaderValue = LoaderResult, .InstallerValue = InstallerResult}
If Output.GameValue.ToString Is Nothing OrElse Output.LoaderValue.ToString Is Nothing OrElse Output.InstallerValue.ToString Is Nothing Then Throw New Exception("获取到的列表缺乏必要项")
Loader.Output = Output
Catch ex As Exception
Throw New Exception("Quilt 官方源版本列表解析失败(" & GameResult.ToString & LoaderResult.ToString & InstallerResult.ToString & ")", ex)
End Try
End Sub

'''' <summary>
'''' Quilt 列表,BMCLAPI。
'''' </summary>
'Public DlQuiltListBmclapiLoader As New LoaderTask(Of Integer, DlQuiltListResult)("DlQuiltList Bmclapi", AddressOf DlQuiltListBmclapiMain)
'Private Sub DlQuiltListBmclapiMain(Loader As LoaderTask(Of Integer, DlQuiltListResult))
' Dim Result As JObject = NetGetCodeByRequestRetry("https://bmclapi2.bangbang93.com/Quilt-meta/v2/versions", IsJson:=True)
' Try
' Dim Output = New DlQuiltListResult With {.IsOfficial = False, .SourceName = "BMCLAPI", .Value = Result}
' If Output.Value("game") Is Nothing OrElse Output.Value("loader") Is Nothing OrElse Output.Value("installer") Is Nothing Then Throw New Exception("获取到的列表缺乏必要项")
' Loader.Output = Output
' Catch ex As Exception
' Throw New Exception("Quilt BMCLAPI 版本列表解析失败(" & Result.ToString & ")", ex)
' End Try
'End Sub

''' <summary>
''' Quilt API 列表,官方源。
''' </summary>
Public DlQSLLoader As New LoaderTask(Of Integer, List(Of CompFile))("Quilt API List Loader",
Sub(Task As LoaderTask(Of Integer, List(Of CompFile))) Task.Output = CompFilesGet("qsl", False))

#End Region

#Region "DlSource | 镜像下载源"

Public Function DlSourceResourceGet(MojangBase As String) As String()
Expand Down
54 changes: 44 additions & 10 deletions Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.vb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,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 Version.HasNeoForge OrElse
Return Version.HasFabric OrElse Version.HasQuilt OrElse Version.HasForge OrElse Version.HasLiteLoader OrElse Version.HasNeoForge OrElse
DisplayType = McVersionCardType.API '#223
End Get
End Property
Expand Down Expand Up @@ -382,12 +382,17 @@ Public Module ModMinecraft
GoTo VersionSearchFinish
End If
'从 Fabric 版本中获取版本号
Regex = RegexSeek(LibrariesString, "(?<=((fabricmc)|(quiltmc)):intermediary:)[^""]*")
Regex = RegexSeek(LibrariesString, "(?<=(fabricmc):intermediary:)[^""]*")
If Regex IsNot Nothing Then
_Version.McName = Regex
GoTo VersionSearchFinish
End If
'从 Quilt 版本中获取版本号
Regex = RegexSeek(LibrariesString, "(?<=(quiltmc):intermediary:)[^""]*")
If Regex IsNot Nothing Then
_Version.McName = Regex
GoTo VersionSearchFinish
End If
'FUTURE: [Quilt 支持] 从 Quilt 版本中获取版本号
'从 jar 项中获取版本号
If JsonObject("jar") IsNot Nothing Then
_Version.McName = JsonObject("jar").ToString
Expand Down Expand Up @@ -723,12 +728,15 @@ Recheck:
State = McVersionState.LiteLoader
Version.HasLiteLoader = True
End If
'Fabric、Forge
'FUTURE: [Quilt 支持] 确认这里的玩意儿对不对
If RealJson.Contains("net.fabricmc:fabric-loader") OrElse RealJson.Contains("org.quiltmc:quilt-loader") Then
'Fabric、Forge、Quilt
If RealJson.Contains("net.fabricmc:fabric-loader") Then
State = McVersionState.Fabric
Version.HasFabric = True
Version.FabricVersion = If(RegexSeek(RealJson, "(?<=(net.fabricmc:fabric-loader:)|(org.quiltmc:quilt-loader:))[0-9\.]+(\+build.[0-9]+)?"), "未知版本").Replace("+build", "")
Version.FabricVersion = If(RegexSeek(RealJson, "(?<=(net.fabricmc:fabric-loader:)[0-9\.]+(\+build.[0-9]+)?"), "未知版本").Replace("+build", "")
ElseIf RealJson.Contains("org.quiltmc:quilt-loader") Then
State = McVersionState.Quilt
Version.HasQuilt = True
Version.QuiltVersion = If(RegexSeek(RealJson, "(?<=(org.quiltmc:quilt-loader:)[0-9\.]+(\+build.[0-9]+)?"), "未知版本").Replace("+build", "")
ElseIf RealJson.Contains("minecraftforge") AndAlso Not RealJson.Contains("net.neoforge") Then
State = McVersionState.Forge
Version.HasForge = True
Expand Down Expand Up @@ -762,6 +770,8 @@ ExitDataLoad:
Logo = PathImage & "Blocks/NeoForge.png"
Case McVersionState.Fabric
Logo = PathImage & "Blocks/Fabric.png"
Case McVersionState.Quilt
Logo = PathImage & "Blocks/Quilt.png"
Case McVersionState.OptiFine
Logo = PathImage & "Blocks/GrassPath.png"
Case McVersionState.LiteLoader
Expand All @@ -788,7 +798,7 @@ ExitDataLoad:
End If
Case McVersionState.Old
Info = "远古版本"
Case McVersionState.Original, McVersionState.Forge, McVersionState.NeoForge, McVersionState.Fabric, McVersionState.OptiFine, McVersionState.LiteLoader
Case McVersionState.Original, McVersionState.Forge, McVersionState.NeoForge, McVersionState.Fabric, McVersionState.Quilt, McVersionState.OptiFine, McVersionState.LiteLoader
Info = Version.ToString
Case McVersionState.Fool
Info = GetMcFoolName(Version.McName)
Expand Down Expand Up @@ -818,6 +828,7 @@ ExitDataLoad:
If State <> McVersionState.Error Then
WriteIni(Path & "PCL\Setup.ini", "ReleaseTime", ReleaseTime.ToString("yyyy'-'MM'-'dd HH':'mm"))
WriteIni(Path & "PCL\Setup.ini", "VersionFabric", Version.FabricVersion)
WriteIni(Path & "PCL\Setup.ini", "VersionQuilt", Version.QuiltVersion)
WriteIni(Path & "PCL\Setup.ini", "VersionOptiFine", Version.OptiFineVersion)
WriteIni(Path & "PCL\Setup.ini", "VersionLiteLoader", Version.HasLiteLoader)
WriteIni(Path & "PCL\Setup.ini", "VersionForge", Version.ForgeVersion)
Expand Down Expand Up @@ -864,6 +875,7 @@ ExitDataLoad:
NeoForge
LiteLoader
Fabric
Quilt
End Enum

''' <summary>
Expand Down Expand Up @@ -935,6 +947,17 @@ ExitDataLoad:
''' </summary>
Public FabricVersion As String = ""

'Quilt

''' <summary>
''' 该版本是否安装了 Quilt。
''' </summary>
Public HasQuilt As Boolean = False
''' <summary>
''' Quilt 版本号,如 0.26.1-beta.1、0.26.0。
''' </summary>
Public QuiltVersion As String = ""

'LiteLoader

''' <summary>
Expand All @@ -952,6 +975,7 @@ ExitDataLoad:
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 HasQuilt Then ToString += ", Quilt" & If(QuiltVersion = "未知版本", "", " " & QuiltVersion)
If HasOptiFine Then ToString += ", OptiFine" & If(OptiFineVersion = "未知版本", "", " " & OptiFineVersion)
If HasLiteLoader Then ToString += ", LiteLoader"
If ToString = "" Then
Expand All @@ -975,7 +999,15 @@ ExitDataLoad:
If SubVersions.Length >= 3 Then
_SortCode = Val(SubVersions(0)) * 10000 + Val(SubVersions(1)) * 100 + Val(SubVersions(2))
Else
Throw New Exception("无效的 Fabric 版本:" & ForgeVersion)
Throw New Exception("无效的 Fabric 版本:" & FabricVersion)
End If
ElseIf HasQuilt Then
If QuiltVersion = "未知版本" Then Return 0
Dim SubVersions = QuiltVersion.Split(".")
If SubVersions.Length >= 3 Then
_SortCode = Val(SubVersions(0)) * 10000 + Val(SubVersions(1)) * 100 + Val(SubVersions(2))
Else
Throw New Exception("无效的 Quilt 版本:" & QuiltVersion)
End If
ElseIf HasForge OrElse HasNeoForge Then
If ForgeVersion = "未知版本" AndAlso NeoForgeVersion = "未知版本" Then Return 0
Expand Down Expand Up @@ -1196,6 +1228,7 @@ OnLoaded:
ReadIni(Version.Path & "PCL\Setup.ini", "VersionOriginal", "Unknown") <> "Unknown" Then '旧版本可能没有这一项,导致 Version 不加载(#643)
Dim VersionInfo As New McVersionInfo With {
.FabricVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionFabric", ""),
.QuiltVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionQuilt", ""),
.ForgeVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionForge", ""),
.NeoForgeVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionNeoForge", ""),
.OptiFineVersion = ReadIni(Version.Path & "PCL\Setup.ini", "VersionOptiFine", ""),
Expand All @@ -1207,6 +1240,7 @@ OnLoaded:
.IsApiLoaded = True
}
VersionInfo.HasFabric = VersionInfo.FabricVersion.Any()
VersionInfo.HasQuilt = VersionInfo.QuiltVersion.Any()
VersionInfo.HasForge = VersionInfo.ForgeVersion.Any()
VersionInfo.HasNeoForge = VersionInfo.NeoForgeVersion.Any()
VersionInfo.HasOptiFine = VersionInfo.OptiFineVersion.Any()
Expand Down Expand Up @@ -1297,7 +1331,7 @@ OnLoaded:
McVersionFilter(VersionList, VersionListOriginal, {McVersionState.Fool}, McVersionCardType.Fool)

'筛选 API 版本
McVersionFilter(VersionList, VersionListOriginal, {McVersionState.Forge, McVersionState.NeoForge, McVersionState.LiteLoader, McVersionState.Fabric}, McVersionCardType.API)
McVersionFilter(VersionList, VersionListOriginal, {McVersionState.Forge, McVersionState.NeoForge, McVersionState.LiteLoader, McVersionState.Fabric, McVersionState.Quilt}, McVersionCardType.API)

'将老版本预先分类入不常用,只剩余原版、快照、OptiFine
Dim VersionUseful As New List(Of McVersion)
Expand Down
Loading