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

NeoForge 支持 #4045

Merged
merged 39 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7ba79db
feat(neoforge): 添加了 NeoForge 的安装选项,并支持获取版本列表
Pigeon0v0 Jun 15, 2024
e731ef6
ui: 显示 NeoForge 版本属性(测试版 / 稳定版)
Pigeon0v0 Jun 15, 2024
8d9dc47
fix: NeoForge 版本列表排序,但是抽象实现
Pigeon0v0 Jun 15, 2024
655364b
fix: 一处逻辑判断错误,但未解决版本判断错误的问题
Pigeon0v0 Jun 15, 2024
65d21d4
Installer 下载和代码清理
Pigeon0v0 Jun 15, 2024
31e391f
optimize: version name and icon
JingHai-Lingyun Jun 15, 2024
d8fe599
fix: 所有版本都显示为测试版 / 正式版
Pigeon0v0 Jun 15, 2024
0e0335e
ui: 添加 NeoForge 手动安装 Tab
Pigeon0v0 Jun 16, 2024
f4b1e3e
feat: 正式支持 NeoForge 自动安装
Pigeon0v0 Jun 16, 2024
27825ed
Update PageDownloadInstall.xaml.vb
JingHai-Lingyun Jun 16, 2024
d305dd3
fix: 版本列表不能正常显示核心 NeoForge 版本
Pigeon0v0 Jun 16, 2024
c31e3b5
Merge branch 'neoforge' into neoforge
Pigeon0v0 Jun 16, 2024
030c498
Merge pull request #2 from JingHai-Lingyun/neoforge
Pigeon0v0 Jun 16, 2024
66182f2
fix: Icon 显示及其导致的崩溃问题
Pigeon0v0 Jun 16, 2024
f3079dd
feat: NeoForge 整合包安装
Pigeon0v0 Jun 16, 2024
9c64dc0
尝试修复 NeoForge 手动安装包列表加载不出的问题,但是失败了
Pigeon0v0 Jun 16, 2024
9dab0b8
改一行注释
Pigeon0v0 Jun 16, 2024
136803f
fix: 回滚修改,修复版本列表问题
Pigeon0v0 Jun 16, 2024
f83afdb
fix: 1.20.1 NeoForge 下载地址拼接可能有误(如果版本为 1.20.1 则硬编码以避免问题)
Pigeon0v0 Jun 21, 2024
e0ae696
chores: 界面文本更改,现在安装的是 NeoForge 还是 Forge 更清晰了
Pigeon0v0 Jun 21, 2024
3bc3416
fix: 1.20.1 NeoForge 安装失败(Json 路径错误)
Pigeon0v0 Jun 21, 2024
7d50ed1
fix: 1.20.1 NeoForge 近期版本无法安装(Json 路径错误)
Pigeon0v0 Jun 21, 2024
70a6b6a
chores: 删除调试用信息
Pigeon0v0 Jun 21, 2024
61ac627
fix: 1.20.1 NeoForge 无法安装(Json 路径拼接错误)
Pigeon0v0 Jun 22, 2024
3f5c292
feat(neoforge): NeoForge 官方源版本列表
Pigeon0v0 Jun 26, 2024
707b6ee
fix: NeoForge 手动安装版本列表不能正常加载(修完了)
Pigeon0v0 Jun 26, 2024
2cfa9b2
feat: NeoForge BMCLAPI 版本列表获取
Pigeon0v0 Jun 26, 2024
ee10caa
fix: NeoForge 官方源不可用
Pigeon0v0 Jun 26, 2024
6efaa09
fix: 官方源总是 Fallback 到 BMCLAPI
Pigeon0v0 Jun 27, 2024
ac6ed8d
chores: Clean up
Pigeon0v0 Jun 27, 2024
1b53489
fix: BMCLAPI 获取支持的 Neo 列表时会意外的包含 1.20
Pigeon0v0 Jun 27, 2024
b61081f
:ok_hand: 修改一些龙猫的审查
youzi-2333 Jun 27, 2024
f98578f
Merge pull request #4 from youzi-2333/pigeon-neoforge
Pigeon0v0 Jun 27, 2024
a54cfef
代码清理
Pigeon0v0 Jun 27, 2024
cf43244
refactor: 合并 Forge 和 NeoForge 部分代码
Pigeon0v0 Jun 28, 2024
4dba7c9
chores: 代码可读性和相关优化
Pigeon0v0 Jun 28, 2024
3c44a55
refactor: NeoForge BMCLAPI 版本列表(爱来自 bangbang93)
Pigeon0v0 Jun 30, 2024
bec5ddd
chores: 代码清理
Pigeon0v0 Jun 30, 2024
7921184
chores: 一些判断和命名修改
Pigeon0v0 Jun 30, 2024
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
13 changes: 13 additions & 0 deletions Plain Craft Launcher 2/Controls/MyCard.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
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 @@ -1019,6 +1019,7 @@ Install:
DownloadClient = 4
DownloadOptiFine = 5
DownloadForge = 6
DownloadNeoForge = 13
DownloadFabric = 7
DownloadLiteLoader = 8
DownloadMod = 10
Expand Down
Binary file added Plain Craft Launcher 2/Images/Blocks/NeoForge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
304 changes: 304 additions & 0 deletions Plain Craft Launcher 2/Modules/Minecraft/ModDownload.vb

