mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Reduce merge conflicts
This commit is contained in:
parent
290ec9cc79
commit
4538095d74
2 changed files with 155 additions and 151 deletions
|
|
@ -1130,18 +1130,20 @@ namespace MinecraftClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text">Text to send to the server</param>
|
/// <param name="text">Text to send to the server</param>
|
||||||
public void SendText(string text)
|
public void SendText(string text)
|
||||||
{
|
|
||||||
lock (chatQueue)
|
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(text))
|
if (String.IsNullOrEmpty(text))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int maxLength = handler.GetMaxChatMessageLength();
|
int maxLength = handler.GetMaxChatMessageLength();
|
||||||
|
|
||||||
|
lock (chatQueue)
|
||||||
|
{
|
||||||
if (text.Length > maxLength) //Message is too long?
|
if (text.Length > maxLength) //Message is too long?
|
||||||
{
|
{
|
||||||
if (text[0] == '/')
|
if (text[0] == '/')
|
||||||
{
|
{
|
||||||
//Send the first 100/256 chars of the command
|
//Send the first 100/256 chars of the command
|
||||||
text = text.Substring(0, maxLength);
|
text = text[..maxLength];
|
||||||
chatQueue.Enqueue(text);
|
chatQueue.Enqueue(text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1149,13 +1151,15 @@ namespace MinecraftClient
|
||||||
//Split the message into several messages
|
//Split the message into several messages
|
||||||
while (text.Length > maxLength)
|
while (text.Length > maxLength)
|
||||||
{
|
{
|
||||||
chatQueue.Enqueue(text.Substring(0, maxLength));
|
chatQueue.Enqueue(text[..maxLength]);
|
||||||
text = text.Substring(maxLength, text.Length - maxLength);
|
text = text[maxLength..];
|
||||||
}
|
}
|
||||||
chatQueue.Enqueue(text);
|
chatQueue.Enqueue(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else chatQueue.Enqueue(text);
|
else
|
||||||
|
chatQueue.Enqueue(text);
|
||||||
|
|
||||||
TrySendMessageToServer();
|
TrySendMessageToServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
private readonly List<string> autocomplete_result = new List<string>();
|
private readonly List<string> autocomplete_result = new List<string>();
|
||||||
private readonly Dictionary<int, short> window_actions = new Dictionary<int, short>();
|
private readonly Dictionary<int, short> window_actions = new Dictionary<int, short>();
|
||||||
private bool login_phase = true;
|
private bool login_phase = true;
|
||||||
private int protocolversion;
|
private int protocolVersion;
|
||||||
private int currentDimension;
|
private int currentDimension;
|
||||||
private readonly BlockingCollection<Tuple<int, Queue<byte>>> packetQueue = new();
|
private readonly BlockingCollection<Tuple<int, Queue<byte>>> packetQueue = new();
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
ChatParser.InitTranslations();
|
ChatParser.InitTranslations();
|
||||||
this.socketWrapper = new SocketWrapper(Client);
|
this.socketWrapper = new SocketWrapper(Client);
|
||||||
this.dataTypes = new DataTypes(protocolVersion);
|
this.dataTypes = new DataTypes(protocolVersion);
|
||||||
this.protocolversion = protocolVersion;
|
this.protocolVersion = protocolVersion;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.pForge = new Protocol18Forge(forgeInfo, protocolVersion, dataTypes, this, handler);
|
this.pForge = new Protocol18Forge(forgeInfo, protocolVersion, dataTypes, this, handler);
|
||||||
this.pTerrain = new Protocol18Terrain(protocolVersion, dataTypes, handler);
|
this.pTerrain = new Protocol18Terrain(protocolVersion, dataTypes, handler);
|
||||||
|
|
@ -95,26 +95,26 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
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_18_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_18_2_Version))
|
if (handler.GetInventoryEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_18_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_18_2_Version))
|
if (handler.GetEntityHandlingEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_18_2_Version))
|
||||||
{
|
{
|
||||||
log.Error(Translations.Get("extra.entity_disabled"));
|
log.Error(Translations.Get("extra.entity_disabled"));
|
||||||
handler.SetEntityHandlingEnabled(false);
|
handler.SetEntityHandlingEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block palette
|
// Block palette
|
||||||
if (protocolversion >= MC_1_13_Version)
|
if (protocolVersion >= MC_1_13_Version)
|
||||||
{
|
{
|
||||||
if (protocolVersion > MC_1_18_2_Version && handler.GetTerrainEnabled())
|
if (protocolVersion > MC_1_18_2_Version && handler.GetTerrainEnabled())
|
||||||
throw new NotImplementedException(Translations.Get("exception.palette.block"));
|
throw new NotImplementedException(Translations.Get("exception.palette.block"));
|
||||||
|
|
@ -132,18 +132,18 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
else Block.Palette = new Palette112();
|
else Block.Palette = new Palette112();
|
||||||
|
|
||||||
// Entity palette
|
// Entity palette
|
||||||
if (protocolversion >= MC_1_13_Version)
|
if (protocolVersion >= MC_1_13_Version)
|
||||||
{
|
{
|
||||||
if (protocolversion > MC_1_18_2_Version && handler.GetEntityHandlingEnabled())
|
if (protocolVersion > MC_1_18_2_Version && handler.GetEntityHandlingEnabled())
|
||||||
throw new NotImplementedException(Translations.Get("exception.palette.entity"));
|
throw new NotImplementedException(Translations.Get("exception.palette.entity"));
|
||||||
if (protocolversion >= MC_1_17_Version)
|
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)
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
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();
|
||||||
|
|
@ -152,16 +152,16 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
else entityPalette = new EntityPalette112();
|
else entityPalette = new EntityPalette112();
|
||||||
|
|
||||||
// Item palette
|
// Item palette
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
{
|
{
|
||||||
if (protocolversion > MC_1_18_2_Version && handler.GetInventoryEnabled())
|
if (protocolVersion > MC_1_18_2_Version && handler.GetInventoryEnabled())
|
||||||
throw new NotImplementedException(Translations.Get("exception.palette.item"));
|
throw new NotImplementedException(Translations.Get("exception.palette.item"));
|
||||||
if (protocolversion >= MC_1_18_1_Version)
|
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)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
itemPalette = new ItemPalette1162();
|
itemPalette = new ItemPalette1162();
|
||||||
else itemPalette = new ItemPalette1161();
|
else itemPalette = new ItemPalette1161();
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +261,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
Queue<byte> packetData = new(socketWrapper.ReadDataRAW(size)); //Packet contents
|
Queue<byte> packetData = new(socketWrapper.ReadDataRAW(size)); //Packet contents
|
||||||
|
|
||||||
//Handle packet decompression
|
//Handle packet decompression
|
||||||
if (protocolversion >= MC_1_8_Version
|
if (protocolVersion >= MC_1_8_Version
|
||||||
&& compression_treshold > 0)
|
&& compression_treshold > 0)
|
||||||
{
|
{
|
||||||
int sizeUncompressed = dataTypes.ReadNextVarInt(packetData);
|
int sizeUncompressed = dataTypes.ReadNextVarInt(packetData);
|
||||||
|
|
@ -299,7 +299,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
switch (packetID) //Packet IDs are different while logging in
|
switch (packetID) //Packet IDs are different while logging in
|
||||||
{
|
{
|
||||||
case 0x03:
|
case 0x03:
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
compression_treshold = dataTypes.ReadNextVarInt(packetData);
|
compression_treshold = dataTypes.ReadNextVarInt(packetData);
|
||||||
break;
|
break;
|
||||||
case 0x04:
|
case 0x04:
|
||||||
|
|
@ -329,12 +329,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
int playerEntityID = dataTypes.ReadNextInt(packetData);
|
int playerEntityID = dataTypes.ReadNextInt(packetData);
|
||||||
handler.OnReceivePlayerEntityID(playerEntityID);
|
handler.OnReceivePlayerEntityID(playerEntityID);
|
||||||
|
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
dataTypes.ReadNextBool(packetData); // Is hardcore - 1.16.2 and above
|
dataTypes.ReadNextBool(packetData); // Is hardcore - 1.16.2 and above
|
||||||
|
|
||||||
handler.OnGamemodeUpdate(Guid.Empty, dataTypes.ReadNextByte(packetData));
|
handler.OnGamemodeUpdate(Guid.Empty, dataTypes.ReadNextByte(packetData));
|
||||||
|
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
dataTypes.ReadNextByte(packetData); // Previous Gamemode - 1.16 and above
|
dataTypes.ReadNextByte(packetData); // Previous Gamemode - 1.16 and above
|
||||||
int worldCount = dataTypes.ReadNextVarInt(packetData); // Dimension Count (World Count) - 1.16 and above
|
int worldCount = dataTypes.ReadNextVarInt(packetData); // Dimension Count (World Count) - 1.16 and above
|
||||||
|
|
@ -351,55 +351,55 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// String identifier: 1.16 and 1.16.1
|
// String identifier: 1.16 and 1.16.1
|
||||||
// varInt: [1.9.1 to 1.15.2]
|
// varInt: [1.9.1 to 1.15.2]
|
||||||
// byte: below 1.9.1
|
// byte: below 1.9.1
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
||||||
currentDimensionType = new Dictionary<string, object>();
|
currentDimensionType = new Dictionary<string, object>();
|
||||||
}
|
}
|
||||||
else if (protocolversion >= MC_1_16_2_Version)
|
else if (protocolVersion >= MC_1_16_2_Version)
|
||||||
currentDimensionType = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
|
currentDimensionType = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
|
||||||
else
|
else
|
||||||
dataTypes.ReadNextString(packetData);
|
dataTypes.ReadNextString(packetData);
|
||||||
this.currentDimension = 0;
|
this.currentDimension = 0;
|
||||||
}
|
}
|
||||||
else if (protocolversion >= MC_1_9_1_Version)
|
else if (protocolVersion >= MC_1_9_1_Version)
|
||||||
this.currentDimension = dataTypes.ReadNextInt(packetData);
|
this.currentDimension = dataTypes.ReadNextInt(packetData);
|
||||||
else
|
else
|
||||||
this.currentDimension = (sbyte)dataTypes.ReadNextByte(packetData);
|
this.currentDimension = (sbyte)dataTypes.ReadNextByte(packetData);
|
||||||
|
|
||||||
if (protocolversion < MC_1_14_Version)
|
if (protocolVersion < MC_1_14_Version)
|
||||||
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
|
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
|
||||||
|
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
||||||
|
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
World.SetDimension(currentDimensionName, currentDimensionType);
|
World.SetDimension(currentDimensionName, currentDimensionType);
|
||||||
|
|
||||||
if (protocolversion >= MC_1_15_Version)
|
if (protocolVersion >= MC_1_15_Version)
|
||||||
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
|
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
dataTypes.ReadNextVarInt(packetData); // Max Players - 1.16.2 and above
|
dataTypes.ReadNextVarInt(packetData); // Max Players - 1.16.2 and above
|
||||||
else
|
else
|
||||||
dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below
|
dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below
|
||||||
if (protocolversion < MC_1_16_Version)
|
if (protocolVersion < MC_1_16_Version)
|
||||||
dataTypes.SkipNextString(packetData); // Level Type - 1.15 and below
|
dataTypes.SkipNextString(packetData); // Level Type - 1.15 and below
|
||||||
if (protocolversion >= MC_1_14_Version)
|
if (protocolVersion >= MC_1_14_Version)
|
||||||
dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above
|
dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above
|
||||||
if (protocolversion >= MC_1_18_1_Version)
|
if (protocolVersion >= MC_1_18_1_Version)
|
||||||
dataTypes.ReadNextVarInt(packetData); // Simulation Distance - 1.18 and above
|
dataTypes.ReadNextVarInt(packetData); // Simulation Distance - 1.18 and above
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
dataTypes.ReadNextBool(packetData); // Reduced debug info - 1.8 and above
|
dataTypes.ReadNextBool(packetData); // Reduced debug info - 1.8 and above
|
||||||
if (protocolversion >= MC_1_15_Version)
|
if (protocolVersion >= MC_1_15_Version)
|
||||||
dataTypes.ReadNextBool(packetData); // Enable respawn screen - 1.15 and above
|
dataTypes.ReadNextBool(packetData); // Enable respawn screen - 1.15 and above
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above
|
dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above
|
||||||
dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above
|
dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above
|
||||||
}
|
}
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location
|
bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location
|
||||||
if (hasDeathLocation)
|
if (hasDeathLocation)
|
||||||
|
|
@ -412,12 +412,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.ChatMessage:
|
case PacketTypesIn.ChatMessage:
|
||||||
int messageType = 0;
|
int messageType = 0;
|
||||||
|
|
||||||
if (protocolversion <= MC_1_18_2_Version) // 1.18 and bellow
|
if (protocolVersion <= MC_1_18_2_Version) // 1.18 and bellow
|
||||||
{
|
{
|
||||||
string message = dataTypes.ReadNextString(packetData);
|
string message = dataTypes.ReadNextString(packetData);
|
||||||
|
|
||||||
Guid senderUUID;
|
Guid senderUUID;
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
{
|
{
|
||||||
//Hide system messages or xp bar messages?
|
//Hide system messages or xp bar messages?
|
||||||
messageType = dataTypes.ReadNextByte(packetData);
|
messageType = dataTypes.ReadNextByte(packetData);
|
||||||
|
|
@ -425,7 +425,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|| (messageType == 2 && !Settings.DisplayXPBarMessages))
|
|| (messageType == 2 && !Settings.DisplayXPBarMessages))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (protocolversion >= MC_1_16_5_Version)
|
if (protocolVersion >= MC_1_16_5_Version)
|
||||||
senderUUID = dataTypes.ReadNextUUID(packetData);
|
senderUUID = dataTypes.ReadNextUUID(packetData);
|
||||||
else senderUUID = Guid.Empty;
|
else senderUUID = Guid.Empty;
|
||||||
}
|
}
|
||||||
|
|
@ -467,14 +467,14 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.Respawn:
|
case PacketTypesIn.Respawn:
|
||||||
string? dimensionNameInRespawn = null;
|
string? dimensionNameInRespawn = null;
|
||||||
Dictionary<string, object> dimensionTypeInRespawn = null;
|
Dictionary<string, object> dimensionTypeInRespawn = null;
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
dataTypes.ReadNextString(packetData); // Dimension Type: Identifier
|
||||||
dimensionTypeInRespawn = new Dictionary<string, object>();
|
dimensionTypeInRespawn = new Dictionary<string, object>();
|
||||||
}
|
}
|
||||||
else if (protocolversion >= MC_1_16_2_Version)
|
else if (protocolVersion >= MC_1_16_2_Version)
|
||||||
dimensionTypeInRespawn = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
|
dimensionTypeInRespawn = dataTypes.ReadNextNbt(packetData); // Dimension Type: NBT Tag Compound
|
||||||
else
|
else
|
||||||
dataTypes.ReadNextString(packetData);
|
dataTypes.ReadNextString(packetData);
|
||||||
|
|
@ -485,28 +485,28 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// 1.15 and below
|
// 1.15 and below
|
||||||
this.currentDimension = dataTypes.ReadNextInt(packetData);
|
this.currentDimension = dataTypes.ReadNextInt(packetData);
|
||||||
}
|
}
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
dimensionNameInRespawn = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
dimensionNameInRespawn = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above
|
||||||
|
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
World.SetDimension(dimensionNameInRespawn, dimensionTypeInRespawn);
|
World.SetDimension(dimensionNameInRespawn, dimensionTypeInRespawn);
|
||||||
|
|
||||||
if (protocolversion < MC_1_14_Version)
|
if (protocolVersion < MC_1_14_Version)
|
||||||
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
|
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
|
||||||
if (protocolversion >= MC_1_15_Version)
|
if (protocolVersion >= MC_1_15_Version)
|
||||||
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
|
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
|
||||||
dataTypes.ReadNextByte(packetData); // Gamemode
|
dataTypes.ReadNextByte(packetData); // Gamemode
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above
|
dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above
|
||||||
if (protocolversion < MC_1_16_Version)
|
if (protocolVersion < MC_1_16_Version)
|
||||||
dataTypes.SkipNextString(packetData); // Level Type - 1.15 and below
|
dataTypes.SkipNextString(packetData); // Level Type - 1.15 and below
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above
|
dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above
|
||||||
dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above
|
dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above
|
||||||
dataTypes.ReadNextBool(packetData); // Copy metadata - 1.16 and above
|
dataTypes.ReadNextBool(packetData); // Copy metadata - 1.16 and above
|
||||||
}
|
}
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location
|
bool hasDeathLocation = dataTypes.ReadNextBool(packetData); // Has death location
|
||||||
if (hasDeathLocation)
|
if (hasDeathLocation)
|
||||||
|
|
@ -529,7 +529,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// entity handling require player pos for distance calculating
|
// entity handling require player pos for distance calculating
|
||||||
if (handler.GetTerrainEnabled() || handler.GetEntityHandlingEnabled())
|
if (handler.GetTerrainEnabled() || handler.GetEntityHandlingEnabled())
|
||||||
{
|
{
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
{
|
{
|
||||||
Location location = handler.GetCurrentLocation();
|
Location location = handler.GetCurrentLocation();
|
||||||
location.X = (locMask & 1 << 0) != 0 ? location.X + x : x;
|
location.X = (locMask & 1 << 0) != 0 ? location.X + x : x;
|
||||||
|
|
@ -540,14 +540,14 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
else handler.UpdateLocation(new Location(x, y, z), yaw, pitch);
|
else handler.UpdateLocation(new Location(x, y, z), yaw, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocolversion >= MC_1_9_Version)
|
if (protocolVersion >= MC_1_9_Version)
|
||||||
{
|
{
|
||||||
int teleportID = dataTypes.ReadNextVarInt(packetData);
|
int teleportID = dataTypes.ReadNextVarInt(packetData);
|
||||||
// Teleport confirm packet
|
// Teleport confirm packet
|
||||||
SendPacket(PacketTypesOut.TeleportConfirm, dataTypes.GetVarInt(teleportID));
|
SendPacket(PacketTypesOut.TeleportConfirm, dataTypes.GetVarInt(teleportID));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocolversion >= MC_1_17_Version)
|
if (protocolVersion >= MC_1_17_Version)
|
||||||
dataTypes.ReadNextBool(packetData); // Dismount Vehicle - 1.17 and above
|
dataTypes.ReadNextBool(packetData); // Dismount Vehicle - 1.17 and above
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.ChunkData:
|
case PacketTypesIn.ChunkData:
|
||||||
|
|
@ -558,16 +558,16 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
int chunkX = dataTypes.ReadNextInt(packetData);
|
int chunkX = dataTypes.ReadNextInt(packetData);
|
||||||
int chunkZ = dataTypes.ReadNextInt(packetData);
|
int chunkZ = dataTypes.ReadNextInt(packetData);
|
||||||
if (protocolversion >= MC_1_17_Version)
|
if (protocolVersion >= MC_1_17_Version)
|
||||||
{
|
{
|
||||||
ulong[]? verticalStripBitmask = null;
|
ulong[]? verticalStripBitmask = null;
|
||||||
|
|
||||||
if (protocolversion == MC_1_17_Version || protocolversion == MC_1_17_1_Version)
|
if (protocolVersion == MC_1_17_Version || protocolVersion == MC_1_17_1_Version)
|
||||||
verticalStripBitmask = dataTypes.ReadNextULongArray(packetData); // Bit Mask Length and Primary Bit Mask
|
verticalStripBitmask = dataTypes.ReadNextULongArray(packetData); // Bit Mask Length and Primary Bit Mask
|
||||||
|
|
||||||
dataTypes.ReadNextNbt(packetData); // Heightmaps
|
dataTypes.ReadNextNbt(packetData); // Heightmaps
|
||||||
|
|
||||||
if (protocolversion == MC_1_17_Version || protocolversion == MC_1_17_1_Version)
|
if (protocolVersion == MC_1_17_Version || protocolVersion == MC_1_17_1_Version)
|
||||||
{
|
{
|
||||||
int biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length
|
int biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length
|
||||||
for (int i = 0; i < biomesLength; i++)
|
for (int i = 0; i < biomesLength; i++)
|
||||||
|
|
@ -585,12 +585,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool chunksContinuous = dataTypes.ReadNextBool(packetData);
|
bool chunksContinuous = dataTypes.ReadNextBool(packetData);
|
||||||
if (protocolversion >= MC_1_16_Version && protocolversion <= MC_1_16_1_Version)
|
if (protocolVersion >= MC_1_16_Version && protocolVersion <= MC_1_16_1_Version)
|
||||||
dataTypes.ReadNextBool(packetData); // Ignore old data - 1.16 to 1.16.1 only
|
dataTypes.ReadNextBool(packetData); // Ignore old data - 1.16 to 1.16.1 only
|
||||||
ushort chunkMask = protocolversion >= MC_1_9_Version
|
ushort chunkMask = protocolVersion >= MC_1_9_Version
|
||||||
? (ushort)dataTypes.ReadNextVarInt(packetData)
|
? (ushort)dataTypes.ReadNextVarInt(packetData)
|
||||||
: dataTypes.ReadNextUShort(packetData);
|
: dataTypes.ReadNextUShort(packetData);
|
||||||
if (protocolversion < MC_1_8_Version)
|
if (protocolVersion < MC_1_8_Version)
|
||||||
{
|
{
|
||||||
ushort addBitmap = dataTypes.ReadNextUShort(packetData);
|
ushort addBitmap = dataTypes.ReadNextUShort(packetData);
|
||||||
int compressedDataSize = dataTypes.ReadNextInt(packetData);
|
int compressedDataSize = dataTypes.ReadNextInt(packetData);
|
||||||
|
|
@ -602,15 +602,15 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (protocolversion >= MC_1_14_Version)
|
if (protocolVersion >= MC_1_14_Version)
|
||||||
dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above
|
dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above
|
||||||
int biomesLength = 0;
|
int biomesLength = 0;
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
if (chunksContinuous)
|
if (chunksContinuous)
|
||||||
biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - 1.16.2 and above
|
biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - 1.16.2 and above
|
||||||
if (protocolversion >= MC_1_15_Version && chunksContinuous)
|
if (protocolVersion >= MC_1_15_Version && chunksContinuous)
|
||||||
{
|
{
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < biomesLength; i++)
|
for (int i = 0; i < biomesLength; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -632,13 +632,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.MapData:
|
case PacketTypesIn.MapData:
|
||||||
int mapid = dataTypes.ReadNextVarInt(packetData);
|
int mapid = dataTypes.ReadNextVarInt(packetData);
|
||||||
byte scale = dataTypes.ReadNextByte(packetData);
|
byte scale = dataTypes.ReadNextByte(packetData);
|
||||||
bool trackingposition = protocolversion >= MC_1_17_Version ? false : dataTypes.ReadNextBool(packetData);
|
bool trackingposition = protocolVersion >= MC_1_17_Version ? false : dataTypes.ReadNextBool(packetData);
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
if (protocolversion >= MC_1_14_Version)
|
if (protocolVersion >= MC_1_14_Version)
|
||||||
{
|
{
|
||||||
locked = dataTypes.ReadNextBool(packetData);
|
locked = dataTypes.ReadNextBool(packetData);
|
||||||
}
|
}
|
||||||
if (protocolversion >= MC_1_17_Version)
|
if (protocolVersion >= MC_1_17_Version)
|
||||||
{
|
{
|
||||||
trackingposition = dataTypes.ReadNextBool(packetData);
|
trackingposition = dataTypes.ReadNextBool(packetData);
|
||||||
}
|
}
|
||||||
|
|
@ -646,7 +646,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
handler.OnMapData(mapid, scale, trackingposition, locked, iconcount);
|
handler.OnMapData(mapid, scale, trackingposition, locked, iconcount);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.TradeList:
|
case PacketTypesIn.TradeList:
|
||||||
if ((protocolversion >= MC_1_14_Version) && (handler.GetInventoryEnabled()))
|
if ((protocolVersion >= MC_1_14_Version) && (handler.GetInventoryEnabled()))
|
||||||
{
|
{
|
||||||
// MC 1.14 or greater
|
// MC 1.14 or greater
|
||||||
int windowID = dataTypes.ReadNextVarInt(packetData);
|
int windowID = dataTypes.ReadNextVarInt(packetData);
|
||||||
|
|
@ -668,7 +668,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.Title:
|
case PacketTypesIn.Title:
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
{
|
{
|
||||||
int action2 = dataTypes.ReadNextVarInt(packetData);
|
int action2 = dataTypes.ReadNextVarInt(packetData);
|
||||||
string titletext = String.Empty;
|
string titletext = String.Empty;
|
||||||
|
|
@ -678,7 +678,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
int fadein = -1;
|
int fadein = -1;
|
||||||
int stay = -1;
|
int stay = -1;
|
||||||
int fadeout = -1;
|
int fadeout = -1;
|
||||||
if (protocolversion >= MC_1_10_Version)
|
if (protocolVersion >= MC_1_10_Version)
|
||||||
{
|
{
|
||||||
if (action2 == 0)
|
if (action2 == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -727,7 +727,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.MultiBlockChange:
|
case PacketTypesIn.MultiBlockChange:
|
||||||
if (handler.GetTerrainEnabled())
|
if (handler.GetTerrainEnabled())
|
||||||
{
|
{
|
||||||
if (protocolversion >= MC_1_16_2_Version)
|
if (protocolVersion >= MC_1_16_2_Version)
|
||||||
{
|
{
|
||||||
long chunkSection = dataTypes.ReadNextLong(packetData);
|
long chunkSection = dataTypes.ReadNextLong(packetData);
|
||||||
int sectionX = (int)(chunkSection >> 42);
|
int sectionX = (int)(chunkSection >> 42);
|
||||||
|
|
@ -755,7 +755,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
int chunkX = dataTypes.ReadNextInt(packetData);
|
int chunkX = dataTypes.ReadNextInt(packetData);
|
||||||
int chunkZ = dataTypes.ReadNextInt(packetData);
|
int chunkZ = dataTypes.ReadNextInt(packetData);
|
||||||
int recordCount = protocolversion < MC_1_8_Version
|
int recordCount = protocolVersion < MC_1_8_Version
|
||||||
? (int)dataTypes.ReadNextShort(packetData)
|
? (int)dataTypes.ReadNextShort(packetData)
|
||||||
: dataTypes.ReadNextVarInt(packetData);
|
: dataTypes.ReadNextVarInt(packetData);
|
||||||
|
|
||||||
|
|
@ -765,7 +765,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
ushort blockIdMeta;
|
ushort blockIdMeta;
|
||||||
int blockY;
|
int blockY;
|
||||||
|
|
||||||
if (protocolversion < MC_1_8_Version)
|
if (protocolVersion < MC_1_8_Version)
|
||||||
{
|
{
|
||||||
blockIdMeta = dataTypes.ReadNextUShort(packetData);
|
blockIdMeta = dataTypes.ReadNextUShort(packetData);
|
||||||
blockY = (ushort)dataTypes.ReadNextByte(packetData);
|
blockY = (ushort)dataTypes.ReadNextByte(packetData);
|
||||||
|
|
@ -804,7 +804,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.BlockChange:
|
case PacketTypesIn.BlockChange:
|
||||||
if (handler.GetTerrainEnabled())
|
if (handler.GetTerrainEnabled())
|
||||||
{
|
{
|
||||||
if (protocolversion < MC_1_8_Version)
|
if (protocolVersion < MC_1_8_Version)
|
||||||
{
|
{
|
||||||
int blockX = dataTypes.ReadNextInt(packetData);
|
int blockX = dataTypes.ReadNextInt(packetData);
|
||||||
int blockY = dataTypes.ReadNextByte(packetData);
|
int blockY = dataTypes.ReadNextByte(packetData);
|
||||||
|
|
@ -840,14 +840,14 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.MapChunkBulk:
|
case PacketTypesIn.MapChunkBulk:
|
||||||
if (protocolversion < MC_1_9_Version && handler.GetTerrainEnabled())
|
if (protocolVersion < MC_1_9_Version && handler.GetTerrainEnabled())
|
||||||
{
|
{
|
||||||
int chunkCount;
|
int chunkCount;
|
||||||
bool hasSkyLight;
|
bool hasSkyLight;
|
||||||
Queue<byte> chunkData = packetData;
|
Queue<byte> chunkData = packetData;
|
||||||
|
|
||||||
//Read global fields
|
//Read global fields
|
||||||
if (protocolversion < MC_1_8_Version)
|
if (protocolVersion < MC_1_8_Version)
|
||||||
{
|
{
|
||||||
chunkCount = dataTypes.ReadNextShort(packetData);
|
chunkCount = dataTypes.ReadNextShort(packetData);
|
||||||
int compressedDataSize = dataTypes.ReadNextInt(packetData);
|
int compressedDataSize = dataTypes.ReadNextInt(packetData);
|
||||||
|
|
@ -872,7 +872,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
chunkXs[chunkColumnNo] = dataTypes.ReadNextInt(packetData);
|
chunkXs[chunkColumnNo] = dataTypes.ReadNextInt(packetData);
|
||||||
chunkZs[chunkColumnNo] = dataTypes.ReadNextInt(packetData);
|
chunkZs[chunkColumnNo] = dataTypes.ReadNextInt(packetData);
|
||||||
chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData);
|
chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData);
|
||||||
addBitmaps[chunkColumnNo] = protocolversion < MC_1_8_Version
|
addBitmaps[chunkColumnNo] = protocolVersion < MC_1_8_Version
|
||||||
? dataTypes.ReadNextUShort(packetData)
|
? dataTypes.ReadNextUShort(packetData)
|
||||||
: (ushort)0;
|
: (ushort)0;
|
||||||
}
|
}
|
||||||
|
|
@ -887,7 +887,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.UnloadChunk:
|
case PacketTypesIn.UnloadChunk:
|
||||||
if (protocolversion >= MC_1_9_Version && handler.GetTerrainEnabled())
|
if (protocolVersion >= MC_1_9_Version && handler.GetTerrainEnabled())
|
||||||
{
|
{
|
||||||
int chunkX = dataTypes.ReadNextInt(packetData);
|
int chunkX = dataTypes.ReadNextInt(packetData);
|
||||||
int chunkZ = dataTypes.ReadNextInt(packetData);
|
int chunkZ = dataTypes.ReadNextInt(packetData);
|
||||||
|
|
@ -902,7 +902,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.PlayerInfo:
|
case PacketTypesIn.PlayerInfo:
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
{
|
{
|
||||||
int action = dataTypes.ReadNextVarInt(packetData); // Action Name
|
int action = dataTypes.ReadNextVarInt(packetData); // Action Name
|
||||||
int numberOfPlayers = dataTypes.ReadNextVarInt(packetData); // Number Of Players
|
int numberOfPlayers = dataTypes.ReadNextVarInt(packetData); // Number Of Players
|
||||||
|
|
@ -939,7 +939,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// 1.19 Additions
|
// 1.19 Additions
|
||||||
long? keyExpiration = null;
|
long? keyExpiration = null;
|
||||||
byte[]? publicKey = null, signature = null;
|
byte[]? publicKey = null, signature = null;
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
if (dataTypes.ReadNextBool(packetData)) // Has Sig Data (if true, red the following fields)
|
if (dataTypes.ReadNextBool(packetData)) // Has Sig Data (if true, red the following fields)
|
||||||
{
|
{
|
||||||
|
|
@ -995,7 +995,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.TabComplete:
|
case PacketTypesIn.TabComplete:
|
||||||
if (protocolversion >= MC_1_13_Version)
|
if (protocolVersion >= MC_1_13_Version)
|
||||||
{
|
{
|
||||||
autocomplete_transaction_id = dataTypes.ReadNextVarInt(packetData);
|
autocomplete_transaction_id = dataTypes.ReadNextVarInt(packetData);
|
||||||
dataTypes.ReadNextVarInt(packetData); // Start of text to replace
|
dataTypes.ReadNextVarInt(packetData); // Start of text to replace
|
||||||
|
|
@ -1008,7 +1008,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
for (int i = 0; i < autocomplete_count; i++)
|
for (int i = 0; i < autocomplete_count; i++)
|
||||||
{
|
{
|
||||||
autocomplete_result.Add(dataTypes.ReadNextString(packetData));
|
autocomplete_result.Add(dataTypes.ReadNextString(packetData));
|
||||||
if (protocolversion >= MC_1_13_Version)
|
if (protocolVersion >= MC_1_13_Version)
|
||||||
{
|
{
|
||||||
// Skip optional tooltip for each tab-complete result
|
// Skip optional tooltip for each tab-complete result
|
||||||
if (dataTypes.ReadNextBool(packetData))
|
if (dataTypes.ReadNextBool(packetData))
|
||||||
|
|
@ -1021,7 +1021,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.PluginMessage:
|
case PacketTypesIn.PluginMessage:
|
||||||
String channel = dataTypes.ReadNextString(packetData);
|
String channel = dataTypes.ReadNextString(packetData);
|
||||||
// Length is unneeded as the whole remaining packetData is the entire payload of the packet.
|
// Length is unneeded as the whole remaining packetData is the entire payload of the packet.
|
||||||
if (protocolversion < MC_1_8_Version)
|
if (protocolVersion < MC_1_8_Version)
|
||||||
pForge.ReadNextVarShort(packetData);
|
pForge.ReadNextVarShort(packetData);
|
||||||
handler.OnPluginChannelMessage(channel, packetData.ToArray());
|
handler.OnPluginChannelMessage(channel, packetData.ToArray());
|
||||||
return pForge.HandlePluginMessage(channel, packetData, ref currentDimension);
|
return pForge.HandlePluginMessage(channel, packetData, ref currentDimension);
|
||||||
|
|
@ -1029,13 +1029,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick, ChatParser.ParseText(dataTypes.ReadNextString(packetData)));
|
handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick, ChatParser.ParseText(dataTypes.ReadNextString(packetData)));
|
||||||
return false;
|
return false;
|
||||||
case PacketTypesIn.SetCompression:
|
case PacketTypesIn.SetCompression:
|
||||||
if (protocolversion >= MC_1_8_Version && protocolversion < MC_1_9_Version)
|
if (protocolVersion >= MC_1_8_Version && protocolVersion < MC_1_9_Version)
|
||||||
compression_treshold = dataTypes.ReadNextVarInt(packetData);
|
compression_treshold = dataTypes.ReadNextVarInt(packetData);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.OpenWindow:
|
case PacketTypesIn.OpenWindow:
|
||||||
if (handler.GetInventoryEnabled())
|
if (handler.GetInventoryEnabled())
|
||||||
{
|
{
|
||||||
if (protocolversion < MC_1_14_Version)
|
if (protocolVersion < MC_1_14_Version)
|
||||||
{
|
{
|
||||||
// MC 1.13 or lower
|
// MC 1.13 or lower
|
||||||
byte windowID = dataTypes.ReadNextByte(packetData);
|
byte windowID = dataTypes.ReadNextByte(packetData);
|
||||||
|
|
@ -1072,7 +1072,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
int stateId = -1;
|
int stateId = -1;
|
||||||
int elements = 0;
|
int elements = 0;
|
||||||
|
|
||||||
if (protocolversion >= MC_1_17_1_Version)
|
if (protocolVersion >= MC_1_17_1_Version)
|
||||||
{
|
{
|
||||||
// State ID and Elements as VarInt - 1.17.1 and above
|
// State ID and Elements as VarInt - 1.17.1 and above
|
||||||
stateId = dataTypes.ReadNextVarInt(packetData);
|
stateId = dataTypes.ReadNextVarInt(packetData);
|
||||||
|
|
@ -1092,7 +1092,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
inventorySlots[slotId] = item;
|
inventorySlots[slotId] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocolversion >= MC_1_17_1_Version) // Carried Item - 1.17.1 and above
|
if (protocolVersion >= MC_1_17_1_Version) // Carried Item - 1.17.1 and above
|
||||||
dataTypes.ReadNextItemSlot(packetData, itemPalette);
|
dataTypes.ReadNextItemSlot(packetData, itemPalette);
|
||||||
|
|
||||||
handler.OnWindowItems(windowId, inventorySlots, stateId);
|
handler.OnWindowItems(windowId, inventorySlots, stateId);
|
||||||
|
|
@ -1103,7 +1103,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
byte windowID = dataTypes.ReadNextByte(packetData);
|
byte windowID = dataTypes.ReadNextByte(packetData);
|
||||||
int stateId = -1;
|
int stateId = -1;
|
||||||
if (protocolversion >= MC_1_17_1_Version)
|
if (protocolVersion >= MC_1_17_1_Version)
|
||||||
stateId = dataTypes.ReadNextVarInt(packetData); // State ID - 1.17.1 and above
|
stateId = dataTypes.ReadNextVarInt(packetData); // State ID - 1.17.1 and above
|
||||||
short slotID = dataTypes.ReadNextShort(packetData);
|
short slotID = dataTypes.ReadNextShort(packetData);
|
||||||
Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette);
|
Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette);
|
||||||
|
|
@ -1126,7 +1126,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
string url = dataTypes.ReadNextString(packetData);
|
string url = dataTypes.ReadNextString(packetData);
|
||||||
string hash = dataTypes.ReadNextString(packetData);
|
string hash = dataTypes.ReadNextString(packetData);
|
||||||
bool forced = true; // Assume forced for MC 1.16 and below
|
bool forced = true; // Assume forced for MC 1.16 and below
|
||||||
if (protocolversion >= MC_1_17_Version)
|
if (protocolVersion >= MC_1_17_Version)
|
||||||
{
|
{
|
||||||
forced = dataTypes.ReadNextBool(packetData);
|
forced = dataTypes.ReadNextBool(packetData);
|
||||||
string forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
|
string forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
|
||||||
|
|
@ -1139,7 +1139,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
break;
|
break;
|
||||||
//Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory
|
//Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory
|
||||||
byte[] responseHeader = new byte[0];
|
byte[] responseHeader = new byte[0];
|
||||||
if (protocolversion < MC_1_10_Version) //MC 1.10 does not include resource pack hash in responses
|
if (protocolVersion < MC_1_10_Version) //MC 1.10 does not include resource pack hash in responses
|
||||||
responseHeader = dataTypes.ConcatBytes(dataTypes.GetVarInt(hash.Length), Encoding.UTF8.GetBytes(hash));
|
responseHeader = dataTypes.ConcatBytes(dataTypes.GetVarInt(hash.Length), Encoding.UTF8.GetBytes(hash));
|
||||||
SendPacket(PacketTypesOut.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(3))); //Accepted pack
|
SendPacket(PacketTypesOut.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(3))); //Accepted pack
|
||||||
SendPacket(PacketTypesOut.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(0))); //Successfully loaded
|
SendPacket(PacketTypesOut.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(0))); //Successfully loaded
|
||||||
|
|
@ -1155,7 +1155,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (handler.GetEntityHandlingEnabled())
|
if (handler.GetEntityHandlingEnabled())
|
||||||
{
|
{
|
||||||
int entityid = dataTypes.ReadNextVarInt(packetData);
|
int entityid = dataTypes.ReadNextVarInt(packetData);
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
{
|
{
|
||||||
bool hasNext;
|
bool hasNext;
|
||||||
do
|
do
|
||||||
|
|
@ -1216,7 +1216,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
bool hasFactorData = false;
|
bool hasFactorData = false;
|
||||||
Dictionary<string, object>? factorCodec = null;
|
Dictionary<string, object>? factorCodec = null;
|
||||||
|
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
hasFactorData = dataTypes.ReadNextBool(packetData);
|
hasFactorData = dataTypes.ReadNextBool(packetData);
|
||||||
factorCodec = dataTypes.ReadNextNbt(packetData);
|
factorCodec = dataTypes.ReadNextNbt(packetData);
|
||||||
|
|
@ -1230,7 +1230,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (handler.GetEntityHandlingEnabled())
|
if (handler.GetEntityHandlingEnabled())
|
||||||
{
|
{
|
||||||
int entityCount = 1; // 1.17.0 has only one entity per packet
|
int entityCount = 1; // 1.17.0 has only one entity per packet
|
||||||
if (protocolversion != MC_1_17_Version)
|
if (protocolVersion != MC_1_17_Version)
|
||||||
entityCount = dataTypes.ReadNextVarInt(packetData); // All other versions have a "count" field
|
entityCount = dataTypes.ReadNextVarInt(packetData); // All other versions have a "count" field
|
||||||
int[] entityList = new int[entityCount];
|
int[] entityList = new int[entityCount];
|
||||||
for (int i = 0; i < entityCount; i++)
|
for (int i = 0; i < entityCount; i++)
|
||||||
|
|
@ -1274,7 +1274,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (handler.GetEntityHandlingEnabled())
|
if (handler.GetEntityHandlingEnabled())
|
||||||
{
|
{
|
||||||
int EntityID = dataTypes.ReadNextVarInt(packetData);
|
int EntityID = dataTypes.ReadNextVarInt(packetData);
|
||||||
int NumberOfProperties = protocolversion >= MC_1_17_Version ? dataTypes.ReadNextVarInt(packetData) : dataTypes.ReadNextInt(packetData);
|
int NumberOfProperties = protocolVersion >= MC_1_17_Version ? dataTypes.ReadNextVarInt(packetData) : dataTypes.ReadNextInt(packetData);
|
||||||
Dictionary<string, Double> keys = new Dictionary<string, Double>();
|
Dictionary<string, Double> keys = new Dictionary<string, Double>();
|
||||||
for (int i = 0; i < NumberOfProperties; i++)
|
for (int i = 0; i < NumberOfProperties; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1313,11 +1313,11 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
// See https://wiki.vg/Entity_metadata#Living_Entity
|
// See https://wiki.vg/Entity_metadata#Living_Entity
|
||||||
int healthField = 7; // From 1.10 to 1.13.2
|
int healthField = 7; // From 1.10 to 1.13.2
|
||||||
if (protocolversion >= MC_1_14_Version)
|
if (protocolVersion >= MC_1_14_Version)
|
||||||
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_18_2_Version)
|
if (protocolVersion > MC_1_18_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))
|
||||||
|
|
@ -1361,7 +1361,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.UpdateHealth:
|
case PacketTypesIn.UpdateHealth:
|
||||||
float health = dataTypes.ReadNextFloat(packetData);
|
float health = dataTypes.ReadNextFloat(packetData);
|
||||||
int food;
|
int food;
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
food = dataTypes.ReadNextVarInt(packetData);
|
food = dataTypes.ReadNextVarInt(packetData);
|
||||||
else
|
else
|
||||||
food = dataTypes.ReadNextShort(packetData);
|
food = dataTypes.ReadNextShort(packetData);
|
||||||
|
|
@ -1376,12 +1376,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.Explosion:
|
case PacketTypesIn.Explosion:
|
||||||
Location explosionLocation;
|
Location explosionLocation;
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
explosionLocation = new(dataTypes.ReadNextDouble(packetData), dataTypes.ReadNextDouble(packetData), dataTypes.ReadNextDouble(packetData));
|
explosionLocation = new(dataTypes.ReadNextDouble(packetData), dataTypes.ReadNextDouble(packetData), dataTypes.ReadNextDouble(packetData));
|
||||||
else
|
else
|
||||||
explosionLocation = new(dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData));
|
explosionLocation = new(dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData));
|
||||||
float explosionStrength = dataTypes.ReadNextFloat(packetData);
|
float explosionStrength = dataTypes.ReadNextFloat(packetData);
|
||||||
int explosionBlockCount = protocolversion >= MC_1_17_Version
|
int explosionBlockCount = protocolVersion >= MC_1_17_Version
|
||||||
? dataTypes.ReadNextVarInt(packetData)
|
? dataTypes.ReadNextVarInt(packetData)
|
||||||
: dataTypes.ReadNextInt(packetData);
|
: dataTypes.ReadNextInt(packetData);
|
||||||
// Ignoring additional fields (records, pushback)
|
// Ignoring additional fields (records, pushback)
|
||||||
|
|
@ -1405,12 +1405,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.UpdateScore:
|
case PacketTypesIn.UpdateScore:
|
||||||
string entityname = dataTypes.ReadNextString(packetData);
|
string entityname = dataTypes.ReadNextString(packetData);
|
||||||
int action3 = protocolversion >= MC_1_18_2_Version
|
int action3 = protocolVersion >= MC_1_18_2_Version
|
||||||
? dataTypes.ReadNextVarInt(packetData)
|
? dataTypes.ReadNextVarInt(packetData)
|
||||||
: dataTypes.ReadNextByte(packetData);
|
: dataTypes.ReadNextByte(packetData);
|
||||||
string objectivename2 = string.Empty;
|
string objectivename2 = string.Empty;
|
||||||
int value = -1;
|
int value = -1;
|
||||||
if (action3 != 1 || protocolversion >= MC_1_8_Version)
|
if (action3 != 1 || protocolVersion >= MC_1_8_Version)
|
||||||
objectivename2 = dataTypes.ReadNextString(packetData);
|
objectivename2 = dataTypes.ReadNextString(packetData);
|
||||||
if (action3 != 1)
|
if (action3 != 1)
|
||||||
value = dataTypes.ReadNextVarInt(packetData);
|
value = dataTypes.ReadNextVarInt(packetData);
|
||||||
|
|
@ -1449,7 +1449,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
Translations.Get("exception.packet_process",
|
Translations.Get("exception.packet_process",
|
||||||
packetPalette.GetIncommingTypeById(packetID),
|
packetPalette.GetIncommingTypeById(packetID),
|
||||||
packetID,
|
packetID,
|
||||||
protocolversion,
|
protocolVersion,
|
||||||
login_phase,
|
login_phase,
|
||||||
innerException.GetType()),
|
innerException.GetType()),
|
||||||
innerException);
|
innerException);
|
||||||
|
|
@ -1551,7 +1551,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
/// <returns>True if login successful</returns>
|
/// <returns>True if login successful</returns>
|
||||||
public bool Login(PlayerKeyPair? playerKeyPair, SessionToken session)
|
public bool Login(PlayerKeyPair? playerKeyPair, SessionToken session)
|
||||||
{
|
{
|
||||||
byte[] protocol_version = dataTypes.GetVarInt(protocolversion);
|
byte[] protocol_version = dataTypes.GetVarInt(protocolVersion);
|
||||||
string server_address = pForge.GetServerAddress(handler.GetServerHost());
|
string server_address = pForge.GetServerAddress(handler.GetServerHost());
|
||||||
byte[] server_port = dataTypes.GetUShort((ushort)handler.GetServerPort());
|
byte[] server_port = dataTypes.GetUShort((ushort)handler.GetServerPort());
|
||||||
byte[] next_state = dataTypes.GetVarInt(2);
|
byte[] next_state = dataTypes.GetVarInt(2);
|
||||||
|
|
@ -1560,7 +1560,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
List<byte> fullLoginPacket = new List<byte>();
|
List<byte> fullLoginPacket = new List<byte>();
|
||||||
fullLoginPacket.AddRange(dataTypes.GetString(handler.GetUsername())); // Username
|
fullLoginPacket.AddRange(dataTypes.GetString(handler.GetUsername())); // Username
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
if (playerKeyPair == null)
|
if (playerKeyPair == null)
|
||||||
fullLoginPacket.AddRange(dataTypes.GetBool(false)); // Has Sig Data
|
fullLoginPacket.AddRange(dataTypes.GetBool(false)); // Has Sig Data
|
||||||
|
|
@ -1651,7 +1651,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// Encryption Response packet
|
// Encryption Response packet
|
||||||
List<byte> encryptionResponse = new();
|
List<byte> encryptionResponse = new();
|
||||||
encryptionResponse.AddRange(dataTypes.GetArray(RSAService.Encrypt(secretKey, false))); // Shared Secret
|
encryptionResponse.AddRange(dataTypes.GetArray(RSAService.Encrypt(secretKey, false))); // Shared Secret
|
||||||
if (protocolversion >= Protocol18Handler.MC_1_19_Version)
|
if (protocolVersion >= Protocol18Handler.MC_1_19_Version)
|
||||||
{
|
{
|
||||||
if (playerKeyPair == null)
|
if (playerKeyPair == null)
|
||||||
{
|
{
|
||||||
|
|
@ -1675,7 +1675,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
SendPacket(0x01, encryptionResponse);
|
SendPacket(0x01, encryptionResponse);
|
||||||
|
|
||||||
//Start client-side encryption
|
//Start client-side encryption
|
||||||
socketWrapper.SwitchToEncrypted(secretKey);
|
socketWrapper.SwitchToEncrypted(secretKey); // pre switch
|
||||||
|
|
||||||
//Process the next packet
|
//Process the next packet
|
||||||
int loopPrevention = UInt16.MaxValue;
|
int loopPrevention = UInt16.MaxValue;
|
||||||
|
|
@ -1697,7 +1697,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
Guid uuidReceived = dataTypes.ReadNextUUID(packetData);
|
Guid uuidReceived = dataTypes.ReadNextUUID(packetData);
|
||||||
string userName = dataTypes.ReadNextString(packetData);
|
string userName = dataTypes.ReadNextString(packetData);
|
||||||
Tuple<string, string, string>[]? playerProperty = null;
|
Tuple<string, string, string>[]? playerProperty = null;
|
||||||
if (protocolversion >= Protocol18Handler.MC_1_19_Version)
|
if (protocolVersion >= Protocol18Handler.MC_1_19_Version)
|
||||||
{
|
{
|
||||||
int count = dataTypes.ReadNextVarInt(packetData); // Number Of Properties
|
int count = dataTypes.ReadNextVarInt(packetData); // Number Of Properties
|
||||||
playerProperty = new Tuple<string, string, string>[count];
|
playerProperty = new Tuple<string, string, string>[count];
|
||||||
|
|
@ -1752,9 +1752,9 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
byte[] tabcomplete_packet = new byte[] { };
|
byte[] tabcomplete_packet = new byte[] { };
|
||||||
|
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
{
|
{
|
||||||
if (protocolversion >= MC_1_13_Version)
|
if (protocolVersion >= MC_1_13_Version)
|
||||||
{
|
{
|
||||||
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, transaction_id);
|
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, transaction_id);
|
||||||
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor));
|
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor));
|
||||||
|
|
@ -1763,7 +1763,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor));
|
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, dataTypes.GetString(BehindCursor));
|
||||||
|
|
||||||
if (protocolversion >= MC_1_9_Version)
|
if (protocolVersion >= MC_1_9_Version)
|
||||||
{
|
{
|
||||||
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, assume_command);
|
tabcomplete_packet = dataTypes.ConcatBytes(tabcomplete_packet, assume_command);
|
||||||
}
|
}
|
||||||
|
|
@ -1869,7 +1869,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
/// <returns>Max length, in characters</returns>
|
/// <returns>Max length, in characters</returns>
|
||||||
public int GetMaxChatMessageLength()
|
public int GetMaxChatMessageLength()
|
||||||
{
|
{
|
||||||
return protocolversion > MC_1_10_Version
|
return protocolVersion > MC_1_10_Version
|
||||||
? 256
|
? 256
|
||||||
: 100;
|
: 100;
|
||||||
}
|
}
|
||||||
|
|
@ -1883,7 +1883,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
/// <returns>Minecraft Protocol version number</returns>
|
/// <returns>Minecraft Protocol version number</returns>
|
||||||
public int GetProtocolVersion()
|
public int GetProtocolVersion()
|
||||||
{
|
{
|
||||||
return protocolversion;
|
return protocolVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2004,7 +2004,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Process Chat Command - 1.19 and above
|
// Process Chat Command - 1.19 and above
|
||||||
if (protocolversion >= MC_1_19_Version && message.StartsWith('/'))
|
if (protocolVersion >= MC_1_19_Version && message.StartsWith('/'))
|
||||||
return SendChatCommand(message[1..], playerKeyPair);
|
return SendChatCommand(message[1..], playerKeyPair);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -2014,7 +2014,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// Message: String (up to 256 chars)
|
// Message: String (up to 256 chars)
|
||||||
fields.AddRange(dataTypes.GetString(message));
|
fields.AddRange(dataTypes.GetString(message));
|
||||||
|
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
// Timestamp: Instant(Long)
|
// Timestamp: Instant(Long)
|
||||||
DateTimeOffset timeNow = DateTimeOffset.UtcNow;
|
DateTimeOffset timeNow = DateTimeOffset.UtcNow;
|
||||||
|
|
@ -2092,7 +2092,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
return false;
|
return false;
|
||||||
// Plugin channels were significantly changed between Minecraft 1.12 and 1.13
|
// Plugin channels were significantly changed between Minecraft 1.12 and 1.13
|
||||||
// https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14132#Plugin_Channels
|
// https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14132#Plugin_Channels
|
||||||
if (protocolversion >= MC_1_13_Version)
|
if (protocolVersion >= MC_1_13_Version)
|
||||||
{
|
{
|
||||||
return SendPluginChannelPacket("minecraft:brand", dataTypes.GetString(brandInfo));
|
return SendPluginChannelPacket("minecraft:brand", dataTypes.GetString(brandInfo));
|
||||||
}
|
}
|
||||||
|
|
@ -2120,26 +2120,26 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
List<byte> fields = new List<byte>();
|
List<byte> fields = new List<byte>();
|
||||||
fields.AddRange(dataTypes.GetString(language));
|
fields.AddRange(dataTypes.GetString(language));
|
||||||
fields.Add(viewDistance);
|
fields.Add(viewDistance);
|
||||||
fields.AddRange(protocolversion >= MC_1_9_Version
|
fields.AddRange(protocolVersion >= MC_1_9_Version
|
||||||
? dataTypes.GetVarInt(chatMode)
|
? dataTypes.GetVarInt(chatMode)
|
||||||
: new byte[] { chatMode });
|
: new byte[] { chatMode });
|
||||||
fields.Add(chatColors ? (byte)1 : (byte)0);
|
fields.Add(chatColors ? (byte)1 : (byte)0);
|
||||||
if (protocolversion < MC_1_8_Version)
|
if (protocolVersion < MC_1_8_Version)
|
||||||
{
|
{
|
||||||
fields.Add(difficulty);
|
fields.Add(difficulty);
|
||||||
fields.Add((byte)(skinParts & 0x1)); //show cape
|
fields.Add((byte)(skinParts & 0x1)); //show cape
|
||||||
}
|
}
|
||||||
else fields.Add(skinParts);
|
else fields.Add(skinParts);
|
||||||
if (protocolversion >= MC_1_9_Version)
|
if (protocolVersion >= MC_1_9_Version)
|
||||||
fields.AddRange(dataTypes.GetVarInt(mainHand));
|
fields.AddRange(dataTypes.GetVarInt(mainHand));
|
||||||
if (protocolversion >= MC_1_17_Version)
|
if (protocolVersion >= MC_1_17_Version)
|
||||||
{
|
{
|
||||||
if (protocolversion >= MC_1_18_1_Version)
|
if (protocolVersion >= MC_1_18_1_Version)
|
||||||
fields.Add(0); // 1.18 and above - Enable text filtering. (Always false)
|
fields.Add(0); // 1.18 and above - Enable text filtering. (Always false)
|
||||||
else
|
else
|
||||||
fields.Add(1); // 1.17 and 1.17.1 - Disable text filtering. (Always true)
|
fields.Add(1); // 1.17 and 1.17.1 - Disable text filtering. (Always true)
|
||||||
}
|
}
|
||||||
if (protocolversion >= MC_1_18_1_Version)
|
if (protocolVersion >= MC_1_18_1_Version)
|
||||||
fields.Add(1); // 1.18 and above - Allow server listings
|
fields.Add(1); // 1.18 and above - Allow server listings
|
||||||
SendPacket(PacketTypesOut.ClientSettings, fields);
|
SendPacket(PacketTypesOut.ClientSettings, fields);
|
||||||
}
|
}
|
||||||
|
|
@ -2175,7 +2175,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
SendPacket(packetType, dataTypes.ConcatBytes(
|
SendPacket(packetType, dataTypes.ConcatBytes(
|
||||||
dataTypes.GetDouble(location.X),
|
dataTypes.GetDouble(location.X),
|
||||||
dataTypes.GetDouble(location.Y),
|
dataTypes.GetDouble(location.Y),
|
||||||
protocolversion < MC_1_8_Version
|
protocolVersion < MC_1_8_Version
|
||||||
? dataTypes.GetDouble(location.Y + 1.62)
|
? dataTypes.GetDouble(location.Y + 1.62)
|
||||||
: new byte[0],
|
: new byte[0],
|
||||||
dataTypes.GetDouble(location.Z),
|
dataTypes.GetDouble(location.Z),
|
||||||
|
|
@ -2201,7 +2201,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
// In 1.7, length needs to be included.
|
// In 1.7, length needs to be included.
|
||||||
// In 1.8, it must not be.
|
// In 1.8, it must not be.
|
||||||
if (protocolversion < MC_1_8_Version)
|
if (protocolVersion < MC_1_8_Version)
|
||||||
{
|
{
|
||||||
byte[] length = BitConverter.GetBytes((short)data.Length);
|
byte[] length = BitConverter.GetBytes((short)data.Length);
|
||||||
Array.Reverse(length);
|
Array.Reverse(length);
|
||||||
|
|
@ -2256,7 +2256,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// Is player Sneaking (Only 1.16 and above)
|
// Is player Sneaking (Only 1.16 and above)
|
||||||
// Currently hardcoded to false
|
// Currently hardcoded to false
|
||||||
// TODO: Update to reflect the real player state
|
// TODO: Update to reflect the real player state
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
fields.AddRange(dataTypes.GetBool(false));
|
fields.AddRange(dataTypes.GetBool(false));
|
||||||
|
|
||||||
SendPacket(PacketTypesOut.InteractEntity, fields);
|
SendPacket(PacketTypesOut.InteractEntity, fields);
|
||||||
|
|
@ -2282,7 +2282,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// Is player Sneaking (Only 1.16 and above)
|
// Is player Sneaking (Only 1.16 and above)
|
||||||
// Currently hardcoded to false
|
// Currently hardcoded to false
|
||||||
// TODO: Update to reflect the real player state
|
// TODO: Update to reflect the real player state
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
fields.AddRange(dataTypes.GetBool(false));
|
fields.AddRange(dataTypes.GetBool(false));
|
||||||
SendPacket(PacketTypesOut.InteractEntity, fields);
|
SendPacket(PacketTypesOut.InteractEntity, fields);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2302,7 +2302,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// Is player Sneaking (Only 1.16 and above)
|
// Is player Sneaking (Only 1.16 and above)
|
||||||
// Currently hardcoded to false
|
// Currently hardcoded to false
|
||||||
// TODO: Update to reflect the real player state
|
// TODO: Update to reflect the real player state
|
||||||
if (protocolversion >= MC_1_16_Version)
|
if (protocolVersion >= MC_1_16_Version)
|
||||||
fields.AddRange(dataTypes.GetBool(false));
|
fields.AddRange(dataTypes.GetBool(false));
|
||||||
SendPacket(PacketTypesOut.InteractEntity, fields);
|
SendPacket(PacketTypesOut.InteractEntity, fields);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2318,7 +2318,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
public bool SendUseItem(int hand, int sequenceId)
|
public bool SendUseItem(int hand, int sequenceId)
|
||||||
{
|
{
|
||||||
if (protocolversion < MC_1_9_Version)
|
if (protocolVersion < MC_1_9_Version)
|
||||||
return false; // Packet does not exist prior to MC 1.9
|
return false; // Packet does not exist prior to MC 1.9
|
||||||
// According to https://wiki.vg/index.php?title=Protocol&oldid=5486#Player_Block_Placement
|
// According to https://wiki.vg/index.php?title=Protocol&oldid=5486#Player_Block_Placement
|
||||||
// MC 1.7 does this using Player Block Placement with special values
|
// MC 1.7 does this using Player Block Placement with special values
|
||||||
|
|
@ -2327,7 +2327,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
List<byte> packet = new List<byte>();
|
List<byte> packet = new List<byte>();
|
||||||
packet.AddRange(dataTypes.GetVarInt(hand));
|
packet.AddRange(dataTypes.GetVarInt(hand));
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
packet.AddRange(dataTypes.GetVarInt(sequenceId));
|
packet.AddRange(dataTypes.GetVarInt(sequenceId));
|
||||||
SendPacket(PacketTypesOut.UseItem, packet);
|
SendPacket(PacketTypesOut.UseItem, packet);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2345,7 +2345,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
packet.AddRange(dataTypes.GetVarInt(status));
|
packet.AddRange(dataTypes.GetVarInt(status));
|
||||||
packet.AddRange(dataTypes.GetLocation(location));
|
packet.AddRange(dataTypes.GetLocation(location));
|
||||||
packet.AddRange(dataTypes.GetVarInt(dataTypes.GetBlockFace(face)));
|
packet.AddRange(dataTypes.GetVarInt(dataTypes.GetBlockFace(face)));
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
packet.AddRange(dataTypes.GetVarInt(sequenceId));
|
packet.AddRange(dataTypes.GetVarInt(sequenceId));
|
||||||
SendPacket(PacketTypesOut.PlayerDigging, packet);
|
SendPacket(PacketTypesOut.PlayerDigging, packet);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2357,7 +2357,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
public bool SendPlayerBlockPlacement(int hand, Location location, Direction face, int sequenceId)
|
public bool SendPlayerBlockPlacement(int hand, Location location, Direction face, int sequenceId)
|
||||||
{
|
{
|
||||||
if (protocolversion < MC_1_14_Version)
|
if (protocolVersion < MC_1_14_Version)
|
||||||
return false; // NOT IMPLEMENTED for older MC versions
|
return false; // NOT IMPLEMENTED for older MC versions
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -2369,7 +2369,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
packet.AddRange(dataTypes.GetFloat(0.5f)); // cursorY
|
packet.AddRange(dataTypes.GetFloat(0.5f)); // cursorY
|
||||||
packet.AddRange(dataTypes.GetFloat(0.5f)); // cursorZ
|
packet.AddRange(dataTypes.GetFloat(0.5f)); // cursorZ
|
||||||
packet.Add(0); // insideBlock = false;
|
packet.Add(0); // insideBlock = false;
|
||||||
if (protocolversion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
packet.AddRange(dataTypes.GetVarInt(sequenceId));
|
packet.AddRange(dataTypes.GetVarInt(sequenceId));
|
||||||
SendPacket(PacketTypesOut.PlayerBlockPlacement, packet);
|
SendPacket(PacketTypesOut.PlayerBlockPlacement, packet);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2432,13 +2432,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
packet.Add((byte)windowId); // Window ID
|
packet.Add((byte)windowId); // Window ID
|
||||||
|
|
||||||
// 1.18+
|
// 1.18+
|
||||||
if (protocolversion >= MC_1_18_1_Version)
|
if (protocolVersion >= MC_1_18_1_Version)
|
||||||
{
|
{
|
||||||
packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID
|
packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID
|
||||||
packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID
|
packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID
|
||||||
}
|
}
|
||||||
// 1.17.1
|
// 1.17.1
|
||||||
else if (protocolversion == MC_1_17_1_Version)
|
else if (protocolVersion == MC_1_17_1_Version)
|
||||||
{
|
{
|
||||||
packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID
|
packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID
|
||||||
packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID
|
packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID
|
||||||
|
|
@ -2451,15 +2451,15 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
packet.Add(button); // Button
|
packet.Add(button); // Button
|
||||||
|
|
||||||
if (protocolversion < MC_1_17_Version)
|
if (protocolVersion < MC_1_17_Version)
|
||||||
packet.AddRange(dataTypes.GetShort(actionNumber));
|
packet.AddRange(dataTypes.GetShort(actionNumber));
|
||||||
|
|
||||||
if (protocolversion >= MC_1_9_Version)
|
if (protocolVersion >= MC_1_9_Version)
|
||||||
packet.AddRange(dataTypes.GetVarInt(mode)); // Mode
|
packet.AddRange(dataTypes.GetVarInt(mode)); // Mode
|
||||||
else packet.Add(mode);
|
else packet.Add(mode);
|
||||||
|
|
||||||
// 1.17+ Array of changed slots
|
// 1.17+ Array of changed slots
|
||||||
if (protocolversion >= MC_1_17_Version)
|
if (protocolVersion >= MC_1_17_Version)
|
||||||
{
|
{
|
||||||
packet.AddRange(dataTypes.GetVarInt(changedSlots.Count)); // Length of the array
|
packet.AddRange(dataTypes.GetVarInt(changedSlots.Count)); // Length of the array
|
||||||
foreach (var slot in changedSlots)
|
foreach (var slot in changedSlots)
|
||||||
|
|
@ -2502,12 +2502,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
List<byte> packet = new List<byte>();
|
List<byte> packet = new List<byte>();
|
||||||
|
|
||||||
if (protocolversion < MC_1_8_Version)
|
if (protocolVersion < MC_1_8_Version)
|
||||||
{
|
{
|
||||||
packet.AddRange(dataTypes.GetInt(playerid));
|
packet.AddRange(dataTypes.GetInt(playerid));
|
||||||
packet.Add((byte)1); // Swing arm
|
packet.Add((byte)1); // Swing arm
|
||||||
}
|
}
|
||||||
else if (protocolversion < MC_1_9_Version)
|
else if (protocolVersion < MC_1_9_Version)
|
||||||
{
|
{
|
||||||
// No fields in 1.8.X
|
// No fields in 1.8.X
|
||||||
}
|
}
|
||||||
|
|
@ -2575,7 +2575,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
public bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags)
|
public bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags)
|
||||||
{
|
{
|
||||||
if (protocolversion <= MC_1_13_Version)
|
if (protocolVersion <= MC_1_13_Version)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -2613,7 +2613,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
public bool SelectTrade(int selectedSlot)
|
public bool SelectTrade(int selectedSlot)
|
||||||
{
|
{
|
||||||
// MC 1.13 or greater
|
// MC 1.13 or greater
|
||||||
if (protocolversion >= MC_1_13_Version)
|
if (protocolVersion >= MC_1_13_Version)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -2632,7 +2632,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
public bool SendSpectate(Guid UUID)
|
public bool SendSpectate(Guid UUID)
|
||||||
{
|
{
|
||||||
// MC 1.8 or greater
|
// MC 1.8 or greater
|
||||||
if (protocolversion >= MC_1_8_Version)
|
if (protocolVersion >= MC_1_8_Version)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue