mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Merge from milutinke
This commit is contained in:
parent
70d354b016
commit
11fe93a128
2 changed files with 52 additions and 51 deletions
|
|
@ -65,6 +65,9 @@ namespace MinecraftClient.Mapping
|
||||||
case Material.BlackShulkerBox:
|
case Material.BlackShulkerBox:
|
||||||
case Material.BlackStainedGlass:
|
case Material.BlackStainedGlass:
|
||||||
case Material.BlackStainedGlassPane:
|
case Material.BlackStainedGlassPane:
|
||||||
|
case Material.Blackstone:
|
||||||
|
case Material.BlackstoneSlab:
|
||||||
|
case Material.BlackstoneStairs:
|
||||||
case Material.BlackTerracotta:
|
case Material.BlackTerracotta:
|
||||||
case Material.BlackWool:
|
case Material.BlackWool:
|
||||||
case Material.BlastFurnace:
|
case Material.BlastFurnace:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ using MinecraftClient.Protocol.Message;
|
||||||
namespace MinecraftClient.Protocol.Handlers
|
namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implementation for Minecraft 1.8.X+ Protocols
|
/// Implementation for Minecraft 1.7.X+ Protocols
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Typical update steps for implementing protocol changes for a new Minecraft version:
|
/// Typical update steps for implementing protocol changes for a new Minecraft version:
|
||||||
|
|
@ -97,18 +97,19 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
this.packetPalette = new PacketTypeHandler(protocolVersion, forgeInfo != null).GetTypeHandler();
|
this.packetPalette = new PacketTypeHandler(protocolVersion, forgeInfo != null).GetTypeHandler();
|
||||||
this.log = handler.GetLogger();
|
this.log = handler.GetLogger();
|
||||||
this.randomGen = RandomNumberGenerator.Create();
|
this.randomGen = RandomNumberGenerator.Create();
|
||||||
if (handler.GetTerrainEnabled() && protocolVersion > MC_1_18_2_Version)
|
|
||||||
|
if (handler.GetTerrainEnabled() && protocolVersion > MC_1_19_2_Version)
|
||||||
{
|
{
|
||||||
log.Error(Translations.Get("extra.terrainandmovement_disabled"));
|
log.Error(Translations.Get("extra.terrainandmovement_disabled"));
|
||||||
handler.SetTerrainEnabled(false);
|
handler.SetTerrainEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler.GetInventoryEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_Version))
|
if (handler.GetInventoryEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_2_Version))
|
||||||
{
|
{
|
||||||
log.Error(Translations.Get("extra.inventory_disabled"));
|
log.Error(Translations.Get("extra.inventory_disabled"));
|
||||||
handler.SetInventoryEnabled(false);
|
handler.SetInventoryEnabled(false);
|
||||||
}
|
}
|
||||||
if (handler.GetEntityHandlingEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_Version))
|
if (handler.GetEntityHandlingEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_2_Version))
|
||||||
{
|
{
|
||||||
log.Error(Translations.Get("extra.entity_disabled"));
|
log.Error(Translations.Get("extra.entity_disabled"));
|
||||||
handler.SetEntityHandlingEnabled(false);
|
handler.SetEntityHandlingEnabled(false);
|
||||||
|
|
@ -128,51 +129,48 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
Block.Palette = new Palette115();
|
Block.Palette = new Palette115();
|
||||||
else if (protocolVersion >= MC_1_14_Version)
|
else if (protocolVersion >= MC_1_14_Version)
|
||||||
Block.Palette = new Palette114();
|
Block.Palette = new Palette114();
|
||||||
else if(protocolVersion >= MC_1_13_Version)
|
else if (protocolVersion >= MC_1_13_Version)
|
||||||
Block.Palette = new Palette113();
|
Block.Palette = new Palette113();
|
||||||
else
|
else
|
||||||
Block.Palette = new Palette112();
|
Block.Palette = new Palette112();
|
||||||
|
|
||||||
// Entity palette
|
// Entity palette
|
||||||
if (protocolVersion >= MC_1_13_Version)
|
if (protocolVersion > MC_1_19_2_Version && handler.GetEntityHandlingEnabled())
|
||||||
{
|
throw new NotImplementedException(Translations.Get("exception.palette.entity"));
|
||||||
if (protocolVersion > MC_1_19_Version && handler.GetEntityHandlingEnabled())
|
|
||||||
throw new NotImplementedException(Translations.Get("exception.palette.entity"));
|
|
||||||
|
|
||||||
if (protocolVersion == MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
entityPalette = new EntityPalette119();
|
entityPalette = new EntityPalette119();
|
||||||
else if (protocolVersion >= MC_1_17_Version)
|
else if (protocolVersion >= MC_1_17_Version)
|
||||||
entityPalette = new EntityPalette117();
|
entityPalette = new EntityPalette117();
|
||||||
else if (protocolVersion >= MC_1_16_2_Version)
|
else if (protocolVersion >= MC_1_16_2_Version)
|
||||||
entityPalette = new EntityPalette1162();
|
entityPalette = new EntityPalette1162();
|
||||||
else if (protocolVersion >= MC_1_16_Version)
|
else if (protocolVersion >= MC_1_16_Version)
|
||||||
entityPalette = new EntityPalette1161();
|
entityPalette = new EntityPalette1161();
|
||||||
else if (protocolVersion >= MC_1_15_Version)
|
else if (protocolVersion >= MC_1_15_Version)
|
||||||
entityPalette = new EntityPalette115();
|
entityPalette = new EntityPalette115();
|
||||||
else if (protocolVersion >= MC_1_14_Version)
|
else if (protocolVersion >= MC_1_14_Version)
|
||||||
entityPalette = new EntityPalette114();
|
entityPalette = new EntityPalette114();
|
||||||
else entityPalette = new EntityPalette113();
|
else if (protocolVersion >= MC_1_13_Version)
|
||||||
}
|
entityPalette = new EntityPalette113();
|
||||||
else entityPalette = new EntityPalette112();
|
else
|
||||||
|
entityPalette = new EntityPalette112();
|
||||||
|
|
||||||
// Item palette
|
// Item palette
|
||||||
if (protocolVersion >= MC_1_16_2_Version)
|
if (protocolVersion > MC_1_19_2_Version && handler.GetInventoryEnabled())
|
||||||
{
|
throw new NotImplementedException(Translations.Get("exception.palette.item"));
|
||||||
if (protocolVersion > MC_1_19_Version && handler.GetInventoryEnabled())
|
|
||||||
throw new NotImplementedException(Translations.Get("exception.palette.item"));
|
|
||||||
|
|
||||||
if (protocolVersion == MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
itemPalette = new ItemPalette119();
|
itemPalette = new ItemPalette119();
|
||||||
else if (protocolVersion >= MC_1_18_1_Version)
|
else if (protocolVersion >= MC_1_18_1_Version)
|
||||||
itemPalette = new ItemPalette118();
|
itemPalette = new ItemPalette118();
|
||||||
else if (protocolVersion >= MC_1_17_Version)
|
else if (protocolVersion >= MC_1_17_Version)
|
||||||
itemPalette = new ItemPalette117();
|
itemPalette = new ItemPalette117();
|
||||||
else if (protocolVersion >= MC_1_16_2_Version)
|
else if (protocolVersion >= MC_1_16_2_Version)
|
||||||
if (protocolVersion >= MC_1_16_2_Version)
|
itemPalette = new ItemPalette1162();
|
||||||
itemPalette = new ItemPalette1162();
|
else if (protocolVersion >= MC_1_16_1_Version)
|
||||||
else itemPalette = new ItemPalette1161();
|
itemPalette = new ItemPalette1161();
|
||||||
}
|
else
|
||||||
else itemPalette = new ItemPalette115();
|
itemPalette = new ItemPalette115();
|
||||||
|
|
||||||
// MessageType
|
// MessageType
|
||||||
// You can find it in https://wiki.vg/Protocol#Player_Chat_Message or /net/minecraft/network/message/MessageType.java
|
// You can find it in https://wiki.vg/Protocol#Player_Chat_Message or /net/minecraft/network/message/MessageType.java
|
||||||
|
|
@ -520,7 +518,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
string senderDisplayName = (chatInfo.ContainsKey("insertion") ? chatInfo["insertion"] : chatInfo["text"]).StringValue;
|
string senderDisplayName = (chatInfo.ContainsKey("insertion") ? chatInfo["insertion"] : chatInfo["text"]).StringValue;
|
||||||
string? senderTeamName = null;
|
string? senderTeamName = null;
|
||||||
ChatParser.MessageType messageTypeEnum = ChatParser.ChatId2Type![chatTypeId];
|
ChatParser.MessageType messageTypeEnum = ChatParser.ChatId2Type![chatTypeId];
|
||||||
if (targetName != null &&
|
if (targetName != null &&
|
||||||
(messageTypeEnum == ChatParser.MessageType.TEAM_MSG_COMMAND_INCOMING || messageTypeEnum == ChatParser.MessageType.TEAM_MSG_COMMAND_OUTGOING))
|
(messageTypeEnum == ChatParser.MessageType.TEAM_MSG_COMMAND_INCOMING || messageTypeEnum == ChatParser.MessageType.TEAM_MSG_COMMAND_OUTGOING))
|
||||||
senderTeamName = Json.ParseJson(targetName).Properties["with"].DataArray[0].Properties["text"].StringValue;
|
senderTeamName = Json.ParseJson(targetName).Properties["with"].DataArray[0].Properties["text"].StringValue;
|
||||||
|
|
||||||
|
|
@ -588,7 +586,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
dataTypes.ReadNextString(packetData);
|
dataTypes.ReadNextString(packetData);
|
||||||
this.currentDimension = 0;
|
this.currentDimension = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // 1.15 and below
|
{ // 1.15 and below
|
||||||
this.currentDimension = dataTypes.ReadNextInt(packetData);
|
this.currentDimension = dataTypes.ReadNextInt(packetData);
|
||||||
}
|
}
|
||||||
|
|
@ -1029,8 +1027,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// Property: Tuple<Name, Value, Signature(empty if there is no signature)
|
// Property: Tuple<Name, Value, Signature(empty if there is no signature)
|
||||||
// The Property field looks as in the response of https://wiki.vg/Mojang_API#UUID_to_Profile_and_Skin.2FCape
|
// The Property field looks as in the response of https://wiki.vg/Mojang_API#UUID_to_Profile_and_Skin.2FCape
|
||||||
const bool useProperty = false;
|
const bool useProperty = false;
|
||||||
Tuple<string, string, string?>[]? properties = useProperty ?
|
Tuple<string, string, string?>[]? properties = useProperty ?
|
||||||
new Tuple<string, string, string?>[propNum] : null;
|
new Tuple<string, string, string?>[propNum] : null;
|
||||||
for (int p = 0; p < propNum; p++)
|
for (int p = 0; p < propNum; p++)
|
||||||
{
|
{
|
||||||
string propertyName = dataTypes.ReadNextString(packetData); // Name: String (32767)
|
string propertyName = dataTypes.ReadNextString(packetData); // Name: String (32767)
|
||||||
|
|
@ -1425,7 +1423,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
healthField = 8; // 1.14 and above
|
healthField = 8; // 1.14 and above
|
||||||
if (protocolVersion >= MC_1_17_Version)
|
if (protocolVersion >= MC_1_17_Version)
|
||||||
healthField = 9; // 1.17 and above
|
healthField = 9; // 1.17 and above
|
||||||
if (protocolVersion > MC_1_19_Version)
|
if (protocolVersion > MC_1_19_2_Version)
|
||||||
throw new NotImplementedException(Translations.Get("exception.palette.healthfield"));
|
throw new NotImplementedException(Translations.Get("exception.palette.healthfield"));
|
||||||
|
|
||||||
if (metadata.ContainsKey(healthField) && metadata[healthField] != null && metadata[healthField].GetType() == typeof(float))
|
if (metadata.ContainsKey(healthField) && metadata[healthField] != null && metadata[healthField].GetType() == typeof(float))
|
||||||
|
|
@ -1896,7 +1894,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
/// Ping a Minecraft server to get information about the server
|
/// Ping a Minecraft server to get information about the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>True if ping was successful</returns>
|
/// <returns>True if ping was successful</returns>
|
||||||
public static bool doPing(string host, int port, ref int protocolVersion, ref ForgeInfo? forgeInfo)
|
public static bool doPing(string host, int port, ref int protocolversion, ref ForgeInfo? forgeInfo)
|
||||||
{
|
{
|
||||||
string version = "";
|
string version = "";
|
||||||
TcpClient tcp = ProxyHandler.newTcpClient(host, port);
|
TcpClient tcp = ProxyHandler.newTcpClient(host, port);
|
||||||
|
|
@ -1948,12 +1946,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
//Retrieve protocol version number for handling this server
|
//Retrieve protocol version number for handling this server
|
||||||
if (versionData.Properties.ContainsKey("protocol"))
|
if (versionData.Properties.ContainsKey("protocol"))
|
||||||
protocolVersion = int.Parse(versionData.Properties["protocol"].StringValue);
|
protocolversion = int.Parse(versionData.Properties["protocol"].StringValue);
|
||||||
|
|
||||||
// Check for forge on the server.
|
// Check for forge on the server.
|
||||||
Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo);
|
Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo);
|
||||||
|
|
||||||
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.server_protocol", version, protocolVersion + (forgeInfo != null ? Translations.Get("mcc.with_forge") : "")));
|
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.server_protocol", version, protocolversion + (forgeInfo != null ? Translations.Get("mcc.with_forge") : "")));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -2054,7 +2052,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
needSigned.Add(new("action", argStage1[1]));
|
needSigned.Add(new("action", argStage1[1]));
|
||||||
else if (argStage1[0] == "say" || argStage1[0] == "teammsg" || argStage1[0] == "tm")
|
else if (argStage1[0] == "say" || argStage1[0] == "teammsg" || argStage1[0] == "tm")
|
||||||
needSigned.Add(new("message", argStage1[1]));
|
needSigned.Add(new("message", argStage1[1]));
|
||||||
else if (argStage1[0] == "msg" || argStage1[0] == "tell" || argStage1[0] == "w" ||
|
else if (argStage1[0] == "msg" || argStage1[0] == "tell" || argStage1[0] == "w" ||
|
||||||
argStage1[0] == "ban" || argStage1[0] == "ban-ip" || argStage1[0] == "kick")
|
argStage1[0] == "ban" || argStage1[0] == "ban-ip" || argStage1[0] == "kick")
|
||||||
{
|
{
|
||||||
/* /msg <targets> <message>
|
/* /msg <targets> <message>
|
||||||
|
|
@ -2095,7 +2093,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LastSeenMessageList.Acknowledgment? acknowledgment =
|
LastSeenMessageList.Acknowledgment? acknowledgment =
|
||||||
(protocolVersion >= MC_1_19_2_Version) ? this.consumeAcknowledgment() : null;
|
(protocolVersion >= MC_1_19_2_Version) ? this.consumeAcknowledgment() : null;
|
||||||
|
|
||||||
List<byte> fields = new();
|
List<byte> fields = new();
|
||||||
|
|
@ -2164,7 +2162,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LastSeenMessageList.Acknowledgment? acknowledgment =
|
LastSeenMessageList.Acknowledgment? acknowledgment =
|
||||||
(protocolVersion >= MC_1_19_2_Version) ? this.consumeAcknowledgment() : null;
|
(protocolVersion >= MC_1_19_2_Version) ? this.consumeAcknowledgment() : null;
|
||||||
|
|
||||||
List<byte> fields = new();
|
List<byte> fields = new();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue