Tested on all versions 1.8 +

Fixed 1.14 not working at all.
This commit is contained in:
Milutinke 2022-09-22 19:36:24 +02:00
parent f47c240920
commit 12c8a60ad7
3 changed files with 68 additions and 18 deletions

View file

@ -584,6 +584,7 @@ namespace MinecraftClient.Protocol.Handlers
{ {
Dictionary<int, object?> data = new(); Dictionary<int, object?> data = new();
byte key = ReadNextByte(cache); byte key = ReadNextByte(cache);
while (key != 0xff) while (key != 0xff)
{ {
int type = ReadNextVarInt(cache); int type = ReadNextVarInt(cache);
@ -599,6 +600,7 @@ namespace MinecraftClient.Protocol.Handlers
type += 1; type += 1;
} }
} }
// Value's data type is depended on Type // Value's data type is depended on Type
object? value = null; object? value = null;

View file

@ -62,7 +62,7 @@ namespace MinecraftClient.Protocol.Handlers
p = new PacketPalette112(); p = new PacketPalette112();
else if (protocol <= Protocol18Handler.MC_1_12_2_Version) else if (protocol <= Protocol18Handler.MC_1_12_2_Version)
p = new PacketPalette1122(); p = new PacketPalette1122();
else if (protocol <= Protocol18Handler.MC_1_14_Version) else if (protocol < Protocol18Handler.MC_1_14_Version)
p = new PacketPalette113(); p = new PacketPalette113();
else if (protocol <= Protocol18Handler.MC_1_15_Version) else if (protocol <= Protocol18Handler.MC_1_15_Version)
p = new PacketPalette114(); p = new PacketPalette114();

View file

@ -4,23 +4,22 @@ using System.Linq;
using System.Text; using System.Text;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using System.Security.Cryptography;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Collections.Concurrent;
using MinecraftClient.Crypto; using MinecraftClient.Crypto;
using MinecraftClient.Proxy; using MinecraftClient.Proxy;
using System.Security.Cryptography;
using MinecraftClient.Mapping; using MinecraftClient.Mapping;
using MinecraftClient.Mapping.BlockPalettes; using MinecraftClient.Mapping.BlockPalettes;
using MinecraftClient.Mapping.EntityPalettes; using MinecraftClient.Mapping.EntityPalettes;
using MinecraftClient.Protocol.Handlers.Forge; using MinecraftClient.Protocol.Handlers.Forge;
using MinecraftClient.Inventory; using MinecraftClient.Inventory;
using System.Diagnostics;
using MinecraftClient.Inventory.ItemPalettes; using MinecraftClient.Inventory.ItemPalettes;
using MinecraftClient.Protocol.Handlers.PacketPalettes; using MinecraftClient.Protocol.Handlers.PacketPalettes;
using MinecraftClient.Logger; using MinecraftClient.Logger;
using System.Threading.Tasks;
using MinecraftClient.Protocol.Keys; using MinecraftClient.Protocol.Keys;
using System.Text.RegularExpressions;
using MinecraftClient.Protocol.Session; using MinecraftClient.Protocol.Session;
using System.Collections.Concurrent;
using MinecraftClient.Protocol.Message; using MinecraftClient.Protocol.Message;
namespace MinecraftClient.Protocol.Handlers namespace MinecraftClient.Protocol.Handlers
@ -45,6 +44,7 @@ namespace MinecraftClient.Protocol.Handlers
internal const int MC_1_12_Version = 335; internal const int MC_1_12_Version = 335;
internal const int MC_1_12_2_Version = 340; internal const int MC_1_12_2_Version = 340;
internal const int MC_1_13_Version = 393; internal const int MC_1_13_Version = 393;
internal const int MC_1_13_2_Version = 404;
internal const int MC_1_14_Version = 477; internal const int MC_1_14_Version = 477;
internal const int MC_1_15_Version = 573; internal const int MC_1_15_Version = 573;
internal const int MC_1_15_2_Version = 578; internal const int MC_1_15_2_Version = 578;
@ -781,23 +781,42 @@ namespace MinecraftClient.Protocol.Handlers
} }
break; break;
case PacketTypesIn.MapData: case PacketTypesIn.MapData:
if (protocolVersion < MC_1_8_Version)
break;
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);
// 1.9 +
bool trackingPosition = true;
// 1.14+
bool locked = false; bool locked = false;
if (protocolVersion >= MC_1_14_Version)
{ // 1.17+ (locked and trackingPosition switched places)
locked = dataTypes.ReadNextBool(packetData);
}
if (protocolVersion >= MC_1_17_Version) if (protocolVersion >= MC_1_17_Version)
{ {
trackingPosition = dataTypes.ReadNextBool(packetData); if (protocolVersion >= MC_1_14_Version)
locked = dataTypes.ReadNextBool(packetData);
if (protocolVersion >= MC_1_9_Version)
trackingPosition = dataTypes.ReadNextBool(packetData);
}
else
{
if (protocolVersion >= MC_1_9_Version)
trackingPosition = dataTypes.ReadNextBool(packetData);
if (protocolVersion >= MC_1_14_Version)
locked = dataTypes.ReadNextBool(packetData);
} }
int iconcount = 0; int iconcount = 0;
List<MapIcon> icons = new(); List<MapIcon> icons = new();
if (trackingPosition) // 1,9 + = needs tracking position to be true to get the icons
if (protocolVersion > MC_1_9_Version ? trackingPosition : true)
{ {
iconcount = dataTypes.ReadNextVarInt(packetData); iconcount = dataTypes.ReadNextVarInt(packetData);
@ -805,14 +824,43 @@ namespace MinecraftClient.Protocol.Handlers
{ {
MapIcon mapIcon = new(); MapIcon mapIcon = new();
mapIcon.Type = (MapIconType)dataTypes.ReadNextVarInt(packetData); // 1.8 - 1.13
if (protocolVersion < MC_1_13_2_Version)
{
byte directionAndtype = dataTypes.ReadNextByte(packetData);
byte direction, type;
// 1.12.2+
if (protocolVersion >= MC_1_12_2_Version)
{
direction = (byte)(directionAndtype & 0xF);
type = (byte)((directionAndtype >> 4) & 0xF);
}
else // 1.8 - 1.12
{
direction = (byte)((directionAndtype >> 4) & 0xF);
type = (byte)(directionAndtype & 0xF);
}
mapIcon.Type = (MapIconType)type;
mapIcon.Direction = direction;
}
// 1.13.2+
if (protocolVersion >= MC_1_13_2_Version)
mapIcon.Type = (MapIconType)dataTypes.ReadNextVarInt(packetData);
mapIcon.X = dataTypes.ReadNextByte(packetData); mapIcon.X = dataTypes.ReadNextByte(packetData);
mapIcon.Z = dataTypes.ReadNextByte(packetData); mapIcon.Z = dataTypes.ReadNextByte(packetData);
mapIcon.Direction = dataTypes.ReadNextByte(packetData);
bool mapIconHasDisplayName = dataTypes.ReadNextBool(packetData);
if (mapIconHasDisplayName) // 1.13.2+
mapIcon.DisplayName = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); if (protocolVersion >= MC_1_13_2_Version)
{
mapIcon.Direction = dataTypes.ReadNextByte(packetData);
if (dataTypes.ReadNextBool(packetData)) // Has Display Name?
mapIcon.DisplayName = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
}
icons.Add(mapIcon); icons.Add(mapIcon);
} }