Coder Social home page Coder Social logo

cmllib / cmllib.core Goto Github PK

View Code? Open in Web Editor NEW
206.0 8.0 43.0 2.18 MB

.NET Minecraft Launcher Library. All Version, Auth, Forge, Java, Crossplatform

License: MIT License

C# 99.42% PowerShell 0.58%
minecraft launcher game library minecraft-launcher minecraft-launcher-library mojang

cmllib.core's People

Contributors

4wincode avatar actbit avatar alisaakiron avatar alphabs avatar alphanecron avatar dkrsk avatar gamervii-net avatar ilsubyeega avatar justawesomedanny avatar m1nicrusher avatar m1xt3nz avatar masteryuan418 avatar niklyadov avatar roxxel avatar rudde0 avatar taigostudio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cmllib.core's Issues

System.Collections.Generic.KeyNotFoundException: 'Cannot find 1.16.5'

I tried to install FabricMC using CMLauncher and FabricVersionLoader.

But an error appears when executing this piece of code:
launcher.GetVersion("fabric-loader-0.11.6-1.16.5")

Full code:

if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var launcher = new CMLauncher(path);
System.Net.ServicePointManager.DefaultConnectionLimit = 256;
FabricVersionLoader fabric = new FabricVersionLoader();

launcher.VersionLoader = fabric;
launcher.FileChanged += FileChanged;
fabric.LoaderVersion = "0.11.6";
MVersion ver = new MVersion("");
ver = launcher.GetVersion("fabric-loader-0.11.6-1.16.5");

(await launcher.CreateProcessAsync(ver, new MLaunchOption
{
Session = new MLogin().Authenticate("","").Session,
MaximumRamMb = 1024
})).Start();

Versions Disappear

if you have a version of Minecraft for example 1.16
as a local version.
getting the versions via

         var infos = MLauncher.UpdateVersions();

            foreach (var item in infos)
            {
               
                if (item.MType == MVersionType.Release)
                    MC_Versions.Items.Add(item.Name);
            }

will result in 1.16 to not show up in the list...

I don't expect that this is the expected behavior and its kind of annoying.

[BUG] Unexpected EOF (ICSharpZip)

Unexpected EOF (ICSharpZip) exception when using the method CmLauncher.CreateProcess, may be cause while extracting natives from JAR file (I have my specific JAR file)

  • OS: Windows 11 Beta Insider 22H2
  • CmlLib.Core Version: 3.3.4
  • .NET version: .NET Framework 4.6.2

Bug was fixed when downgrading to 3.3.1

ProgressBar on process

Is it possible to link progressBar to launch game process?

var launcher = new CMLauncher(path());
var launchOption = new MLaunchOption
{
MaximumRamMb = memory,
Session = session,
};

            var process = launcher.CreateProcess("1.7.10", "10.13.4.1614-1.7.10", launchOption);
            
            process.Start();

process expired

I'm trying to hide the launcher when the game starts and open it after the game closes, after closing the game the function process.Exited doesn't work.

        var process = await launcher.CreateProcessAsync(startVersion, launchOption);
        process.Start();

        this.Hide();
        process.Exited += (s1, e1) =>
        {
             this.Show();
        };

[BUG] AutoLogin doesn't work with microsoft

Describe the bug
If you login using microsoft, autologin doesn't relogin to a microsoft account.

Logs
No logs.

Environment

  • OS: Windows 11
  • CmlLib.Core Version: 3.3.5
  • .NET version: .NET Framework 4.7.2

Additional context
I don't know.

Forge Versions

Where can I check what to type in versions to use forge?
I wanna use forge 1.16.5 and it shows that it's not found
image

Download Minecraft JAR File from URL and run it.

If I have a Minecraft .JAR file and .JSON file located at 2 different urls, I was wondering if I could run it using a method. I've tried downloading it, storing it to a folder but I don't know how I would run it.

Describe the solution you'd like
I would want like a way to run it using CmlLib as this would be really useful for Auto Updaters as then they could get their jar file from a link and immediately run it.

