Add support for Minecraft Settings

- Add Minecraft vanilla settings from Settings screen
 - These settings are sent to server when joining
 - Allows to customize skin layers shown to other players
 - Most other settings are ignored by servers
 - Update language file from 1.9 to 1.10 version
 - Minor aesthetic changes in INI file comments

Suggestion by TNT-UP in issue #161 and Splodger1 in MC Forum.
This commit is contained in:
ORelio 2016-08-26 12:19:25 +02:00
parent b1d4f85b23
commit 61ce935c63
5 changed files with 192 additions and 38 deletions

View file

@ -626,6 +626,11 @@ namespace MinecraftClient.Protocol.Handlers
return false; //Only supported since MC 1.7
}
public bool SendClientSettings(string language, byte viewDistance, byte difficulty, byte chatMode, bool chatColors, byte skinParts, byte mainHand)
{
return false; //Currently not implemented
}
public bool SendLocationUpdate(Location location, bool onGround)
{
return false; //Currently not implemented

View file

@ -1469,6 +1469,42 @@ namespace MinecraftClient.Protocol.Handlers
return SendPluginChannelPacket("MC|Brand", getString(brandInfo));
}
/// <summary>
/// Inform the server of the client's Minecraft settings
/// </summary>
/// <param name="language">Client language eg en_US</param>
/// <param name="viewDistance">View distance, in chunks</param>
/// <param name="difficulty">Game difficulty (client-side...)</param>
/// <param name="chatMode">Chat mode (allows muting yourself)</param>
/// <param name="chatColors">Show chat colors</param>
/// <param name="skinParts">Show skin layers</param>
/// <param name="mainHand">1.9+ main hand</param>
/// <returns>True if client settings were successfully sent</returns>
public bool SendClientSettings(string language, byte viewDistance, byte difficulty, byte chatMode, bool chatColors, byte skinParts, byte mainHand)
{
try
{
List<byte> fields = new List<byte>();
fields.AddRange(getString(language));
fields.Add(viewDistance);
fields.AddRange(protocolversion >= MC19Version
? getVarInt(chatMode)
: new byte[] { chatMode });
fields.Add(chatColors ? (byte)1 : (byte)0);
if (protocolversion < MC18Version)
{
fields.Add(difficulty);
fields.Add((byte)(skinParts & 0x1)); //show cape
}
else fields.Add(skinParts);
if (protocolversion >= MC19Version)
fields.AddRange(getVarInt(mainHand));
SendPacket(protocolversion >= MC19Version ? 0x04 : 0x15, fields);
}
catch (SocketException) { }
return false;
}
/// <summary>
/// Send a location update to the server
/// </summary>

View file

@ -20,14 +20,12 @@ namespace MinecraftClient.Protocol
/// Start the login procedure once connected to the server
/// </summary>
/// <returns>True if login was successful</returns>
bool Login();
/// <summary>
/// Disconnect from the server
/// </summary>
/// <param name="message">Reason</param>
void Disconnect();
/// <summary>
@ -35,14 +33,12 @@ namespace MinecraftClient.Protocol
/// </summary>
/// <param name="message">Text to send</param>
/// <returns>True if successfully sent</returns>
bool SendChatMessage(string message);
/// <summary>
/// Allow to respawn after death
/// </summary>
/// <returns>True if packet successfully sent</returns>
bool SendRespawnPacket();
/// <summary>
@ -50,15 +46,26 @@ namespace MinecraftClient.Protocol
/// </summary>
/// <param name="brandInfo">Client string describing the client</param>
/// <returns>True if brand info was successfully sent</returns>
bool SendBrandInfo(string brandInfo);
/// <summary>
/// Inform the server of the client's Minecraft settings
/// </summary>
/// <param name="language">Client language eg en_US</param>
/// <param name="viewDistance">View distance, in chunks</param>
/// <param name="difficulty">Game difficulty (client-side...)</param>
/// <param name="chatMode">Chat mode (allows muting yourself)</param>
/// <param name="chatColors">Show chat colors</param>
/// <param name="skinParts">Show skin layers</param>
/// <param name="mainHand">1.9+ main hand</param>
/// <returns>True if client settings were successfully sent</returns>
bool SendClientSettings(string language, byte viewDistance, byte difficulty, byte chatMode, bool chatColors, byte skinParts, byte mainHand);
/// <summary>
/// Send a location update telling that we moved to that location
/// </summary>
/// <param name="location">The new location</param>
/// <returns>True if packet was successfully sent</returns>
bool SendLocationUpdate(Location location, bool onGround);
/// <summary>
@ -68,7 +75,6 @@ namespace MinecraftClient.Protocol
/// <param name="channel">Channel to send packet on</param>
/// <param name="data">packet Data</param>
/// <returns>True if message was successfully sent</returns>
bool SendPluginChannelPacket(string channel, byte[] data);
}
}