Skip to content
New issue

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

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

Already on GitHub? # to your account

[Bugfix] Forge launch issue #106

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ProjBobcat/ProjBobcat/Class/Model/MavenInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// Maven包的有关信息。
/// Maven Package Information.
/// </summary>
public class MavenInfo
public record MavenInfo
{
/// <summary>
/// 组织名。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ public override (List<NativeFileInfo>, List<FileInfo>) GetNatives(Library[] libr
// 不同版本的Minecraft有不同的library JSON字符串的结构。
// Different versions of Minecraft have different library JSON's structure.

// Fix for new native format introduced in 1.19
if (lib.Name.Contains("natives", StringComparison.OrdinalIgnoreCase) &&
lib.Downloads?.Artifact != null)
{
result.Item1.Add(new NativeFileInfo
{
Extract = lib.Extract,
FileInfo = lib.Downloads.Artifact
});

continue;
}

var isNative = (lib.Natives?.Count ?? 0) > 0;
if (isNative)
{
Expand Down Expand Up @@ -263,22 +276,20 @@ public override (List<NativeFileInfo>, List<FileInfo>) GetNatives(Library[] libr

if (lib.Downloads?.Artifact != null)
{
if (lib.Downloads.Artifact.Name == null)
{
if (string.IsNullOrEmpty(lib.Downloads.Artifact.Name))
lib.Downloads.Artifact.Name = lib.Name;

if (!result.Item2.Any(l => l.Name!.Equals(lib.Name, StringComparison.OrdinalIgnoreCase)))
result.Item2.Add(lib.Downloads.Artifact);
}

if (!result.Item2.Any(l => l.Name!.Equals(lib.Name, StringComparison.OrdinalIgnoreCase)))
result.Item2.Add(lib.Downloads.Artifact);
}
else
{
if ((lib.Natives?.Count ?? 0) == 0)
if (!result.Item2.Any(l => l.Name!.Equals(lib.Name, StringComparison.OrdinalIgnoreCase)))
result.Item2.Add(new FileInfo
{
Name = lib.Name
});
if ((lib.Natives?.Count ?? 0) != 0) continue;
if (!result.Item2.Any(l => l.Name!.Equals(lib.Name, StringComparison.OrdinalIgnoreCase)))
result.Item2.Add(new FileInfo
{
Name = lib.Name
});
}
}

Expand Down Expand Up @@ -441,7 +452,7 @@ public override (List<NativeFileInfo>, List<FileInfo>) GetNatives(Library[] libr
continue;

var lMaven = result.Libraries[j].Name!.ResolveMavenString()!;
if (!lMaven.GetMavenFullName().Equals(mLMaven.GetMavenFullName(), StringComparison.Ordinal))
if (lMaven != mLMaven)
continue;

var v1 = new ComparableVersion(lMaven.Version);
Expand Down