The Minecraft protocol.
http://wiki.vg/Protocol
 public PacketListener(Protocol protocol)
 {
     _log = LogManager.GetLogger(this);
     _log.Debug("Setting protocol...");
     _protocol = protocol;
     _log.Debug("Creating packet listen thread...");
     _listenThread = new Thread(ReadPackets) {Name = "PacketListen", IsBackground = true};
     _log.Debug("Starting packet listen thread...");
     _running = true;
     _listenThread.Start();
     _log.Info("Packet listen thread started!");
 }
Example #2
0
 /// <summary>
 /// Initialize a new Minecraft client.
 /// </summary>
 /// <param name="server">The server to connect to.</param>
 /// <param name="player">The player who logged in with the client.</param>
 public Client(Server server, Player player)
 {
     _log = LogManager.GetLogger(this);
     _log.Debug("Minecraft Client created!");
     _server = server;
     _log.Debug("Loading Items from file...");
     try
     {
         using (var reader = new StreamReader(Constants.MinecraftItemFile))
             Items = new JsonSerializer().Deserialize<List<Item>>(new JsonTextReader(reader));
     }
     catch(IOException ex)
     {
         _log.Error("Failed to read item list from file!");
         _log.Error(ex.GetType() + ": " + ex.Message);
         _log.Error("Stack Trace:\n" + ex.StackTrace);
         throw new Exception("Sharpcraft.Library.Minecraft.Client failed to initialize! Could not read item list file!", ex);
     }
     _log.Debug("Creating communication protocol...");
     _protocol = new Protocol(_server.Address, _server.Port);
     _log.Info("Client initiated on " + _server.Address + ":" + _server.Port + "!");
     _player = player;
     _world = new World();
 }