Describe alternatives you've considered
I couldnt think of any alternative.

Additional context
I'm trying to make a launcher for a Minecraft PvP Client, I have a link to the JAR file and JSON file but I dont know how to run it.

Add Microsoft Login

Please Add In Microsoft Login And Update The Win Forms To Newest As Had Issues With Username's Having Spaces In

How to start the game without internet?

Hello there,
How do I start the game without internet? (I logged in to the crack) when I do with these codes, I get an error if I don't have internet.

Codes.txt

and I have another problem,
I am getting Java Virtual Machine error on 1.15+ versions. However, such an error does not occur when I use Minecraft Launcher. Could the Java version being used not support it?

(Translated)

Custom instances directory with shared libraries

Hey is it possible for you to make it possible to be able to use this structure:
.

  • assets (normal assets directory)
  • instances
    • ModPacks
      • MyOwnPack (custom path where client data is saved - "./instances/ModPacks/MyOwnPack")
        • config
        • logs
        • mods
        • natives (temp dir)
        • client.jar
        • options.txt
        • servers.dat
        • MyOwnPack.json
    • OptiFine
    • Vanilla
      • 1.12.2 (custom path where client data is saved - "./instances/OptiFine/Vanilla/1.12.2")
        • logs
        • resourcepacks
        • saves
        • natives (temp dir)
        • 1.12.2.json
        • client.jar
  • libraries (normal libraries directory)

I know I can set a path for the client data (for example to the 1.12.2 Vanilla dir) but can you add possibility to set custom libraries location like we can do for assets?

Change client brand

Is your feature request related to a problem? Please describe.
no

Describe the solution you'd like
I would love to be able to change the client brand, because some plugins can get your client brand and it would be pretty nice if i could set the brand to something like "Cml Client":
image

Describe alternatives you've considered
modifying the version to display a client brand you want

Additional context
none

Modded versions not working

I can launch vanilla versions with no problems, but when I tried Optifine/fabric game crashes with this:

Backend API: ERROR NoClassDefFoundError: Could not initialize class org.lwjgl.glfw.GLFW

Any clue?

Launching with Optifine broken in v3.3.3

Launching with Optifine broken in v3.3.3

[13:16:18] [main/INFO]: Loading tweak class name optifine.OptiFineTweaker
[13:16:18] [main/INFO]: Using primary tweak class name optifine.OptiFineTweaker
[13:16:18] [main/INFO]: Calling tweak class optifine.OptiFineTweaker
OptiFineTweaker: acceptOptions
OptiFineTweaker: injectIntoClassLoader
OptiFine ClassTransformer
OptiFine ZIP file: D:\AppData\Roaming.meloncher\minecraft\libraries\optifine\Optifine\1.12.2_HD_U_G6_pre1\Optifine-1.12.2_HD_U_G6_pre1.jar
OptiFineTweaker: getLaunchArguments
OptiFineTweaker: getLaunchTarget
[13:16:18] [main/ERROR]: Unable to launch
java.lang.ClassNotFoundException: net.minecraft.client.main.Main
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:186) ~[launchwrapper-of-2.2.jar:2.2]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_51]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_51]
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_51]
at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_51]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:155) [launchwrapper-of-2.2.jar:2.2]
at net.minecraft.launchwrapper.Launch.main(Launch.java:30) [launchwrapper-of-2.2.jar:2.2]
Caused by: java.lang.NullPointerException
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:177) ~[launchwrapper-of-2.2.jar:2.2]
... 6 more

[ 1.19 ] [ Forge ]

var process = await launcher.CreateProcessAsync("1.19-forge1.19-41.1.0", launchOption);

I got exception
System.Collections.Generic.KeyNotFoundException: "Cannot find 1.19-forge1.19-41.1.0"

I don't understand how to download this version

How to specify user's private key and public key for Chat Signing and how to handle banned users so they can't play multiplayer when they launch Minecraft with my launcher

