diff --git a/MinecraftClient/ConsoleIcon.cs b/MinecraftClient/ConsoleIcon.cs
new file mode 100644
index 00000000..1a24c129
--- /dev/null
+++ b/MinecraftClient/ConsoleIcon.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Threading;
+using System.Net;
+using System.IO;
+using System.Drawing;
+
+namespace MinecraftClient
+{
+ ///
+ /// Allow to set the player skin as console icon, on Windows only.
+ /// See StackOverflow no. 2986853
+ ///
+
+ public static class ConsoleIcon
+ {
+ [DllImport("kernel32.dll", SetLastError = true)]
+ private static extern bool SetConsoleIcon(IntPtr hIcon);
+
+ ///
+ /// Asynchronously download the player's skin and set the head as console icon
+ ///
+
+ public static void setPlayerIconAsync(string playerName)
+ {
+ Thread t = new Thread(new ThreadStart(delegate
+ {
+ if (!Program.isUsingMono) //Windows Only
+ {
+ HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://skins.minecraft.net/MinecraftSkins/" + playerName + ".png");
+
+ try
+ {
+ using (HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse())
+ {
+ Bitmap skin = new Bitmap(Image.FromStream(httpWebReponse.GetResponseStream())); //Read skin from network
+ skin = skin.Clone(new Rectangle(8, 8, 8, 8), skin.PixelFormat); //Crop skin
+ SetConsoleIcon(skin.GetHicon()); //Set skin as icon
+ }
+ }
+ catch (WebException) { } //Skin not found
+ }
+ }
+ ));
+ t.Name = "Player skin icon setter";
+ t.Start();
+ }
+ }
+}
diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj
index 47f9a771..ce1d3b27 100644
--- a/MinecraftClient/MinecraftClient.csproj
+++ b/MinecraftClient/MinecraftClient.csproj
@@ -62,6 +62,7 @@
+
@@ -89,6 +90,7 @@
+
diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs
index a0265c1e..da77f645 100644
--- a/MinecraftClient/Program.cs
+++ b/MinecraftClient/Program.cs
@@ -127,11 +127,13 @@ namespace MinecraftClient
if (result == ProtocolHandler.LoginResult.Success)
{
if (Settings.ConsoleTitle != "")
- {
Console.Title = Settings.expandVars(Settings.ConsoleTitle);
- }
-
+
+ if (Settings.playerHeadAsIcon)
+ ConsoleIcon.setPlayerIconAsync(Settings.Username);
+
Console.WriteLine("Success. (session ID: " + sessionID + ')');
+
if (Settings.ServerIP == "")
{
Console.Write("Server IP : ");
diff --git a/MinecraftClient/Protocol/ProtocolHandler.cs b/MinecraftClient/Protocol/ProtocolHandler.cs
index a35fa072..c48d0271 100644
--- a/MinecraftClient/Protocol/ProtocolHandler.cs
+++ b/MinecraftClient/Protocol/ProtocolHandler.cs
@@ -176,11 +176,11 @@ namespace MinecraftClient.Protocol
catch (System.Security.Authentication.AuthenticationException)
{
return LoginResult.SSLError;
- }/*
+ }
catch
{
return LoginResult.OtherError;
- }*/
+ }
}
///
diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs
index ffddf349..b5b4adde 100644
--- a/MinecraftClient/Settings.cs
+++ b/MinecraftClient/Settings.cs
@@ -42,6 +42,7 @@ namespace MinecraftClient
public static bool chatTimeStamps = false;
public static bool exitOnFailure = false;
public static char internalCmdChar = '/';
+ public static bool playerHeadAsIcon = false;
//AntiAFK Settings
public static bool AntiAFK_Enabled = false;
@@ -328,6 +329,7 @@ namespace MinecraftClient
+ "mcversion=auto #use 'auto' or '1.X.X' values\r\n"
+ "accountlist=accounts.txt\r\n"
+ "serverlist=servers.txt\r\n"
+ + "playerheadicon=true\r\n"
+ "exitonfailure=false\r\n"
+ "timestamps=false\r\n"
+ "\r\n"