Cross-platform Minecraft Launcher library
Your on-the-fly Minecraft launcher core.
English / 简体中文
We don’t talk about very basic facts here, if you have got confused, go to documentation.
Install-Package ModuleLauncher.Re
dotnet add package ModuleLauncher.Re
Assuming you must have an existing .minecraft
. By the way, don’t be afraid of these lines of codes, actually real codes are within 10 lines.
// version you want to launch
var version = "<version>";
// initialize a MinecraftResolver instance by path of .minecraft
var minecraftResolver = new MinecraftResolver(rootPath);
// get MinecraftEntry by Minecraft id (version)
// it's very IMPORTANT
var minecraft = minecraftResolver.GetMinecraft(version);
// launch in method-chain way
// essentially only two value needed to launch Minecraft besides Minecraft version
// player: username of an offline player
// (notice that here string has been implicitly converted to AuthenticateResult)
// java: path of java executable file
var process = await minecraft.WithAuthentication("<player>")
.WithJava(@"<java>")
.LaunchAsync();
The launch method LaunchAsync
returns an instance of Process
, you can manipulate it as you wish.
// read and write Minecraft output
// ReadOutputLine and IsNullOrEmpty here is extension methods provided by library Manganese
while (!process.ReadOutputLine().IsNullOrEmpty())
{
Console.WriteLine(process.ReadOutputLine());
}
new
branch. Noticibly you can’t open a pull request directly to the main
branch.If you didn’t satified with the current document, you can: