Beispiel #1
0
 //------------------------------------------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------------------------------------------
 //PULSANTE DI ACCESSO A MINECRAFT
 //ATTUALMENTE AVVIA E BASTA, IN FUTURO AGGIUNGERE ANCHE LA FUNZIONE CHE E' SUL PULSANTE BUTTON1 E CANCELLARE QUEL BOTTONE
 //------------------------------------------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------------------------------------------
 public async void login_Click(object sender, EventArgs e)
 {
     //Downloader Downloader = new Downloader();
     //Downloader.mainjardownload();
     Downloader Downloader = new Downloader();
     login.Enabled = false;
     cleanInstallationToolStripMenuItem.Enabled = false;
     try
     {
     await Downloader.librariesdownload();
     }
     catch
     {
         login.Enabled = true;
         cleanInstallationToolStripMenuItem.Enabled = true;
         return;
     }
     login.Enabled = true;
     cleanInstallationToolStripMenuItem.Enabled = true;
     MinecraftStarter.Minecraft_Start();
     if (checkBox1.Checked)
     {
         LauncherOptionsProfileSaver.saveUsername(UsernameTextBox.Text);
         LauncherOptionsProfileSaver.saveRememberMe("true");
     }
     if (!checkBox1.Checked)
     {
         LauncherOptionsProfileSaver.saveUsername("");
         LauncherOptionsProfileSaver.saveRememberMe("false");
     }
 }
        public static async void Minecraft_Start()
        {
            var Downloader = new Downloader();
            bool check = await Downloader.check_pre_start();
            if (!check)
            {
                return;
            }
            var json = new JsonAnalyzer();
            string[] urlsforge = await Task.Factory.StartNew(async () => await json.jsonAnalyzer(false, true)).Result;
            string[] urlslibraries = await Task.Factory.StartNew(async () => await json.jsonAnalyzer(true, false)).Result;


            string launch = @"-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx" + Properties.Settings.Default["RAM"] + "M -Xms" + Properties.Settings.Default["RAM"] + "M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M " +
                           @"-Djava.library.path=" + Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\natives-win\ " +

                           @"-cp ";
            if (config.forge == true)
                launch += Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\net\minecraftforge\forge\1.7.10-10.13.4.1492-1.7.10\forge-1.7.10-10.13.4.1492-1.7.10.jar;";
            else
                launch += Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\versions\1.7.10\1.7.10.jar;";
            foreach (string url in urlsforge)
            {
                if (url.Contains("platform"))
                    continue;
                if (url.Contains("https://libraries.minecraft.net"))
                {
                    string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\" + url.Replace("https://libraries.minecraft.net", "");
                    string FileName = Path.GetFileName(dir);
                    dir = Path.GetDirectoryName(@dir);
                    //MessageBox.Show(@dir);
                    if (!Directory.Exists(@dir))
                    {
                        Directory.CreateDirectory(@dir);
                    }
                    launch = launch + ("\"" + @dir + "\\" + FileName + "\"" + ";");
                }
                if (url.Contains("http://files.minecraftforge.net/maven/"))
                {
                    string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\" + url.Replace("http://files.minecraftforge.net/maven/", "");
                    //localpath = localpath.Replace("/","\\");
                    string FileName = Path.GetFileName(dir);
                    //MessageBox.Show(FileName);
                    dir = Path.GetDirectoryName(@dir);
                    //MessageBox.Show(@dir);
                    if (!Directory.Exists(@dir))
                    {
                        Directory.CreateDirectory(@dir);
                    }
                    launch = launch + ("\"" + @dir + "\\" + FileName.Replace(".jar.pack.xz", ".jar") + "\"" + ";");
                }
            }
            foreach (string url in urlslibraries)
            {
                if (url.Contains("platform"))
                    continue;
                if (url.Contains("https://libraries.minecraft.net"))
                {
                    string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\" + url.Replace("https://libraries.minecraft.net", "");
                    //localpath = localpath.Replace("/","\\");
                    string FileName = Path.GetFileName(dir);

                    //MessageBox.Show(FileName);
                    dir = Path.GetDirectoryName(@dir);
                    //MessageBox.Show(@dir);
                    if (!Directory.Exists(@dir))
                    {
                        Directory.CreateDirectory(@dir);
                    }
                    launch = launch + ("\"" + @dir + "\\" + FileName + "\"" + ";");
                }
                if (url.Contains("http://files.minecraftforge.net/maven/"))
                {
                    string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\" + url.Replace("http://files.minecraftforge.net/maven/", "");
                    //localpath = localpath.Replace("/","\\");
                    string FileName = Path.GetFileName(dir);

                    //MessageBox.Show(FileName);
                    dir = Path.GetDirectoryName(@dir);
                    //MessageBox.Show(@dir);
                    if (!Directory.Exists(@dir))
                    {
                        Directory.CreateDirectory(@dir);
                    }
                    launch = launch + ("\"" + @dir + "\\" + FileName.Replace(".jar.pack.xz", ".jar") + "\"" + ";");
                }
            }
            if (config.forge == true)
                launch += Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\versions\1.7.10\1.7.10.jar";



            launch = launch + //" net.minecraft.client.main.Main " +
                           " net.minecraft.launchwrapper.Launch " +
                           "--username  " + Form1.singleton.UsernameTextBox.Text + " " +
                           //"--accessToken " + MojangLogin.getAccessToken() + " " +
                           //"--username killpowa " +
                           "--accessToken 0 " +
                           "--version 1.7.10-Forge10.13.4.1448-1.7.10 " +
                           "--gameDir  \"minecraft\\instances\\" + Form1.singleton.ModpackList.SelectedItem.ToString() + "\" " +
                           "--assetsDir minecraft\\assets\\ " +
                           "--userProperties {} " +
                           //"--uuid " + MojangLogin.getUUID() + " " +
                           "--uuid 3b40f99969e64dbcabd01f87cddcb1fd " +
                           "--tweakClass cpw.mods.fml.common.launcher.FMLTweaker";
            //string launch = @"-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M -Dos.version=10.0 -Djava.library.path=C:\Users\david\AppData\Roaming\.minecraft\versions\1.7.10-Forge10.13.4.1448-1.7.10\1.7.10-Forge10.13.4.1448-1.7.10-natives-260440781397829 -cp C:\Users\david\AppData\Roaming\.minecraft\libraries\net\minecraftforge\forge\1.7.10-10.13.4.1448-1.7.10\forge-1.7.10-10.13.4.1448-1.7.10.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\minecraft\launchwrapper\1.11\launchwrapper-1.11.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\ow2\asm\asm-all\5.0.3\asm-all-5.0.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\typesafe\akka\akka-actor_2.11\2.3.3\akka-actor_2.11-2.3.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\typesafe\config\1.2.1\config-1.2.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-actors-migration_2.11\1.1.0\scala-actors-migration_2.11-1.1.0.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-compiler\2.11.1\scala-compiler-2.11.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\plugins\scala-continuations-library_2.11\1.0.2\scala-continuations-library_2.11-1.0.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\plugins\scala-continuations-plugin_2.11.1\1.0.2\scala-continuations-plugin_2.11.1-1.0.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-library\2.11.1\scala-library-2.11.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-parser-combinators_2.11\1.0.1\scala-parser-combinators_2.11-1.0.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-reflect\2.11.1\scala-reflect-2.11.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-swing_2.11\1.0.1\scala-swing_2.11-1.0.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-xml_2.11\1.0.2\scala-xml_2.11-1.0.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\lzma\lzma\0.0.1\lzma-0.0.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\sf\jopt-simple\jopt-simple\4.5\jopt-simple-4.5.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\google\guava\guava\17.0\guava-17.0.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\mojang\realms\1.3.5\realms-1.3.5.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-compress\1.8.1\commons-compress-1.8.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\httpcomponents\httpclient\4.3.3\httpclient-4.3.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\java3d\vecmath\1.3.1\vecmath-1.3.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\sf\trove4j\trove4j\3.0.3\trove4j-3.0.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\ibm\icu\icu4j-core-mojang\51.2\icu4j-core-mojang-51.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\sf\jopt-simple\jopt-simple\4.5\jopt-simple-4.5.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\io\netty\netty-all\4.0.10.Final\netty-all-4.0.10.Final.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\google\guava\guava\15.0\guava-15.0.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\google\code\gson\gson\2.2.4\gson-2.2.4.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\mojang\authlib\1.5.21\authlib-1.5.21.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-api\2.0-beta9\log4j-api-2.0-beta9.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-core\2.0-beta9\log4j-core-2.0-beta9.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl\2.9.1\lwjgl-2.9.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.1\lwjgl_util-2.9.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\tv\twitch\twitch\5.16\twitch-5.16.jar;C:\Users\david\AppData\Roaming\.minecraft\versions\1.7.10\1.7.10.jar net.minecraft.launchwrapper.Launch --username killpowa --version 1.7.10-Forge10.13.4.1448-1.7.10 --gameDir C:\Users\david\AppData\Roaming\.minecraft --assetsDir C:\Users\david\AppData\Roaming\.minecraft\assets --assetIndex 1.7.10 --uuid 3b40f99969e64dbcabd01f87cddcb1fd --accessToken b856b175da4a46e8a85e34f385396157 --userProperties {} --userType legacy --tweakClass cpw.mods.fml.common.launcher.FMLTweaker";
            /*try
            {
                //MessageBox.Show(launch);
                Process test = new Process();
                test.StartInfo.UseShellExecute = false;
                test.StartInfo.RedirectStandardOutput = true;
                test.StartInfo.FileName = "java.exe";
                test.StartInfo.Arguments = launch;
                test.Start();
                Form1.singleton.richTextBox1.Text = launch;
                string output = test.StandardOutput.ReadToEnd();
                MessageBox.Show(output);

            }
            catch(Exception e)
            {
                MessageBox.Show("Non e' stato possibile avviare il gioco. Controlla di avere installato JAVA!");
                throw;
            }*/
            Downloader downloader = new Downloader();
            DebugMode.sendToConsole("Launching Minecraft with following settings: \n\r" + launch);
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = downloader.GetJavaInstallationPath() + "//bin//java.exe";
            startInfo.Arguments = launch;
            Process.Start(startInfo);
        }