Skip to content

Commit

Permalink
修复了一个导致无法启动游戏的Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSpring114 committed Dec 23, 2023
1 parent bd0f11d commit 2140cc8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 45 deletions.
42 changes: 10 additions & 32 deletions MinecraftLaunch.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,14 @@
using MinecraftLaunch;
//
using MinecraftLaunch.Components.Authenticator;
using MinecraftLaunch.Components.Fetcher;
using MinecraftLaunch.Components.Installer;
using MinecraftLaunch.Components.Launcher;
using MinecraftLaunch.Components.Resolver;
using MinecraftLaunch.Extensions;

string gameFolder = "C:\\Users\\w\\Desktop\\temp\\.minecraft";
foreach (var item in new GameResolver(gameFolder).GetGameEntitys().ToList())
{
Console.WriteLine(item.JavaVersion);
};
var installer = new VanlliaInstaller(new GameResolver(gameFolder), "1.16.5", MirrorDownloadManager.Mcbbs);
return;
installer.ProgressChanged += (_, x) => {
Console.Clear();
Console.SetCursorPosition(0, 0);
Console.WriteLine($"{x.Status} - {x.ProgressStatus} - {x.Progress.ToPercentage(0.0d, 0.65d) * 100:F2}%");
Console.SetCursorPosition(0, 0);
};

var result = await installer.InstallAsync();

var fInstaller = new ForgeInstaller(new GameResolver(gameFolder).GetGameEntity("1.16.5"),
(await ForgeInstaller.EnumerableFromVersionAsync("1.16.5")).FirstOrDefault(),new JavaFetcher().Fetch().First().JavaPath);

fInstaller.ProgressChanged += (_, x) => {
Console.Clear();
Console.SetCursorPosition(0, 0);
Console.WriteLine($"{x.Status} - {x.ProgressStatus} - {x.Progress.ToPercentage(0.65d, 1.0d) * 100:F2}%");
Console.SetCursorPosition(0, 0);
};

await fInstaller.InstallAsync();

Console.ReadKey();
var resolver = new GameResolver("C:\\Users\\w\\Desktop\\temp\\.minecraft");
Launcher launcher = new(resolver, new(new OfflineAuthenticator("Yang114").Authenticate()) {
JvmConfig = new(new JavaFetcher().Fetch().FirstOrDefault().JavaPath) {
MaxMemory = 1024,
}
});

await launcher.LaunchAsync("1.12.2");
12 changes: 1 addition & 11 deletions MinecraftLaunch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinecraftLaunch", "MinecraftLaunch\MinecraftLaunch.csproj", "{695112FD-D509-48BE-B050-0A4C1FFAC382}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Natsurainko.FluentCore", "..\..\..\Code\Natsurainko.FluentCore.New\Natsurainko.FluentCore\Natsurainko.FluentCore.csproj", "{510C557E-E4EB-4E28-BB05-969373030054}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinecraftLaunch.Test", "MinecraftLaunch.Test\MinecraftLaunch.Test.csproj", "{76E3BD50-5A2C-43D0-A5B5-CD139EB60C94}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinecraftLaunch.Simple", "MinecraftLaunch.Test\MinecraftLaunch.Simple.csproj", "{76E3BD50-5A2C-43D0-A5B5-CD139EB60C94}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -25,14 +23,6 @@ Global
{695112FD-D509-48BE-B050-0A4C1FFAC382}.Release|Any CPU.Build.0 = Release|Any CPU
{695112FD-D509-48BE-B050-0A4C1FFAC382}.Release|x64.ActiveCfg = Release|Any CPU
{695112FD-D509-48BE-B050-0A4C1FFAC382}.Release|x64.Build.0 = Release|Any CPU
{510C557E-E4EB-4E28-BB05-969373030054}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{510C557E-E4EB-4E28-BB05-969373030054}.Debug|Any CPU.Build.0 = Debug|Any CPU
{510C557E-E4EB-4E28-BB05-969373030054}.Debug|x64.ActiveCfg = Debug|Any CPU
{510C557E-E4EB-4E28-BB05-969373030054}.Debug|x64.Build.0 = Debug|Any CPU
{510C557E-E4EB-4E28-BB05-969373030054}.Release|Any CPU.ActiveCfg = Release|Any CPU
{510C557E-E4EB-4E28-BB05-969373030054}.Release|Any CPU.Build.0 = Release|Any CPU
{510C557E-E4EB-4E28-BB05-969373030054}.Release|x64.ActiveCfg = Release|Any CPU
{510C557E-E4EB-4E28-BB05-969373030054}.Release|x64.Build.0 = Release|Any CPU
{76E3BD50-5A2C-43D0-A5B5-CD139EB60C94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76E3BD50-5A2C-43D0-A5B5-CD139EB60C94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76E3BD50-5A2C-43D0-A5B5-CD139EB60C94}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down
17 changes: 17 additions & 0 deletions MinecraftLaunch/Components/Checker/PreLaunchChecker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using MinecraftLaunch.Classes.Interfaces;
using MinecraftLaunch.Classes.Models.Game;

namespace MinecraftLaunch.Components.Checker {
public class PreLaunchChecker(GameEntry entry) : IChecker {
public bool IsCheckResource { get; set; }

public bool IsCheckAccount { get; set; }

public ValueTask<bool> CheckAsync() {
/*
*
*/
throw new NotImplementedException();
}
}
}
2 changes: 1 addition & 1 deletion MinecraftLaunch/Components/Launcher/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private Process CreateProcess(IEnumerable<string> arguments, string versionPath)

private async Task ExtractNativesAndStartProcess(string versionPath, LibrariesResolver librariesResolver, Process process) {
var libraries = librariesResolver.GetLibraries()
.Where(x => (x as LibraryEntry).IsNative)
.Where(x => ((x as LibraryEntry)?.IsNative) != null)
.Select(x => x.Path)
.ToList();

Expand Down
2 changes: 1 addition & 1 deletion MinecraftLaunch/MinecraftLaunch.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>3.0.0-preview3</Version>
<Version>3.0.0-preview4</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit 2140cc8

Please sign in to comment.