Getting Started

  1. Add CraftLib.dll to your project
  2. Add
    using CraftLib;
    
     to your usings.

Using Objects

The first thing to do when launching Minecraft is to create a Session object using the user's username and password. This also works with migrated accounts so it can also be an email address.

The most simple way to create a Session object is like this,

Auth.Session Sess = Auth.GenerateSession(Username, Password);

As you can see the method GenerateSession returns the new Session object after authenticating the user with Minecraft.net. It also throws errors for various things like,

  • Migrated Accounts
  • User Not Found
  • Minecraft.Net Unreachable
  • Bad Response

This makes it much easier for you to handle these errors in your code to provide a better user experience. The Session object contains various important parts for launching Minecraft for the user. The most important part however is the Session token also known as the Session ID this hash helps us make sure the user gets logged in to the game correctly. It looks something like this,

7ae9007b9909de05ea58e94199a33b30c310c69c

Now using that Session object we can create a GameProperties object for launching Minecraft. This GameProperties object gives a centralized location for all the variables we need to launch the game such as,

  • The Generated Session Object
  • Minimum RAM
  • Maximum RAM
  • Online Mode (bool)
  • Debug Mode (bool)
  • A Custom Path For Minecraft

It helps make the StartGame method easier to use. We can generate the GameProperties object in code like this,

 

Launcher.GameProperties Prop = new Launcher.GameProperties()
{
    GameSession = Sess, //Session Object From Earlier
    RAM_Minimum = 512, //Minimum RAM
    RAM_Maximum = 1024, //Maximum RAM
    OnlineMode = Online, //Online Mode?
    DebugMode = false, //Debug Mode?
    CustomPath = null //No Custom Path In This Example
}

 

Then we simply pass this object to the StartGame method and Minecraft will launch with the authenticated user logged in. The StartGame method checks all of these things before launching,

  • If Java Is Installed
  • If Minecraft Is Present
  • If All Minecraft Libs Are Present
    • Checks for jinput.jar, lwjgl.jar, and lwjgl_util.jar

As you can see CraftLib makes it extremely easy to authenticate users and start Minecraft. Of course you can use the individual parts if you choose to do so. You can even use the Java or Minecraft verification seperately like this,

 

if (!Verify.JavaInstalled() || !Verify.MinecraftInstalled(AppData))
{
    throw new FileNotFoundException("One or more required files are missing");
}

Last edited Nov 15, 2012 at 10:09 PM by H4x0, version 2

Comments

No comments yet.