diff --git a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs new file mode 100644 index 0000000000..f30ce07393 --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs @@ -0,0 +1,16 @@ +namespace MinecraftClient.Protocol.Handlers; + +public enum ConfigurationPacketTypesIn +{ + PluginMessage, + Disconnect, + FinishConfiguration, + KeepAlive, + Ping, + RegistryData, + ResourcePack, + FeatureFlags, + UpdateTags, + + Unknown +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs new file mode 100644 index 0000000000..f951a38d0f --- /dev/null +++ b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs @@ -0,0 +1,13 @@ +namespace MinecraftClient.Protocol.Handlers; + +public enum ConfigurationPacketTypesOut +{ + ClientInformation, + PluginMessage, + FinishConfiguration, + KeepAlive, + Pong, + ResourcePackResponse, + + Unknown +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette110.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette110.cs index 5b514ab45e..aed6e52bfb 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette110.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette110.cs @@ -118,14 +118,9 @@ public class PacketPalette110 : PacketTypePalette { 0x1D, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette112.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette112.cs index 4aa74ef05b..4479e3402a 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette112.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette112.cs @@ -124,14 +124,9 @@ public class PacketPalette112 : PacketTypePalette { 0x20, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1122.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1122.cs index 1c32571e12..401d0d3cf7 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1122.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1122.cs @@ -125,14 +125,9 @@ public class PacketPalette1122 : PacketTypePalette { 0x20, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette113.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette113.cs index cee9407a87..c17bccd796 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette113.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette113.cs @@ -141,14 +141,9 @@ public class PacketPalette113 : PacketTypePalette { 0x2A, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette114.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette114.cs index 5a30a16b84..ef9cebf552 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette114.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette114.cs @@ -151,14 +151,9 @@ public class PacketPalette114 : PacketTypePalette { 0x2D, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette115.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette115.cs index ce50911b09..c1b7f21f0b 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette115.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette115.cs @@ -151,14 +151,9 @@ public class PacketPalette115 : PacketTypePalette { 0x2D, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette116.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette116.cs index 0a160cc807..334f1270f5 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette116.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette116.cs @@ -151,14 +151,9 @@ public class PacketPalette116 : PacketTypePalette { 0x2E, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1162.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1162.cs index aa6b97a837..4894a79cd6 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1162.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1162.cs @@ -152,14 +152,9 @@ public class PacketPalette1162 : PacketTypePalette { 0x2F, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette117.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette117.cs index b191982781..305bf52f42 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette117.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette117.cs @@ -163,14 +163,9 @@ public class PacketPalette117 : PacketTypePalette { 0x2F, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette118.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette118.cs index dd984047f8..e249ab43ca 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette118.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette118.cs @@ -164,14 +164,9 @@ public class PacketPalette118 : PacketTypePalette { 0x2F, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette119.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette119.cs index 6c16552b04..990da3e14d 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette119.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette119.cs @@ -118,7 +118,7 @@ public class PacketPalette119 : PacketTypePalette { 0x00, PacketTypesOut.TeleportConfirm }, // (Wiki name: Confirm Teleportation) { 0x01, PacketTypesOut.QueryBlockNBT }, // (Wiki name: Query Block Entity Tag) { 0x02, PacketTypesOut.SetDifficulty }, // (Wiki name: Change Difficutly) - { 0x03, PacketTypesOut.MessageAcknowledgment }, // TODO + { 0x03, PacketTypesOut.MessageAcknowledgment }, // { 0x04, PacketTypesOut.ChatCommand }, // Added in 1.19 { 0x05, PacketTypesOut.ChatMessage }, // Changed in 1.19 (Completely changed) (Wiki name: Chat) { 0x06, PacketTypesOut.ClientStatus }, // (Wiki name: Client Command) @@ -147,7 +147,7 @@ public class PacketPalette119 : PacketTypePalette { 0x1D, PacketTypesOut.EntityAction }, // (Wiki name: Player Command) { 0x1E, PacketTypesOut.SteerVehicle }, // (Wiki name: Player Input) { 0x1F, PacketTypesOut.Pong }, // (Wiki name: Pong (play)) - { 0x20, PacketTypesOut.PlayerSession }, // Added in 1.19.3 TODO + { 0x20, PacketTypesOut.PlayerSession }, // Added in 1.19.3 { 0x21, PacketTypesOut.SetDisplayedRecipe }, // (Wiki name: Recipe Book Change Settings) { 0x22, PacketTypesOut.SetRecipeBookState }, // (Wiki name: Recipe Book Seen Recipe) { 0x23, PacketTypesOut.NameItem }, // (Wiki name: Rename Item) @@ -168,14 +168,9 @@ public class PacketPalette119 : PacketTypePalette { 0x32, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item) }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1192.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1192.cs index 1f7439458d..2920fd968e 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1192.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1192.cs @@ -171,14 +171,9 @@ public class PacketPalette1192 : PacketTypePalette { 0x32, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item) }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1193.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1193.cs index 39c4760f92..d098c76c4d 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1193.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1193.cs @@ -170,14 +170,9 @@ public class PacketPalette1193 : PacketTypePalette { 0x32, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item) }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1194.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1194.cs index 8dd9f9948c..fd65461a1f 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1194.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1194.cs @@ -175,14 +175,9 @@ public class PacketPalette1194 : PacketTypePalette { 0x32, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item) }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1202.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1202.cs index 633314863f..1e771589fe 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1202.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1202.cs @@ -18,8 +18,8 @@ public class PacketPalette1202 : PacketTypePalette { 0x09, PacketTypesIn.BlockChange }, // (Wiki name: Block Update) { 0x0A, PacketTypesIn.BossBar }, // { 0x0B, PacketTypesIn.ServerDifficulty }, // (Wiki name: Change Difficulty) - { 0x0C, PacketTypesIn.ChunkBatchFinished }, // Added in 1.20.2 - TODO - { 0x0D, PacketTypesIn.ChunkBatchStarted }, // Added in 1.20.2 - TODO + { 0x0C, PacketTypesIn.ChunkBatchFinished }, // Added in 1.20.2 + { 0x0D, PacketTypesIn.ChunkBatchStarted }, // Added in 1.20.2 { 0x0E, PacketTypesIn.ChunksBiomes }, // Added in 1.19.4 { 0x0F, PacketTypesIn.ClearTiles }, // { 0x10, PacketTypesIn.TabComplete }, // (Wiki name: Command Suggestions Response) @@ -47,7 +47,7 @@ public class PacketPalette1202 : PacketTypePalette { 0x26, PacketTypesIn.Effect }, // (Wiki name: World Event) { 0x27, PacketTypesIn.Particle }, // Changed in 1.19 ("Particle Data" field is now "Max Speed", it's the same Float data type) (Wiki name: Level Particle) (No need to be implemented) { 0x28, PacketTypesIn.UpdateLight }, // (Wiki name: Light Update) - { 0x29, PacketTypesIn.JoinGame }, // Changed in 1.20.2 (Wiki name: Login (play)) - TODO + { 0x29, PacketTypesIn.JoinGame }, // Changed in 1.20.2 (Wiki name: Login (play)) { 0x2A, PacketTypesIn.MapData }, // (Wiki name: Map Item Data) { 0x2B, PacketTypesIn.TradeList }, // (Wiki name: Merchant Offers) { 0x2C, PacketTypesIn.EntityPosition }, // (Wiki name: Move Entity Position) @@ -58,7 +58,7 @@ public class PacketPalette1202 : PacketTypePalette { 0x31, PacketTypesIn.OpenWindow }, // (Wiki name: Open Screen) { 0x32, PacketTypesIn.OpenSignEditor }, // { 0x33, PacketTypesIn.Ping }, // (Wiki name: Ping (play)) - { 0x34, PacketTypesIn.PingResponse }, // Added in 1.20.2 - TODO + { 0x34, PacketTypesIn.PingResponse }, // Added in 1.20.2 { 0x35, PacketTypesIn.CraftRecipeResponse }, // (Wiki name: Place Ghost Recipe) { 0x36, PacketTypesIn.PlayerAbilities }, // { 0x37, PacketTypesIn.ChatMessage }, // Changed in 1.19 (Completely changed) (Wiki name: Player Chat Message) @@ -73,7 +73,7 @@ public class PacketPalette1202 : PacketTypePalette { 0x40, PacketTypesIn.DestroyEntities }, // (Wiki name: Remove Entites) { 0x41, PacketTypesIn.RemoveEntityEffect }, // { 0x42, PacketTypesIn.ResourcePackSend }, // (Wiki name: Resource Pack) - { 0x43, PacketTypesIn.Respawn }, // Changed in 1.20.2 - TODO + { 0x43, PacketTypesIn.Respawn }, // Changed in 1.20.2 { 0x44, PacketTypesIn.EntityHeadLook }, // (Wiki name: Set Head Rotation) { 0x45, PacketTypesIn.MultiBlockChange }, // (Wiki name: Update Section Blocks) { 0x46, PacketTypesIn.SelectAdvancementTab }, // @@ -89,12 +89,12 @@ public class PacketPalette1202 : PacketTypePalette { 0x50, PacketTypesIn.UpdateViewPosition }, // (Wiki name: Set Center Chunk) { 0x51, PacketTypesIn.UpdateViewDistance }, // (Wiki name: Set Render Distance) { 0x52, PacketTypesIn.SpawnPosition }, // (Wiki name: Set Default Spawn Position) - { 0x53, PacketTypesIn.DisplayScoreboard }, // (Wiki name: Set Display Objective) - TODO + { 0x53, PacketTypesIn.DisplayScoreboard }, // (Wiki name: Set Display Objective) { 0x54, PacketTypesIn.EntityMetadata }, // (Wiki name: Set Entity Metadata) { 0x55, PacketTypesIn.AttachEntity }, // (Wiki name: Link Entities) { 0x56, PacketTypesIn.EntityVelocity }, // (Wiki name: Set Entity Velocity) { 0x57, PacketTypesIn.EntityEquipment }, // (Wiki name: Set Equipment) - { 0x58, PacketTypesIn.SetExperience }, // Changed in 1.20.2 - TODO + { 0x58, PacketTypesIn.SetExperience }, // Changed in 1.20.2 { 0x59, PacketTypesIn.UpdateHealth }, // (Wiki name: Set Health) { 0x5A, PacketTypesIn.ScoreboardObjective }, // (Wiki name: Update Objectives) { 0x5B, PacketTypesIn.SetPassengers }, // @@ -107,7 +107,7 @@ public class PacketPalette1202 : PacketTypePalette { 0x62, PacketTypesIn.SetTitleTime }, // (Wiki name: Set Title Animation Times) { 0x63, PacketTypesIn.EntitySoundEffect }, // (Wiki name: Sound Entity) { 0x64, PacketTypesIn.SoundEffect }, // Changed in 1.19 (Added "Seed" field) (Wiki name: Sound Effect) (No need to be implemented) - { 0x65, PacketTypesIn.StartConfiguration }, // Added in 1.20.2 - TODO + { 0x65, PacketTypesIn.StartConfiguration }, // Added in 1.20.2 { 0x66, PacketTypesIn.StopSound }, // { 0x67, PacketTypesIn.SystemChat }, // Added in 1.19 (Wiki name: System Chat Message) { 0x68, PacketTypesIn.PlayerListHeaderAndFooter }, // (Wiki name: Set Tab List Header And Footer) @@ -130,11 +130,11 @@ public class PacketPalette1202 : PacketTypePalette { 0x04, PacketTypesOut.ChatCommand }, // Added in 1.19 { 0x05, PacketTypesOut.ChatMessage }, // Changed in 1.19 (Completely changed) (Wiki name: Chat) { 0x06, PacketTypesOut.PlayerSession }, // Added in 1.19.3 - { 0x07, PacketTypesOut.ChunkBatchReceived }, // Added in 1.20.2 - TODO + { 0x07, PacketTypesOut.ChunkBatchReceived }, // Added in 1.20.2 { 0x08, PacketTypesOut.ClientStatus }, // (Wiki name: Client Command) { 0x09, PacketTypesOut.ClientSettings }, // (Wiki name: Client Information) { 0x0A, PacketTypesOut.TabComplete }, // (Wiki name: Command Suggestions Request) - { 0x0B, PacketTypesOut.AcknowledgeConfiguration }, // Added in 1.20.2 - TODO + { 0x0B, PacketTypesOut.AcknowledgeConfiguration }, // Added in 1.20.2 { 0x0C, PacketTypesOut.ClickWindowButton }, // (Wiki name: Click Container Button) { 0x0D, PacketTypesOut.ClickWindow }, // (Wiki name: Click Container) { 0x0E, PacketTypesOut.CloseWindow }, // (Wiki name: Close Container (serverbound)) @@ -152,7 +152,7 @@ public class PacketPalette1202 : PacketTypePalette { 0x1A, PacketTypesOut.VehicleMove }, // (Wiki name: Move Vehicle (serverbound)) { 0x1B, PacketTypesOut.SteerBoat }, // (Wiki name: Paddle Boat) { 0x1C, PacketTypesOut.PickItem }, // - { 0x1D, PacketTypesOut.PingRequest }, // Added in 1.20.2 - TODO + { 0x1D, PacketTypesOut.PingRequest }, // Added in 1.20.2 { 0x1E, PacketTypesOut.CraftRecipeRequest }, // (Wiki name: Place recipe) { 0x1F, PacketTypesOut.PlayerAbilities }, // { 0x20, PacketTypesOut.PlayerDigging }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Player Action) @@ -178,15 +178,33 @@ public class PacketPalette1202 : PacketTypePalette { 0x34, PacketTypesOut.PlayerBlockPlacement }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item On) { 0x35, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item) }; - - protected override Dictionary GetListIn() + + private readonly Dictionary configurationTypesIn = new() { - return typeIn; - } + { 0x00, ConfigurationPacketTypesIn.PluginMessage }, + { 0x01, ConfigurationPacketTypesIn.Disconnect }, + { 0x02, ConfigurationPacketTypesIn.FinishConfiguration }, + { 0x03, ConfigurationPacketTypesIn.KeepAlive }, + { 0x04, ConfigurationPacketTypesIn.Ping }, + { 0x05, ConfigurationPacketTypesIn.RegistryData }, + { 0x06, ConfigurationPacketTypesIn.ResourcePack }, + { 0x07, ConfigurationPacketTypesIn.FeatureFlags }, + { 0x08, ConfigurationPacketTypesIn.UpdateTags }, + }; - protected override Dictionary GetListOut() + private readonly Dictionary configurationTypesOut = new() { - return typeOut; - } + { 0x00, ConfigurationPacketTypesOut.ClientInformation }, + { 0x01, ConfigurationPacketTypesOut.PluginMessage }, + { 0x02, ConfigurationPacketTypesOut.FinishConfiguration }, + { 0x03, ConfigurationPacketTypesOut.KeepAlive }, + { 0x04, ConfigurationPacketTypesOut.Pong }, + { 0x05, ConfigurationPacketTypesOut.ResourcePackResponse } + }; + + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; + protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette17.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette17.cs index 5d7c8fdcf9..43a275d91e 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette17.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette17.cs @@ -112,14 +112,10 @@ public class PacketPalette17 : PacketTypePalette { 0x19, PacketTypesOut.ResourcePackStatus }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette18.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette18.cs index 424a74b904..11cefe6044 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette18.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette18.cs @@ -117,14 +117,9 @@ public class PacketPalette18 : PacketTypePalette { 0x20, PacketTypesOut.UseItem }, }; - protected override Dictionary GetListIn() - { - return typeIn; - } - - protected override Dictionary GetListOut() - { - return typeOut; - } + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => null!; + protected override Dictionary GetConfigurationListOut() => null!; } } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketTypePalette.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketTypePalette.cs index 968988f729..a3807275f4 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketTypePalette.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketTypePalette.cs @@ -29,33 +29,40 @@ public abstract class PacketTypePalette { protected abstract Dictionary GetListIn(); protected abstract Dictionary GetListOut(); + protected abstract Dictionary GetConfigurationListIn(); + protected abstract Dictionary GetConfigurationListOut(); private readonly Dictionary reverseMappingIn = new(); - private readonly Dictionary reverseMappingOut = new(); + private readonly Dictionary configurationReverseMappingIn = new(); + private readonly Dictionary configurationReverseMappingOut = new(); + private bool forgeEnabled = false; public PacketTypePalette() { foreach (var p in GetListIn()) - { reverseMappingIn.Add(p.Value, p.Key); - } + foreach (var p in GetListOut()) - { reverseMappingOut.Add(p.Value, p.Key); - } + + foreach (var p in GetConfigurationListIn()) + configurationReverseMappingIn.Add(p.Value, p.Key); + + foreach (var p in GetConfigurationListOut()) + configurationReverseMappingOut.Add(p.Value, p.Key); } /// - /// Get incomming packet type by packet ID + /// Get incoming packet type by packet ID /// /// packet ID /// Packet type - public PacketTypesIn GetIncommingTypeById(int packetId) + public PacketTypesIn GetIncomingTypeById(int packetId) { - if (GetListIn().TryGetValue(packetId, out PacketTypesIn p)) + if (GetListIn().TryGetValue(packetId, out var p)) { return p; } @@ -70,15 +77,42 @@ public PacketTypesIn GetIncommingTypeById(int packetId) } /// - /// Get incomming packet ID by packet type + /// Get incoming packet ID by packet type /// /// Packet type /// packet ID - public int GetIncommingIdByType(PacketTypesIn packetType) + public int GetIncomingIdByType(PacketTypesIn packetType) => reverseMappingIn[packetType]; + + /// + /// Get incoming configuration packet type by packet ID + /// + /// packet ID + /// Packet type + public ConfigurationPacketTypesIn GetIncomingConfigurationTypeById(int packetId) { - return reverseMappingIn[packetType]; + if (GetConfigurationListIn().TryGetValue(packetId, out var p)) + { + return p; + } + else if (forgeEnabled) + { + if (Settings.Config.Logging.DebugMessages) + ConsoleIO.WriteLogLine("Ignoring unknown packet ID of 0x" + packetId.ToString("X2")); + return ConfigurationPacketTypesIn.Unknown; + } + else + throw new KeyNotFoundException("Configuration Packet ID of 0x" + packetId.ToString("X2") + + " doesn't exist!"); } + /// + /// Get incoming packet ID by packet type for configuration packets + /// + /// Packet type + /// packet ID + public int GetIncomingIdByType(ConfigurationPacketTypesIn packetType) => + configurationReverseMappingIn[packetType]; + /// /// Get outgoing packet type by packet ID /// @@ -86,7 +120,7 @@ public int GetIncommingIdByType(PacketTypesIn packetType) /// Packet type public PacketTypesOut GetOutgoingTypeById(int packetId) { - if (GetListOut().TryGetValue(packetId, out PacketTypesOut p)) + if (GetListOut().TryGetValue(packetId, out var p)) { return p; } @@ -105,29 +139,61 @@ public PacketTypesOut GetOutgoingTypeById(int packetId) /// /// Packet type /// Packet ID - public int GetOutgoingIdByType(PacketTypesOut packetType) + public int GetOutgoingIdByType(PacketTypesOut packetType) => reverseMappingOut[packetType]; + + /// + /// Get outgoing configuration packet type by packet ID + /// + /// Packet ID + /// Packet type + public ConfigurationPacketTypesOut GetOutgoingConfigurationTypeById(int packetId) { - return reverseMappingOut[packetType]; + if (GetConfigurationListOut().TryGetValue(packetId, out var p)) + { + return p; + } + else if (forgeEnabled) + { + if (Settings.Config.Logging.DebugMessages) + ConsoleIO.WriteLogLine("Ignoring unknown packet ID of 0x" + packetId.ToString("X2")); + return ConfigurationPacketTypesOut.Unknown; + } + else + throw new KeyNotFoundException("Configuration Packet ID of 0x" + packetId.ToString("X2") + + " doesn't exist!"); } + /// + /// Get outgoing packet ID by packet type for configuration packets + /// + /// Packet type + /// Packet ID + public int GetOutgoingIdByTypeConfiguration(ConfigurationPacketTypesOut packetType) => + configurationReverseMappingOut[packetType]; /// /// Public method for getting the type mapping /// /// PacketTypesIn with packet ID as index - public Dictionary GetMappingIn() - { - return GetListIn(); - } + public Dictionary GetMappingIn() => GetListIn(); /// /// Public method for getting the type mapping /// /// PacketTypesOut with packet ID as index - public Dictionary GetMappingOut() - { - return GetListOut(); - } + public Dictionary GetMappingOut() => GetListOut(); + + /// + /// Public method for getting the type mapping for configuration packets + /// + /// PacketTypesIn with packet ID as index + public Dictionary GetMappingInConfiguration() => GetConfigurationListIn(); + + /// + /// Public method for getting the type mapping for configuration packets + /// + /// PacketTypesOut with packet ID as index + public Dictionary GetMappingOutConfiguration() => GetConfigurationListOut(); /// /// Enable forge or disable forge @@ -143,4 +209,4 @@ public void SetForgeEnabled(bool enabled) forgeEnabled = enabled; } } -} +} \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 076415678f..1c7e1e89c6 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -389,32 +389,27 @@ internal bool HandlePacket(int packetId, Queue packetData) // https://wiki.vg/Protocol#Configuration case CurrentState.Configuration: - switch (packetId) + switch (packetPalette.GetIncomingConfigurationTypeById(packetId)) { - // Disconnect - case 0x01: + case ConfigurationPacketTypesIn.Disconnect: handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick, ChatParser.ParseText(dataTypes.ReadNextString(packetData))); return false; - - // Finish Configuration - case 0x02: + + case ConfigurationPacketTypesIn.FinishConfiguration: currentState = CurrentState.Play; - SendPacket(0x02, new List()); + SendPacket(ConfigurationPacketTypesOut.FinishConfiguration, new List()); break; - - // Keep Alive - case 0x03: - SendPacket(0x03, packetData); + + case ConfigurationPacketTypesIn.KeepAlive: + SendPacket(ConfigurationPacketTypesOut.KeepAlive, packetData); break; - - // Ping - case 0x04: - SendPacket(0x04, packetData); + + case ConfigurationPacketTypesIn.Ping: + SendPacket(ConfigurationPacketTypesOut.Pong, packetData); break; - // Registry Codec - case 0x05: + case ConfigurationPacketTypesIn.RegistryData: var registryCodec = dataTypes.ReadNextNbt(packetData); ChatParser.ReadChatType(registryCodec); @@ -422,9 +417,8 @@ internal bool HandlePacket(int packetId, Queue packetData) World.StoreDimensionList(registryCodec); break; - - // Resource Pack - case 0x06: + + case ConfigurationPacketTypesIn.ResourcePack: var url = dataTypes.ReadNextString(packetData); var hash = dataTypes.ReadNextString(packetData); dataTypes.ReadNextBool(packetData); // Forced @@ -441,9 +435,9 @@ internal bool HandlePacket(int packetId, Queue packetData) //Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory var responseHeader = Array.Empty(); - SendPacket(0x05, + SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse, dataTypes.ConcatBytes(responseHeader, DataTypes.GetVarInt(3))); // Accepted pack - SendPacket(0x05, + SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse, dataTypes.ConcatBytes(responseHeader, DataTypes.GetVarInt(0))); // Successfully loaded break; @@ -471,7 +465,7 @@ internal bool HandlePacket(int packetId, Queue packetData) throw new System.IO.InvalidDataException( string.Format(Translations.exception_packet_process, - packetPalette.GetIncommingTypeById(packetId), + packetPalette.GetIncomingTypeById(packetId), packetId, protocolVersion, currentState == CurrentState.Login, @@ -484,7 +478,7 @@ internal bool HandlePacket(int packetId, Queue packetData) private bool HandlePlayPackets(int packetId, Queue packetData) { - switch (packetPalette.GetIncommingTypeById(packetId)) + switch (packetPalette.GetIncomingTypeById(packetId)) { case PacketTypesIn.KeepAlive: // Keep Alive (Play) SendPacket(PacketTypesOut.KeepAlive, packetData); @@ -2636,6 +2630,16 @@ private void SendPacket(PacketTypesOut packet, IEnumerable packetData) { SendPacket(packetPalette.GetOutgoingIdByType(packet), packetData); } + + /// + /// Send a configuration packet to the server. Packet ID, compression, and encryption will be handled automatically. + /// + /// packet type + /// packet Data + private void SendPacket(ConfigurationPacketTypesOut packet, IEnumerable packetData) + { + SendPacket(packetPalette.GetOutgoingIdByTypeConfiguration(packet), packetData); + } /// /// Send a packet to the server. Compression and encryption will be handled automatically. diff --git a/MinecraftClient/Protocol/ReplayHandler.cs b/MinecraftClient/Protocol/ReplayHandler.cs index 1c88eb6a77..75184e26d1 100644 --- a/MinecraftClient/Protocol/ReplayHandler.cs +++ b/MinecraftClient/Protocol/ReplayHandler.cs @@ -294,7 +294,7 @@ private bool PacketShouldSave(int packetID, bool isLogin, bool isInbound) private void HandleInBoundPacket(int packetID, IEnumerable packetData, bool isLogin) { Queue p = new(packetData); - PacketTypesIn pType = packetType.GetIncommingTypeById(packetID); + PacketTypesIn pType = packetType.GetIncomingTypeById(packetID); // Login success. Get player UUID if (isLogin && packetID == 0x02) {