Updated the protocol for 1.16/1.16.1. Fixed Auto Attack (Added a new field (sneaking) to the Interact Entity event (Only 1.16 and above)). Added Entity Pallete for 1.16/1.16.1.

This commit is contained in:
Dusan Milutinovic 2020-07-27 12:43:32 +02:00 committed by ORelio
parent e542612e76
commit a58e975630
6 changed files with 173 additions and 33 deletions

View file

@ -671,6 +671,18 @@ namespace MinecraftClient.Protocol.Handlers
return bytes.ToArray();
}
/// <summary>
/// Build an boolean for sending over the network
/// </summary>
/// <param name="paramBool">Boolean to encode</param>
/// <returns>Byte array for this boolean</returns>
public byte[] GetVarBool(bool paramBool)
{
List<byte> bytes = new List<byte>();
bytes.Add((byte)Convert.ToByte(paramBool));
return bytes.ToArray();
}
/// <summary>
/// Get byte array representing a long integer
/// </summary>

View file

@ -84,7 +84,7 @@ namespace MinecraftClient.Protocol.Handlers
handler.SetInventoryEnabled(false);
}
if (handler.GetEntityHandlingEnabled() && (protocolversion <= MC1122Version || protocolversion > MC1152Version))
if (handler.GetEntityHandlingEnabled() && (protocolversion <= MC1122Version || protocolversion > MC1161Version))
{
ConsoleIO.WriteLineFormatted("§8Entities are currently not handled for that MC version.");
handler.SetEntityHandlingEnabled(false);
@ -104,11 +104,13 @@ namespace MinecraftClient.Protocol.Handlers
if (protocolversion >= MC114Version)
{
if (protocolversion > MC1152Version && handler.GetEntityHandlingEnabled())
if (protocolversion > MC1161Version && handler.GetEntityHandlingEnabled())
throw new NotImplementedException("Please update entity types handling for this Minecraft version. See EntityType.cs");
if (protocolversion >= MC115Version)
entityPalette = new EntityPalette115();
else entityPalette = new EntityPalette114();
if (protocolversion < MC115Version)
entityPalette = new EntityPalette114();
if (protocolversion > MC115Version)
entityPalette = new EntityPalette116();
else entityPalette = new EntityPalette115();
}
else entityPalette = new EntityPalette113();
}
@ -1436,6 +1438,13 @@ namespace MinecraftClient.Protocol.Handlers
List<byte> fields = new List<byte>();
fields.AddRange(dataTypes.GetVarInt(EntityID));
fields.AddRange(dataTypes.GetVarInt(type));
// Is player Sneaking (Only 1.16 and above)
// Currently hardcoded to false
// TODO: Update to reflect the real player state
if (protocolversion >= MC116Version)
fields.AddRange(dataTypes.GetVarBool(false));
SendPacket(PacketOutgoingType.InteractEntity, fields);
return true;
}

View file

@ -385,9 +385,9 @@ namespace MinecraftClient.Protocol.Handlers
case 0x29: return PacketIncomingType.EntityPositionAndRotation;
case 0x58: return PacketIncomingType.EntityProperties;
case 0x56: return PacketIncomingType.EntityTeleport;
case 0x46: return PacketIncomingType.EntityVelocity;
case 0x46: return PacketIncomingType.EntityVelocity; // This is maybe entity moving, not sure
case 0x47: return PacketIncomingType.EntityEquipment;
case 0x5A: return PacketIncomingType.EntityEffect;
case 0x59: return PacketIncomingType.EntityEffect;
case 0x4E: return PacketIncomingType.TimeUpdate;
case 0x49: return PacketIncomingType.UpdateHealth;
case 0x48: return PacketIncomingType.SetExperience;
@ -605,12 +605,12 @@ namespace MinecraftClient.Protocol.Handlers
case PacketOutgoingType.UseItem: return 0x2E;
case PacketOutgoingType.ClickWindow: return 0x09;
case PacketOutgoingType.CloseWindow: return 0x0A;
case PacketOutgoingType.PlayerBlockPlacement: return 0x2C;
case PacketOutgoingType.PlayerBlockPlacement: return 0x2D;
case PacketOutgoingType.CreativeInventoryAction: return 0x27;
case PacketOutgoingType.Animation: return 0x2B;
case PacketOutgoingType.PlayerDigging: return 0x1B;
case PacketOutgoingType.UpdateSign: return 0x2A;
case PacketOutgoingType.UpdateCommandBlock: return 0x24;
case PacketOutgoingType.UpdateCommandBlock: return 0x25;
}
}