How to specify user's private key and public key for Chat Signing? Is this process automatically or do I have to add some code? And how to disable multiplayer for banned users? Is this process also automatically or do I have to add some code for this? Please answer me so my launcher can comply with Minecraft's current rules, thank you.

Unity

Hello! I am writing a Minecraft launcher in Unity. I have to make an additional socket server to run minecraft. This is a very big "crutch" in the program. Could you please make unity support for CmlLib.Core library?

Compability with other external launcher

CmlLib.Core may not launch version that is not downloaded from mojang launcher or official installer.

ex) CmlLib cannot launch forge downloaded from TLauncher.

Minecraft FabricMC

Dears, Developers!
My issue is about minecraft launching other launcher example forge. I want to run FabricMC but is not supportable around CmlLib module.

[BUG] Not working for Forge 1.18

Describe the bug

If .minecraft folder is empty, I get the error on first run:
Could not find a part of the path 'C:\\Users\\USER\\AppData\\Roaming\\.minecraft\\libraries\\net\\minecraftforge\\installertools\\1.2.10\\installertools-1.2.10.jar'.

On second run after .minecraft folder exists and has some related folders and files, I get:
Cannot start process because a file name has not been provided.

I think I tracked this down to being the javaw.exe not being found initially through the JavaChecker class, or there is something wrong with acquiring the forge .jar file. Maybe it is related to the installertools jar?

Logs
Stack Trace for second error:

at System.Diagnostics.Process.Start() at CmlLib.Utils.ProcessUtil.StartWithEvents() at CmlLib.Core.Installer.MForge.startJava(String[] classpath, String mainclass, String[] args) at CmlLib.Core.Installer.MForge.startProcessor(JToken processor, Dictionary mapData) at CmlLib.Core.Installer.MForge.process(JArray processors, Dictionary mapData) at CmlLib.Core.Installer.MForge.InstallForge(String mcversion, String forgeversion) at CmlLib.Core.CMLauncher.CheckForge(String mcversion, String forgeversion, String java) at CmlLib.Core.CMLauncher.CreateProcess(String mcversion, String forgeversion, MLaunchOption option) at .......... (local code)"

This one is resolved by manually providing the Java path, but the game will not open.

Environment (please complete the following information):

  • OS: Windows 10
  • CmlLib.Core Version: 3.3.3
  • .NET version: .NET 4.7.2 / 4.8 / 6

Additional context

This is how I have been generating my Process:
Process process = launcher.CreateProcess("1.18", "38.0.10", launchOption);

First error seems it is not downloading all binaries correctly, but that doesn't seem to stop it on the second run.

Seems as if the algorithm may be having trouble detecting the Java installation, but even when supplied with the direct file path, the game does not open.

This library was working for me earlier this year on version 3.1.1, all I had changed was the version of the game and forge that is passed to the launcher.CreateProcess method.

The game loads up fine if I omit the Forge version and launch a Vanilla instance.

EDIT:
Installing Forge manually and using either CreateProcess or the updated CreateProcessAsync method launches Forge successfully, but won't correctly download and install if it does not already exist, even if the flag for checking and downloading is passed as true just in case.

Crash logging

Is your feature request related to a problem? Please describe.
I've always wanted to see why my minecraft crashes, or see the logs in real-time.

Describe the solution you'd like
See the game logs in real-time and see them when the game crashes/closes,
and also detect when the game crashes/starts

Describe alternatives you've considered

Additional context

Forge 1.7.10

Everytime i try reach process to download Forge 1.7.10-10.13.4.1614 it gives exception
My process var:
var proccess = launcher.CreateProcess("1.7.10", "10.13.4.1614", launchOptions);

Given exception:

System.Net.WebException HResult=0x80131509 Message=The remote server returned an error: (404) Not Found. Source=System StackTrace: at System.Net.HttpWebRequest.GetResponse() at CmlLib.Core.Downloader.MForge.getInstallerStream(String mcversion, String forgeversion) at CmlLib.Core.Downloader.MForge.InstallForge(String mcversion, String forgeversion) at CmlLib.Core.CMLauncher.CheckForge(String mcversion, String forgeversion, String java) at CmlLib.Core.CMLauncher.CreateProcess(String mcversion, String forgeversion, MLaunchOption option) at TestMCLauncher.Form1.buttonPlay_Click(Object sender, EventArgs e) in C:\Users\RehabCZ\Desktop\TestMCLauncher\TestMCLauncher\Form1.cs:line 51 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at TestMCLauncher.Program.Main() in C:\Users\RehabCZ\Desktop\TestMCLauncher\TestMCLauncher\Program.cs:line 19

1.17 and java16

Currently, MJava cannot install new java version, which is necessary for new versions like 1.17-pre.
We need new java runtime installer

System.ArgumentException: 'Invalid Session'

When am starting the minecraft (pressing button) am have error :

System.ArgumentException: 'Invalid Session'

This exception was originally thrown at this call stack:
[External Code]
mctest.Program.button1_Click(object, System.EventArgs) in Program.cs

in line of code: var process = await launcher.CreateProcessAsync("1.8.9", launchOption);

Versions not launching | CmlLib 3.3.1

[FIX:
Uninstall all of your Nuget Packages
Reinstall them
Try the launcher
]

Hi there, I've been using CmlLib to create a custom Minecraft Launcher.
I've got everything setup with the UI and the Session Handling but my version wont launch.

This info may help (maybe idk):

  • Net Framework 4.7.2 (i dont know if im meant to use a different version possibly?)

  • Project Download (full source and stuff): https://easyupload.io/tcyths [new link]

  • CmlLib Version: 3.3.1 (Installed from NuGet)

  • IDE: Visual Studio 2019 (dont think that would matter)

  • Project Type: Windows Forms

  • OS: Windows 11

  • CPU: Intel Core i7-471OMQ @ 2.50Ghz

  • RAM: 16GB

  • GPU: Intel HD Graphics 4600 / NVIDIA GTX 860M

In the output when I try to press play, it seems to be doing everything fine but no window shows up.
I also get these in the output:
The thread 0x13f4 has exited with code 0 (0x0).
The thread 0x4380 has exited with code 0 (0x0).
The thread 0x4614 has exited with code 0 (0x0).
The thread 0x42b0 has exited with code 0 (0x0).
The thread 0x984 has exited with code 0 (0x0).
The thread 0x4938 has exited with code 0 (0x0).
The thread 0x2cdc has exited with code 0 (0x0).
The thread 0xeb8 has exited with code 0 (0x0).
The thread 0x28ec has exited with code 0 (0x0).
The thread 0x3a38 has exited with code 0 (0x0).

They kind of seem weird.

I'm hoping that helps resolve this problem!

  • Energy

[BUG] Log4J Exploit Fix

Describe the bug
A new exploit has been found in minecraft's log4j library, it allows exploiters to execute arbitrary code on other people's computers by sending a pre-made message in the chat.

I would like to see this bug being fixed immidiately (if possible), because the official minecraft launcher seems to have patched it.

Nuget package different from here

Hi,

I am updating from CML to this, and already installed the version 2.0.2, but theres some different results.

  • As example, new Minecraft(path) dont return a path string but returns itself, not what your examples says;
  • Theres no CMLaunch(), only MLaunch();

And some other things...

Heres the installed version:
image

Can you check whats wrong?
Thanks!!

Cannot Find Any Version (CMLlib 3.1.1.0)

Hey! I'm making a launcher for modpacks and forge.
I'm adding a combo-box to the menu, and I get all versions with the following code:

foreach (var item in launcher.GetAllVersions())
{
        version.Items.Add(item);
}

But, when I go the the GUI, everything starts with "local". I started to replace everything and convert the selection to a string. CMLLib throws an error that says "can't find 'local [versiongohere]", "can't find '[versiongohere]", or "can't find 'release [versiongohere]". Any help?

I have the launcher attached, if you do want to see if anything happened.

Debug.zip

System.ArgumentException: 'Invalid Session'

When am pressing the button am getting this error

System.ArgumentException: 'Invalid Session'

code : var process = await launcher.CreateProcessAsync("1.8.9", launchOption);

Cannot find "fabric-loader-0.13.3-1.16.5"

Describe the bug
When using the following code in version 3.3.5 of CmlLib.Core it throws an exception saying that "fabric-loader-0.13.3-1.16.5" is not found.

            string fabricName = "fabric-loader-0.13.3-1.16.5";

            // Handle fabric missing
            var fabricVersionLoader = new FabricVersionLoader();
            var fabricVersions = await fabricVersionLoader.GetVersionMetadatasAsync();

            // Install fabric
            if (versions.All(x => x.Name != fabricName))
            {
                try
                {
                    var fabric = fabricVersions.GetVersionMetadata(fabricName);         // Throws error (can't find it)
                    await fabric.SaveAsync(path);

                    // Update version list
                    await launcher.GetAllVersionsAsync();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Environment.Exit(1);
                }
            }

Environment (please complete the following information):

  • OS: Windows 10
  • CmlLib.Core Version: 3.3.5
  • .NET version: 6.0-windows

Additional context
Occurs for other versions of fabric such as the example in the sample code.

Using Fabric

I've created a directory for my game path and I've installed the latest version of Fabric into that directory (using the installer). However, when I type in the Fabric version ("fabric-loader-0.10.8-1.16.4") it doesn't launch and says it doesn't exist. This is the file structure in the game path:

  • versions

    • fabric-loader-0.10.8-1.16.4
      • (all the fabric files in here)
  • mods

    • (all my mods here)

I am a little confused here, so help would be appreciated.

How to disable multiplayer when launching the Minecraft?

I'm trying to make my own launcher with my OWN Parental Control feature, and I'm looking on how to disable multiplayer MANUALLY when launching Minecraft (if parent choose to disable it for their child). Is it possible? Because this is help many parents who don't want their child to play multiplayer on Minecraft, but still want their child to play multiplayer on other games. Because when they change their child's Xbox Account Settings, it will disable multiplayer in MOST Xbox Games.

Modpack launcher

Hello,
How can I make a mod pack launcher like the ftb launcher that has multiple mod packs in the same folder?
Thx for the answer

[BUG] Launching is broken in 1.18

Describe the bug
Launcher is unable to start 1.18 versions. It always says:
image

Logs
image
Java virtual machine start failure

Environment (please complete the following information):

  • OS: Windows 10
  • CmlLib.Core Version: 3.3.5
  • .NET version: Visual C# for .NET 6.0

[BUG]

Error in https://github.com/CmlLib/CmlLib.Core/wiki/Common-Errors#could-not-create-java-virtual-machine
You write
"In a 32 bit OS Environment, you can't set MaximumRam(XMX) higher than 1024"
But it's
For 32-bit Windows: it'll be <2GB (Windows internals book says 2GB for user processes)
For 32-bit BSD / Linux: <3GB (from the Devil Book)
For 32-bit MacOS X: <4GB (from Mac OS X internals book)
(Source: https://stackoverflow.com/a/7019624)

Logs
?

Environment (please complete the following information):

  • OS: Windows 10
  • CmlLib.Core Version: ?
  • .NET version: ?

(Sorry for my bad english)

English Issue

I'm not native english speeker,
and I'm not good at english.

so there might be many strange english sentences in this repo. (especially README, wiki, source code comments)

if you find any strange sentences, feel free to tell me

comment in this issue, make pull request, make new issue or anything

thanks you

Launch a downloaded jar

Hey,

I would want to download a .jar from a website and then directly launch Minecraft and use it as a version.
I don't want to keep it in a folder and just launch it instantly.

Can I do that? If not, can you add a feature or a code sample to do that?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.