Jump to content

[C#] Custom Launcher


xTekBlue

Recommended Posts

Good Afternoon,

 

    I have been trying to create a launcher for about 3-5 days now using C#. I have been able to get everything done but the launching. I can authenticate the user with the new auth system and can even pull the information from the auth server. My trouble is when I start to work on "Launching the Client". I named the function "StartMinecraft" for simplicity. I literally copied the entire folder of .minecraft to my own custom folder ".AkumaMC" as a way of testing. I used a batch file to get the default launcher params when launching the client. When I launch/run this function I get no error and the client simply does not open. Does anyone know why this could be?

 

Code: 

Spoiler

        private void StartMinecraft()
        {
            string installPath = GetJavaInstallationPath();
            string filePath = System.IO.Path.Combine(installPath, "bin\\Javaw.exe");
            if (System.IO.File.Exists(filePath))
            {
                Environment.SetEnvironmentVariable("APPDATA", "C:\\AkumaMC\\");

                string userpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                string libpath = userpath + "\\.AkumaMC\\";
                string corepath = userpath + "\\.AkumaMC\\";
                string gamepath = userpath + "\\.AkumaMC\\";
                string assetdir = gamepath + "\\assets\\";
                string accesstoken = accessToken;

                ProcessStartInfo p = new ProcessStartInfo();
                p.FileName = filePath;
                p.CreateNoWindow = true;

                p.Arguments = @"-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Djava.library.path=" + userpath + @"\runGame -Dminecraft.client.jar= " + userpath + @"\versions\1.12\1.12.jar -cp " + userpath + @"\libraries\net\minecraftforge\forge\1.12-14.21.1.2387\forge-1.12-14.21.1.2387.jar;" + userpath + @"\libraries\net\minecraft\launchwrapper\1.12\launchwrapper-1.12.jar;" + userpath + @"\libraries\org\ow2\asm\asm-all\5.2\asm-all-5.2.jar;" + userpath + @"\libraries\jline\jline\2.13\jline-2.13.jar;" + userpath + @"\libraries\com\typesafe\akka\akka-actor_2.11\2.3.3\akka-actor_2.11-2.3.3.jar;" + userpath + @"\libraries\com\typesafe\config\1.2.1\config-1.2.1.jar;" + userpath + @"\libraries\org\scala-lang\scala-actors-migration_2.11\1.1.0\scala-actors-migration_2.11-1.1.0.jar;" + userpath + @"\libraries\org\scala-lang\scala-compiler\2.11.1\scala-compiler-2.11.1.jar;" + userpath + @"\libraries\org\scala-lang\plugins\scala-continuations-library_2.11\1.0.2\scala-continuations-library_2.11-1.0.2.jar;" + userpath + @"\libraries\org\scala-lang\plugins\scala-continuations-plugin_2.11.1\1.0.2\scala-continuations-plugin_2.11.1-1.0.2.jar;" + userpath + @"\libraries\org\scala-lang\scala-library\2.11.1\scala-library-2.11.1.jar;" + userpath + @"\libraries\org\scala-lang\scala-parser-combinators_2.11\1.0.1\scala-parser-combinators_2.11-1.0.1.jar;" + userpath + @"\libraries\org\scala-lang\scala-reflect\2.11.1\scala-reflect-2.11.1.jar;" + userpath + @"\libraries\org\scala-lang\scala-swing_2.11\1.0.1\scala-swing_2.11-1.0.1.jar;" + userpath + @"\libraries\org\scala-lang\scala-xml_2.11\1.0.2\scala-xml_2.11-1.0.2.jar;" + userpath + @"\libraries\lzma\lzma\0.0.1\lzma-0.0.1.jar;" + userpath + @"\libraries\net\sf\jopt-simple\jopt-simple\4.6\jopt-simple-4.6.jar;" + userpath + @"\libraries\java3d\vecmath\1.5.2\vecmath-1.5.2.jar;" + userpath + @"\libraries\net\sf\trove4j\trove4j\3.0.3\trove4j-3.0.3.jar;" + userpath + @"\libraries\net\minecraftforge\MercuriusUpdater\1.12\MercuriusUpdater-1.12.jar;" + userpath + @"\libraries\com\mojang\patchy\1.1\patchy-1.1.jar;" + userpath + @"\libraries\oshi-project\oshi-core\1.1\oshi-core-1.1.jar;" + userpath + @"\libraries\net\java\dev\jna\jna\4.4.0\jna-4.4.0.jar;" + userpath + @"\libraries\net\java\dev\jna\platform\3.4.0\platform-3.4.0.jar;" + userpath + @"\libraries\com\ibm\icu\icu4j-core-mojang\51.2\icu4j-core-mojang-51.2.jar;" + userpath + @"\libraries\net\sf\jopt-simple\jopt-simple\5.0.3\jopt-simple-5.0.3.jar;" + userpath + @"\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;" + userpath + @"\libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar;" + userpath + @"\libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;" + userpath + @"\libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar;" + userpath + @"\libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;" + userpath + @"\libraries\io\netty\netty-all\4.1.9.Final\netty-all-4.1.9.Final.jar;" + userpath + @"\libraries\com\google\guava\guava\21.0\guava-21.0.jar;" + userpath + @"\libraries\org\apache\commons\commons-lang3\3.5\commons-lang3-3.5.jar;" + userpath + @"\libraries\commons-io\commons-io\2.5\commons-io-2.5.jar;" + userpath + @"\libraries\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;" + userpath + @"\libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar;" + userpath + @"\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;" + userpath + @"\libraries\com\google\code\gson\gson\2.8.0\gson-2.8.0.jar;" + userpath + @"\libraries\com\mojang\authlib\1.5.25\authlib-1.5.25.jar;" + userpath + @"\libraries\com\mojang\realms\1.10.17\realms-1.10.17.jar;" + userpath + @"\libraries\org\apache\commons\commons-compress\1.8.1\commons-compress-1.8.1.jar;" + userpath + @"\libraries\org\apache\httpcomponents\httpclient\4.3.3\httpclient-4.3.3.jar;" + userpath + @"\libraries\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;" + userpath + @"\libraries\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar;" + userpath + @"\libraries\it\unimi\dsi\fastutil\7.1.0\fastutil-7.1.0.jar;" + userpath + @"\libraries\org\apache\logging\log4j\log4j-api\2.8.1\log4j-api-2.8.1.jar;" + userpath + @"\libraries\org\apache\logging\log4j\log4j-core\2.8.1\log4j-core-2.8.1.jar;" + userpath + @"\libraries\org\lwjgl\lwjgl\lwjgl\2.9.4-nightly-20150209\lwjgl-2.9.4-nightly-20150209.jar;" + userpath + @"\libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.4-nightly-20150209\lwjgl_util-2.9.4-nightly-20150209.jar;" + userpath + @"\libraries\com\mojang\text2speech\1.10.3\text2speech-1.10.3.jar;" + userpath + @"\versions\1.12\1.12.jar -Xmx4G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -Dlog4j.configurationFile=" + userpath + @"\assets\log_configs\client-1.12.xml net.minecraft.launchwrapper.Launch--username " + uname + " --version 1.12-forge1.12-14.21.1.2387 --gameDir " + userpath + " --assetsDir " + userpath + @"\assets --assetIndex 1.12 --uuid " + uuidPlayer + " --accessToken " + accesstoken + " --userType mojang --tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker --versionType Forge";
                Process.Start(p);
                //Application.Exit();
            }
            else
            {
                MessageBox.Show("Cannot find Java installation. Please reinstall the latest version of Java and try again.", "AkumaMC Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


        }

 

 

Pictures:

Spoiler

 

UPDATE: I have found that changing the default ".minecraft" folder is causing the problem. Even though i specify that the gamedir is somewhere else, it is still having issues launching the game. Does anyon know a fix to this?

 

 

Warning, there is a lot of Libs :P

 

All variables are set up correctly. 

 

Quick Note: the path for "-Djava.library.path=", I launched the client, found the temp folder while the game was running and copied the files from the folder it called. I plan on downloading these from my own webserver to players ".AkumaMC" folders so that I will not have to download these files. (If there is a way to get these dll files, please let me know this too <3)

 

Thanks for any help given.

Cheers.

Edited by xTekBlue
Link to comment
Share on other sites

Creating custom launchers is not supported on this forum.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.