Add support for Minecraft 1.15

See #834
This commit is contained in:
ORelio 2019-12-14 14:22:24 +01:00
parent 52d98538b3
commit c6f00ce686
9 changed files with 1863 additions and 7 deletions

View file

@ -35,6 +35,7 @@ namespace MinecraftClient.Protocol.Handlers
internal const int MC113Version = 393;
internal const int MC114Version = 477;
internal const int MC1144Version = 498;
internal const int MC115Version = 573;
private int compression_treshold = 0;
private bool autocomplete_received = false;
@ -62,7 +63,7 @@ namespace MinecraftClient.Protocol.Handlers
this.pForge = new Protocol18Forge(forgeInfo, protocolVersion, dataTypes, this, handler);
this.pTerrain = new Protocol18Terrain(protocolVersion, dataTypes, handler);
if (handler.GetTerrainEnabled() && protocolversion > MC1144Version)
if (handler.GetTerrainEnabled() && protocolversion > MC115Version)
{
ConsoleIO.WriteLineFormatted("§8Terrain & Movements currently not handled for that MC version.");
handler.SetTerrainEnabled(false);
@ -76,9 +77,11 @@ namespace MinecraftClient.Protocol.Handlers
if (protocolversion >= MC113Version)
{
if (protocolVersion > MC1144Version && handler.GetTerrainEnabled())
if (protocolVersion > MC115Version && handler.GetTerrainEnabled())
throw new NotImplementedException("Please update block types handling for this Minecraft version. See Material.cs");
if (protocolVersion >= MC114Version)
if (protocolVersion >= MC115Version)
Block.Palette = new Palette115();
else if (protocolVersion >= MC114Version)
Block.Palette = new Palette114();
else Block.Palette = new Palette113();
}
@ -197,12 +200,16 @@ namespace MinecraftClient.Protocol.Handlers
this.currentDimension = (sbyte)dataTypes.ReadNextByte(packetData);
if (protocolversion < MC114Version)
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
if (protocolversion >= MC115Version)
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
dataTypes.ReadNextByte(packetData);
dataTypes.ReadNextString(packetData);
if (protocolversion >= MC114Version)
dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above
if (protocolversion >= MC18Version)
dataTypes.ReadNextBool(packetData); // Reduced debug info - 1.8 and above
if (protocolversion >= MC115Version)
dataTypes.ReadNextBool(packetData); // Enable respawn screen - 1.15 and above
break;
case PacketIncomingType.ChatMessage:
string message = dataTypes.ReadNextString(packetData);
@ -221,6 +228,8 @@ namespace MinecraftClient.Protocol.Handlers
this.currentDimension = dataTypes.ReadNextInt(packetData);
if (protocolversion < MC114Version)
dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below
if (protocolversion >= MC115Version)
dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above
dataTypes.ReadNextByte(packetData);
dataTypes.ReadNextString(packetData);
handler.OnRespawn();
@ -275,6 +284,8 @@ namespace MinecraftClient.Protocol.Handlers
{
if (protocolversion >= MC114Version)
dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above
if (protocolversion >= MC115Version && chunksContinuous)
dataTypes.ReadData(1024 * 4, packetData); // Biomes - 1.15 and above
int dataSize = dataTypes.ReadNextVarInt(packetData);
pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, 0, false, chunksContinuous, currentDimension, packetData);
}

View file

@ -147,7 +147,7 @@ namespace MinecraftClient.Protocol.Handlers
default: return PacketIncomingType.UnknownPacket;
}
}
else // MC 1.14
else if (protocol < Protocol18Handler.MC115Version) // MC 1.14 to 1.14.4
{
switch (packetID)
{
@ -172,6 +172,31 @@ namespace MinecraftClient.Protocol.Handlers
default: return PacketIncomingType.UnknownPacket;
}
}
else // MC 1.15
{
switch (packetID)
{
case 0x21: return PacketIncomingType.KeepAlive;
case 0x26: return PacketIncomingType.JoinGame;
case 0x0F: return PacketIncomingType.ChatMessage;
case 0x3B: return PacketIncomingType.Respawn;
case 0x36: return PacketIncomingType.PlayerPositionAndLook;
case 0x22: return PacketIncomingType.ChunkData;
case 0x10: return PacketIncomingType.MultiBlockChange;
case 0x0C: return PacketIncomingType.BlockChange;
case 0x1E: return PacketIncomingType.UnloadChunk;
case 0x34: return PacketIncomingType.PlayerListUpdate;
case 0x11: return PacketIncomingType.TabCompleteResult;
case 0x19: return PacketIncomingType.PluginMessage;
case 0x1B: return PacketIncomingType.KickPacket;
case 0x3A: return PacketIncomingType.ResourcePackSend;
case 0x2F: return PacketIncomingType.OpenWindow;
case 0x14: return PacketIncomingType.CloseWindow;
case 0x15: return PacketIncomingType.WindowItems;
case 0x17: return PacketIncomingType.SetSlot;
default: return PacketIncomingType.UnknownPacket;
}
}
}
/// <summary>
@ -262,7 +287,7 @@ namespace MinecraftClient.Protocol.Handlers
case PacketOutgoingType.TeleportConfirm: return 0x00;
}
}
else // MC 1.14
else // MC 1.14 to 1.15
{
switch (packet)
{

View file

@ -111,7 +111,7 @@ namespace MinecraftClient.Protocol
int[] supportedVersions_Protocol16 = { 51, 60, 61, 72, 73, 74, 78 };
if (Array.IndexOf(supportedVersions_Protocol16, ProtocolVersion) > -1)
return new Protocol16Handler(Client, ProtocolVersion, Handler);
int[] supportedVersions_Protocol18 = { 4, 5, 47, 107, 108, 109, 110, 210, 315, 316, 335, 338, 340, 393, 401, 404, 477, 480, 485, 490, 498 };
int[] supportedVersions_Protocol18 = { 4, 5, 47, 107, 108, 109, 110, 210, 315, 316, 335, 338, 340, 393, 401, 404, 477, 480, 485, 490, 498, 573 };
if (Array.IndexOf(supportedVersions_Protocol18, ProtocolVersion) > -1)
return new Protocol18Handler(Client, ProtocolVersion, Handler, forgeInfo);
throw new NotSupportedException("The protocol version no." + ProtocolVersion + " is not supported.");
@ -211,6 +211,9 @@ namespace MinecraftClient.Protocol
return 490;
case "1.14.4":
return 498;
case "1.15":
case "1.15.0":
return 573;
default:
return 0;
}