Large diffs are not rendered by default.

48 changes: 38 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
Return Version.HasFabric OrElse Version.HasForge OrElse Version.HasLiteLoader OrElse Version.HasNeoForge OrElse
DisplayType = McVersionCardType.API '#223
End Get
End Property
Expand Down Expand Up @@ -345,7 +345,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")
Expand Down Expand Up @@ -729,12 +729,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 '1.20.1 NeoForge Json 内信息不同,为了方便直接截断 orgeVersion;这里的实现比较抽象,正则我写不会
LTCatt marked this conversation as resolved.
Show resolved Hide resolved
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, "(?<=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
Version.IsApiLoaded = True
End Select
Expand All @@ -752,6 +760,8 @@ ExitDataLoad:
Logo = PathImage & "Blocks/CobbleStone.png"
Case McVersionState.Forge
Logo = PathImage & "Blocks/Anvil.png"
Case McVersionState.NeoForge
Logo = PathImage & "Blocks/NeoForge.png"
Case McVersionState.Fabric
Logo = PathImage & "Blocks/Fabric.png"
Case McVersionState.OptiFine
Expand Down Expand Up @@ -780,7 +790,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)
Expand Down Expand Up @@ -813,6 +823,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)
Expand Down Expand Up @@ -852,6 +863,7 @@ ExitDataLoad:
OptiFine
Old
Forge
NeoForge
LiteLoader
Fabric
End Enum
Expand Down Expand Up @@ -903,6 +915,17 @@ ExitDataLoad:
''' </summary>
Public ForgeVersion As String = ""

'NeoForge

''' <summary>
''' 该版本是否安装了 NeoForge。
''' </summary>
Public HasNeoForge As Boolean = False
''' <summary>
''' NeoForge 版本号,如 21.0.2-beta、47.1.79。
''' </summary>
Public NeoForgeVersion As String = ""

'Fabric

''' <summary>
Expand All @@ -929,6 +952,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"
Expand All @@ -955,15 +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)
Throw New Exception(If(HasForge, "无效的 Forge 版本:" & ForgeVersion, "无效的 NeoForge 版本:" & NeoForgeVersion))
End If
ElseIf HasOptiFine Then
If OptiFineVersion = "未知版本" Then Return 0
Expand Down Expand Up @@ -1175,6 +1199,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),
Expand All @@ -1185,6 +1210,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
Pigeon0v0 marked this conversation as resolved.
Show resolved Hide resolved
Version.Version = VersionInfo
End If
Expand Down Expand Up @@ -1273,7 +1299,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)
Expand Down Expand Up @@ -1407,7 +1433,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)
Expand All @@ -1419,6 +1445,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
Expand Down
22 changes: 22 additions & 0 deletions Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -199,6 +200,15 @@ Retry:
Catch ex As Exception
Log(ex, "读取整合包 Forge 版本失败:" & Id)
End Try
ElseIf Id.StartsWithF("neoforge-") Then
'NeoForge 指定
Try
Log("[ModPack] 整合包 NeoForge 版本:" & Id)
NeoForgeVersion = Id.Split("-")(1)
Exit For
Catch ex As Exception
Log(ex, "读取整合包 NeoForge 版本失败:" & Id)
End Try
ElseIf Id.StartsWithF("fabric-") Then
'Fabric 指定
Try
Expand Down Expand Up @@ -301,6 +311,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)
Expand Down Expand Up @@ -368,6 +379,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
Expand All @@ -376,6 +388,12 @@ 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 整合包可能会写成这样,也检测一下
Pigeon0v0 marked this conversation as resolved.
Show resolved Hide resolved
NeoForgeVersion = Entry.Value.ToString
Log("[ModPack] 整合包 NeoForge 版本:" & NeoForgeVersion)
Case "fabric-loader" 'eg. 0.14.14
FabricVersion = Entry.Value.ToString
Log("[ModPack] 整合包 Fabric 版本:" & FabricVersion)
Expand Down Expand Up @@ -447,6 +465,7 @@ Retry:
.TargetVersionFolder = $"{PathMcFolder}versions\{VersionName}\",
.MinecraftName = MinecraftVersion,
.ForgeVersion = ForgeVersion,
.NeoForgeVersion = NeoForgeVersion,
.FabricVersion = FabricVersion
}
Dim MergeLoaders As List(Of LoaderBase) = McInstallLoader(Request, True)
Expand Down Expand Up @@ -676,6 +695,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
Expand Down Expand Up @@ -772,6 +793,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)
Expand Down
1 change: 1 addition & 0 deletions Plain Craft Launcher 2/Modules/ModMain.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading