Client Example

You can download the full project here. This client is an example client that connects to a server.

Note: As of Alpha 0.3, the LibMinecraft client is not compatible with the Minecraft 1.2.3 protocol.  Alpha 0.4 will have support for 1.2.3.

Code (C#): Example Client

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibMinecraft.Model;
using LibMinecraft.Client;

namespace ClientExample
    class Program
        static void Main(string[] args)
            // Represents a Minecraft server's information
            MinecraftServer server = new MinecraftServer();
            server.Hostname = "";

            // Handles all network communication, world management, etc
            MultiplayerClient client = new MultiplayerClient();

            User user = new User();
            user.UserName = "TestPlayer";
            // You can also set user.Password for online-mode servers

            // You need to connect, then login to the server...
            // ...and then you'll be all set

            while (Console.ReadKey(true).Key != ConsoleKey.Q) ; // Press Q to quit

            // Save the world in the LibMinecraft binary format for kicks
            // You can take the resulting world folder and load it into a server
            // if you wanted to.

            client.Disconnect(); // Not strictly required, but nice to have

Last edited Mar 9, 2012 at 8:25 PM by sircmpwn, version 10


No comments yet.