Skip to content

Commit

Permalink
before 1.20.3, ClientInformation packet is sent in GameState play ins…
Browse files Browse the repository at this point in the history
…tead of configuration
  • Loading branch information
psu-de committed Aug 16, 2024
1 parent 4ac5bd7 commit dffc0a8
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Components/MineSharp.Protocol/MinecraftClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using MineSharp.Auth;
using MineSharp.ChatComponent;
using MineSharp.ChatComponent.Components;
using MineSharp.Core;
using MineSharp.Core.Common.Protocol;
using MineSharp.Core.Concurrency;
using MineSharp.Core.Events;
Expand All @@ -23,6 +24,9 @@
using Newtonsoft.Json.Linq;
using NLog;

using PlayClientInformationPacket = MineSharp.Protocol.Packets.Serverbound.Play.ClientInformationPacket;
using ConfigurationClientInformationPacket = MineSharp.Protocol.Packets.Serverbound.Configuration.ClientInformationPacket;

namespace MineSharp.Protocol;

/// <summary>
Expand Down Expand Up @@ -395,15 +399,28 @@ public Task WaitForGame()

internal Task SendClientInformationPacket()
{
return SendPacket(new ClientInformationPacket(
Settings.Locale,
Settings.ViewDistance,
Settings.ChatMode,
Settings.ColoredChat,
Settings.DisplayedSkinParts,
Settings.MainHand,
Settings.EnableTextFiltering,
Settings.AllowServerListings));
IPacket packet = Data.Version.Protocol >= ProtocolVersion.V_1_20_3
? new ConfigurationClientInformationPacket(
Settings.Locale,
Settings.ViewDistance,
Settings.ChatMode,
Settings.ColoredChat,
Settings.DisplayedSkinParts,
Settings.MainHand,
Settings.EnableTextFiltering,
Settings.AllowServerListings)
: new PlayClientInformationPacket(
Settings.Locale,
Settings.ViewDistance,
Settings.ChatMode,
Settings.ColoredChat,
Settings.DisplayedSkinParts,
Settings.MainHand,
Settings.EnableTextFiltering,
Settings.AllowServerListings
);

return SendPacket(packet);
}

internal async Task ChangeGameState(GameState next)
Expand Down

0 comments on commit dffc0a8

Please sign in to comment.