This repository has been archived by the owner on Apr 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Sample Code
권세인 edited this page Feb 15, 2020
·
7 revisions
or check CmlLibSample project
// ENTRY POINT
static void Main(string[] args)
{
var p = new Program();
p.Start("1.7.10-Forge10.13.4.1614-1.7.10"); // start any installed version you want
Console.ReadLine();
}
private void Start(string startVersion)
{
Minecraft.Initialize(Environment.GetEnvironmentVariable("APPDATA") + "\\.minecraft"); // Initialize
MProfileInfo[] versions = MProfileInfo.GetProfiles(); // Get MProfileInfo[]
MProfile profile = MProfile.FindProfile(versions, startVersion);
DownloadGame(profile);
MLaunchOption option = new MLaunchOption() // set options
{
StartProfile = profile,
JavaPath = "java.exe", // javapath
MaximumRamMb = 4096, // maxram
Session = MSession.GetOfflineSession("tester123") // test session
};
MLaunch launch = new MLaunch(option);
launch.GetProcess().Start(); // launch
}
private void DownloadGame(MProfile profile) // download game files
{
MDownloader downloader = new MDownloader(profile);
downloader.ChangeFile += Downloader_ChangeFile;
downloader.ChangeProgress += Downloader_ChangeProgress;
downloader.DownloadAll();
}
private void Downloader_ChangeProgress(object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
Console.WriteLine(e.ProgressPercentage);
}
private void Downloader_ChangeFile(DownloadFileChangedEventArgs e)
{
Console.WriteLine("Now Downloading : {0} - {1} ({2}/{3})" , e.FileKind, e.FileName, e.ProgressedFileCount, e.TotalFileCount);
}
test footer