diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 01febacd..5c42c06b 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -220,20 +220,25 @@ namespace MinecraftClient.Protocol.Handlers int playerEntityID = dataTypes.ReadNextInt(packetData); handler.OnReceivePlayerEntityID(playerEntityID); handler.OnGamemodeUpdate(Guid.Empty, dataTypes.ReadNextByte(packetData)); - if (protocolversion >= MC116Version) - dataTypes.ReadNextByte(packetData); // Previous Gamemode - 1.16 and above - if (protocolversion >= MC116Version) - dataTypes.ReadNextVarInt(packetData); // World Count - 1.16 and above - if (protocolversion >= MC116Version) - dataTypes.ReadNextString(packetData); // World Names - 1.16 and above - if (protocolversion >= MC116Version) - dataTypes.ReadNextNbt(packetData); // Dimension Codec - 1.16 and above - //Current dimension - String identifier in 1.16, number below 1.16 - if (protocolversion >= MC191Version) + if (protocolversion >= MC116Version) + { + dataTypes.ReadNextByte(packetData); // Previous Gamemode - 1.16 and above + int worldCount = dataTypes.ReadNextVarInt(packetData); // World Count - 1.16 and above + for (int i = 0; i < worldCount; i++) + dataTypes.ReadNextString(packetData); // World Names - 1.16 and above + dataTypes.ReadNextNbt(packetData); // Dimension Codec - 1.16 and above + } + + //Current dimension - String identifier in 1.16, varInt below 1.16, byte below 1.9.1 + if (protocolversion >= MC116Version) + { + // TODO handle dimensions for 1.16+, needed for terrain handling + dataTypes.ReadNextString(packetData); + this.currentDimension = 0; + } + else if (protocolversion >= MC191Version) this.currentDimension = dataTypes.ReadNextInt(packetData); - else if (protocolversion >= MC116Version) - this.currentDimension = dataTypes.ReadNextString(packetData); else this.currentDimension = (sbyte)dataTypes.ReadNextByte(packetData); @@ -254,10 +259,12 @@ namespace MinecraftClient.Protocol.Handlers dataTypes.ReadNextBool(packetData); // Reduced debug info - 1.8 and above if (protocolversion >= MC115Version) dataTypes.ReadNextBool(packetData); // Enable respawn screen - 1.15 and above + if (protocolversion >= MC116Version) + { dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above - if (protocolversion >= MC116Version) dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above + } break; case PacketIncomingType.ChatMessage: string message = dataTypes.ReadNextString(packetData); @@ -273,27 +280,34 @@ namespace MinecraftClient.Protocol.Handlers handler.OnTextReceived(message, true); break; case PacketIncomingType.Respawn: - if (protocolversion >= MC116Version) - this.currentDimension = dataTypes.ReadNextString(packetData); //In 1.16 it was changed to "Identifier" which seems to be a string - else - this.currentDimension = dataTypes.ReadNextInt(packetData); - if (protocolversion >= MC116Version) - dataTypes.ReadNextString(packetData); // World Name - 1.16 and above - 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); // Gamemode - if (protocolversion >= MC116Version) - dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above if (protocolversion < MC116Version) - dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below + { + // TODO handle dimensions for 1.16+, needed for terrain handling + dataTypes.ReadNextString(packetData); + this.currentDimension = 0; + } + else + { + // 1.15 and below + this.currentDimension = dataTypes.ReadNextInt(packetData); + } if (protocolversion >= MC116Version) - dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above + dataTypes.ReadNextString(packetData); // World Name - 1.16 and above + 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); // Gamemode if (protocolversion >= MC116Version) - dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above + dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above + if (protocolversion < MC116Version) + dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below if (protocolversion >= MC116Version) - dataTypes.ReadNextBool(packetData); // Copy metadata - 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); // Copy metadata - 1.16 and above + } handler.OnRespawn(); break; case PacketIncomingType.PlayerPositionAndLook: