diff --git a/MinecraftClient/ChatBots/AntiAFK.cs b/MinecraftClient/ChatBots/AntiAFK.cs index 23b2bad6..4291e8dd 100644 --- a/MinecraftClient/ChatBots/AntiAFK.cs +++ b/MinecraftClient/ChatBots/AntiAFK.cs @@ -127,7 +127,7 @@ namespace MinecraftClient.ChatBots private void DoAntiAfkStuff() { var isMovementLocked = BotMovementLock.Instance; - if (Config.Use_Terrain_Handling && GetTerrainEnabled() && isMovementLocked is {IsLocked: false}) + if (Config.Use_Terrain_Handling && GetTerrainEnabled() && isMovementLocked is { IsLocked: false }) { var currentLocation = GetCurrentLocation(); diff --git a/MinecraftClient/ChatBots/AutoAttack.cs b/MinecraftClient/ChatBots/AutoAttack.cs index 8395eed8..f851ca0a 100644 --- a/MinecraftClient/ChatBots/AutoAttack.cs +++ b/MinecraftClient/ChatBots/AutoAttack.cs @@ -28,7 +28,7 @@ namespace MinecraftClient.ChatBots public PriorityType Priority = PriorityType.distance; [TomlInlineComment("$ChatBot.AutoAttack.Cooldown_Time$")] - public CooldownConfig Cooldown_Time = new(false, 1.0); + public CooldownConfig Cooldown_Time = new(); [TomlInlineComment("$ChatBot.AutoAttack.Interaction$")] public InteractType Interaction = InteractType.Attack; @@ -50,10 +50,19 @@ namespace MinecraftClient.ChatBots public void OnSettingUpdate() { - if (Cooldown_Time.Custom && Cooldown_Time.value <= 0) + if (Cooldown_Time.Custom) { - LogToConsole(BotName, Translations.bot_autoAttack_invalidcooldown); - Cooldown_Time.value = 1.0; + if (Cooldown_Time.Min <= 0) + Cooldown_Time.Min = 0.1; + if (Cooldown_Time.Max <= 0) + Cooldown_Time.Max = 0.1; + + if (Cooldown_Time.Min > Cooldown_Time.Max) + { + double temp = Cooldown_Time.Min; + Cooldown_Time.Min = Cooldown_Time.Max; + Cooldown_Time.Max = temp; + } } if (Attack_Range < 1.0) @@ -72,24 +81,16 @@ namespace MinecraftClient.ChatBots public struct CooldownConfig { public bool Custom; - public double value; + public bool RandomMode = false; + public double Min = 1.5; + public double Max = 2.5; public CooldownConfig() { Custom = false; - value = 0; - } - - public CooldownConfig(double value) - { - Custom = true; - this.value = value; - } - - public CooldownConfig(bool Override, double value) - { - this.Custom = Override; - this.value = value; + RandomMode = false; + Min = 1.5; + Max = 2.5; } } } @@ -105,13 +106,14 @@ namespace MinecraftClient.ChatBots private float health = 100; private readonly bool attackHostile = true; private readonly bool attackPassive = false; + private readonly Random _random = new(); public AutoAttack() { overrideAttackSpeed = Config.Cooldown_Time.Custom; if (Config.Cooldown_Time.Custom) { - attackCooldownSeconds = Config.Cooldown_Time.value; + attackCooldownSeconds = Config.Cooldown_Time.Min; attackCooldown = SecondsToAttackCooldownTicks(attackCooldownSeconds); } @@ -137,6 +139,12 @@ namespace MinecraftClient.ChatBots if (attackCooldownCounter == 0) { + if (Config.Cooldown_Time.Custom && Config.Cooldown_Time.RandomMode) + { + double randomSeconds = _random.NextDouble() * (Config.Cooldown_Time.Max - Config.Cooldown_Time.Min) + Config.Cooldown_Time.Min; + attackCooldown = SecondsToAttackCooldownTicks(randomSeconds); + } + attackCooldownCounter = attackCooldown; if (entitiesToAttack.Count > 0) { @@ -177,6 +185,8 @@ namespace MinecraftClient.ChatBots InteractEntity(priorityEntity, Config.Interaction); // hit the entity! SendAnimation(Inventory.Hand.MainHand); // Arm animation } + + } } else @@ -188,6 +198,7 @@ namespace MinecraftClient.ChatBots { InteractEntity(entity.Key, Config.Interaction); // hit the entity! } + } SendAnimation(Inventory.Hand.MainHand); // Arm animation } diff --git a/MinecraftClient/ChatBots/Script.cs b/MinecraftClient/ChatBots/Script.cs index b4da57b4..bbfe729f 100644 --- a/MinecraftClient/ChatBots/Script.cs +++ b/MinecraftClient/ChatBots/Script.cs @@ -86,7 +86,7 @@ namespace MinecraftClient.ChatBots public static bool LookForScript(ref string filename) { //Automatically look in subfolders and try to add ".txt" file extension - char dir_slash = Path.DirectorySeparatorChar; + char dir_slash = Path.DirectorySeparatorChar; string[] files = new string[] { filename, @@ -213,7 +213,7 @@ namespace MinecraftClient.ChatBots .ToLower(); processedLine = string.Join("", processedLine.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries)); var parts = processedLine.Contains("to") ? processedLine.Split("to") : processedLine.Split("-"); - + if (parts.Length == 2) { var min = Convert.ToInt32(parts[0]); @@ -224,10 +224,12 @@ namespace MinecraftClient.ChatBots (min, max) = (max, min); LogToConsole(Translations.cmd_wait_random_min_bigger); } - + ticks = new Random().Next(min, max); - } else ticks = Convert.ToInt32(instruction_line[5..]); - } else ticks = Convert.ToInt32(instruction_line[5..]); + } + else ticks = Convert.ToInt32(instruction_line[5..]); + } + else ticks = Convert.ToInt32(instruction_line[5..]); } catch { } sleepticks = ticks; diff --git a/MinecraftClient/ChatBots/TelegramBridge.cs b/MinecraftClient/ChatBots/TelegramBridge.cs index 70536cb9..6b645507 100644 --- a/MinecraftClient/ChatBots/TelegramBridge.cs +++ b/MinecraftClient/ChatBots/TelegramBridge.cs @@ -352,7 +352,7 @@ namespace MinecraftClient.ChatBots replyParameters: message.MessageId, cancellationToken: _cancellationToken, parseMode: ParseMode.Markdown); - return;; + return; ; } CmdResult result = new(); diff --git a/MinecraftClient/Commands/Entitycmd.cs b/MinecraftClient/Commands/Entitycmd.cs index c48398bf..b0ed8a1b 100644 --- a/MinecraftClient/Commands/Entitycmd.cs +++ b/MinecraftClient/Commands/Entitycmd.cs @@ -317,7 +317,7 @@ namespace MinecraftClient.Commands bool shouldInteractAt = entity.Type == EntityType.ArmorStand || entity.Type == EntityType.ChestMinecart || entity.Type == EntityType.ChestBoat; - + handler.InteractEntity(entity.ID, shouldInteractAt ? InteractType.InteractAt : InteractType.Interact); return Translations.cmd_entityCmd_used; case ActionType.List: diff --git a/MinecraftClient/Inventory/Item.cs b/MinecraftClient/Inventory/Item.cs index 69d175fb..95f95b37 100644 --- a/MinecraftClient/Inventory/Item.cs +++ b/MinecraftClient/Inventory/Item.cs @@ -51,7 +51,7 @@ namespace MinecraftClient.Inventory Count = count; NBT = nbt; } - + public Item(ItemType itemType, int count, int data, Dictionary? nbt) : this(itemType, count, nbt) { Data = data; @@ -134,8 +134,8 @@ namespace MinecraftClient.Inventory { object[] displayName = (object[])displayProperties["Lore"]; lores.AddRange(from string st in displayName - let str = ChatParser.ParseText(st.ToString()) - select str); + let str = ChatParser.ParseText(st.ToString()) + select str); return lores.ToArray(); } } diff --git a/MinecraftClient/Inventory/ItemPalettes/ItemPalette.cs b/MinecraftClient/Inventory/ItemPalettes/ItemPalette.cs index d6770fcd..c8cbe316 100644 --- a/MinecraftClient/Inventory/ItemPalettes/ItemPalette.cs +++ b/MinecraftClient/Inventory/ItemPalettes/ItemPalette.cs @@ -14,7 +14,7 @@ namespace MinecraftClient.Inventory.ItemPalettes { if (DictReverse.ContainsKey(entry.Value)) continue; - + DictReverse.Add(entry.Value, entry.Key); } diff --git a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1122.cs b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1122.cs index 1bb24765..1f9e08cf 100644 --- a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1122.cs +++ b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1122.cs @@ -22,7 +22,7 @@ public class EntityMetadataPalette1122 : EntityMetadataPalette { 12, EntityMetaDataType.OptionalBlockId }, { 13, EntityMetaDataType.Nbt }, }; - + public override Dictionary GetEntityMetadataMappingsList() { return entityMetadataMappings; diff --git a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1191.cs b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1191.cs index bea16c9a..ef7f4117 100644 --- a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1191.cs +++ b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1191.cs @@ -33,7 +33,7 @@ public class EntityMetadataPalette1191 : EntityMetadataPalette { 21, EntityMetaDataType.OptionalGlobalPosition }, { 22, EntityMetaDataType.PaintingVariant } }; - + public override Dictionary GetEntityMetadataMappingsList() { return entityMetadataMappings; diff --git a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1193.cs b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1193.cs index b6dffe4c..664b2cfa 100644 --- a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1193.cs +++ b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1193.cs @@ -34,7 +34,7 @@ public class EntityMetadataPalette1193 : EntityMetadataPalette { 22, EntityMetaDataType.OptionalGlobalPosition }, { 23, EntityMetaDataType.PaintingVariant } }; - + public override Dictionary GetEntityMetadataMappingsList() { return entityMetadataMappings; diff --git a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1194.cs b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1194.cs index 2ac0e467..2b180afc 100644 --- a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1194.cs +++ b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette1194.cs @@ -38,7 +38,7 @@ public class EntityMetadataPalette1194 : EntityMetadataPalette { 26, EntityMetaDataType.Vector3 }, { 27, EntityMetaDataType.Quaternion }, }; - + public override Dictionary GetEntityMetadataMappingsList() { return entityMetadataMappings; diff --git a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette18.cs b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette18.cs index c862092c..41da3b2f 100644 --- a/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette18.cs +++ b/MinecraftClient/Mapping/EntityMetadataPalettes/EntityMetadataPalette18.cs @@ -16,7 +16,7 @@ public class EntityMetadataPalette18 : EntityMetadataPalette { 6, EntityMetaDataType.Vector3Int }, { 7, EntityMetaDataType.Rotation } }; - + public override Dictionary GetEntityMetadataMappingsList() { return entityMetadataMappings; diff --git a/MinecraftClient/Mapping/EntityTypeExtensions.cs b/MinecraftClient/Mapping/EntityTypeExtensions.cs index 8609a2c2..0e7a85fb 100644 --- a/MinecraftClient/Mapping/EntityTypeExtensions.cs +++ b/MinecraftClient/Mapping/EntityTypeExtensions.cs @@ -117,7 +117,8 @@ namespace MinecraftClient.Mapping return true; default: return false; - }; + } + ; } } } diff --git a/MinecraftClient/Mapping/World.cs b/MinecraftClient/Mapping/World.cs index aacfe1ec..69983e0e 100644 --- a/MinecraftClient/Mapping/World.cs +++ b/MinecraftClient/Mapping/World.cs @@ -19,7 +19,7 @@ namespace MinecraftClient.Mapping /// /// The dimension info of the world /// - private static Dimension curDimension= new(); + private static Dimension curDimension = new(); private static readonly Dictionary dimensionList = new(); @@ -82,7 +82,7 @@ namespace MinecraftClient.Mapping public static void LoadDefaultDimensions1206Plus() { // TODO: Move this to a JSON file. - + var defaultRegistryCodec = new Dictionary { { "minecraft:dimension_type", new Dictionary @@ -314,29 +314,29 @@ namespace MinecraftClient.Mapping /// /// The name of the dimension type /// The dimension type (NBT Tag Compound) - public static void SetDimension(string name) - { - // Try to get the dimension using the name as is - if (dimensionList.TryGetValue(name, out Dimension? dimension)) - { - curDimension = dimension; - return; // Dimension found - } + public static void SetDimension(string name) + { + // Try to get the dimension using the name as is + if (dimensionList.TryGetValue(name, out Dimension? dimension)) + { + curDimension = dimension; + return; // Dimension found + } - // If not found, check if name lacks 'minecraft:' prefix and try again - if (!name.StartsWith("minecraft:")) - { - string prefixedName = "minecraft:" + name; - if (dimensionList.TryGetValue(prefixedName, out dimension)) - { - curDimension = dimension; - return; // Dimension found with prefixed name - } - } + // If not found, check if name lacks 'minecraft:' prefix and try again + if (!name.StartsWith("minecraft:")) + { + string prefixedName = "minecraft:" + name; + if (dimensionList.TryGetValue(prefixedName, out dimension)) + { + curDimension = dimension; + return; // Dimension found with prefixed name + } + } - // If still not found, dimension does not exist - throw new KeyNotFoundException($"Dimension '{name}' not found in dimensions dictionary."); - } + // If still not found, dimension does not exist + throw new KeyNotFoundException($"Dimension '{name}' not found in dimensions dictionary."); + } diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index cde3ad55..6e65c5eb 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -120,7 +120,7 @@ namespace MinecraftClient // scoreboard teams (key = team name) private readonly Dictionary teams = new(StringComparer.Ordinal); - + // Sneaking public bool IsSneaking { get; set; } = false; private bool isUnderSlab = false; @@ -142,7 +142,7 @@ namespace MinecraftClient // ChatBot OnNetworkPacket event private bool networkPacketCaptureEnabled = false; - + // Cookies private Dictionary Cookies { get; set; } = new(); @@ -233,7 +233,7 @@ namespace MinecraftClient private bool consoleHandlersAttached = false; public ILogger Log; - + private static IMinecraftComHandler? instance; public static IMinecraftComHandler? Instance => instance; @@ -250,7 +250,7 @@ namespace MinecraftClient { CmdResult.currentHandler = this; instance = this; - + terrainAndMovementsEnabled = Config.Main.Advanced.TerrainAndMovements; inventoryHandlingEnabled = Config.Main.Advanced.InventoryHandling; entityHandlingEnabled = Config.Main.Advanced.EntityHandling; @@ -281,7 +281,7 @@ namespace MinecraftClient scope.SetTag("Protocol Version", protocolversion.ToString()); scope.SetTag("Minecraft Version", ProtocolHandler.ProtocolVersion2MCVer(protocolversion)); scope.SetTag("MCC Build", Program.BuildInfo is null ? "Debug" : Program.BuildInfo); - + if (forgeInfo is not null) scope.SetTag("Forge Version", forgeInfo.Version.ToString()); @@ -291,17 +291,17 @@ namespace MinecraftClient MinecraftVersion = ProtocolHandler.ProtocolVersion2MCVer(protocolversion), ForgeInfo = forgeInfo?.Version }; - - scope.Contexts["Client Configuration"] = new + + scope.Contexts["Client Configuration"] = new { TerrainAndMovementsEnabled = terrainAndMovementsEnabled, InventoryHandlingEnabled = inventoryHandlingEnabled, EntityHandlingEnabled = entityHandlingEnabled }; }); - + SentrySdk.StartSession(); - + /* Load commands from Commands namespace */ LoadCommands(); @@ -356,7 +356,7 @@ namespace MinecraftClient return; - Retry: + Retry: if (timeoutdetector is not null) { timeoutdetector.Item2.Cancel(); @@ -379,7 +379,7 @@ namespace MinecraftClient } throw new Exception("Initialization failed."); - } + } else { // AutoRelog is enabled - invoke its static handler to trigger reconnection. @@ -399,7 +399,7 @@ namespace MinecraftClient throw new Exception("Initialization failed."); } } - + public void Transfer(string newHost, int newPort) { // Do not block here: a new handler can start processing packets before the @@ -419,13 +419,13 @@ namespace MinecraftClient { ResolveTransferAddress(ref resolvedHost, ref resolvedPort); Log.Info($"Initiating a transfer to: {resolvedHost}:{resolvedPort}"); - + // Unload bots UnloadAllBots(); bots.Clear(); ResetStateForTransfer(); - + // Retire the old handler so its updater exits without reporting a stale disconnect. oldHandler.Dispose(); oldClient.Close(); @@ -916,7 +916,7 @@ namespace MinecraftClient } SentrySdk.EndSession(); - + if (!will_restart) { StopConsoleSession(); @@ -2844,7 +2844,7 @@ namespace MinecraftClient _ => handler.SendInteractEntity(entityID, (int)type), }; } - + return false; } @@ -3128,7 +3128,7 @@ namespace MinecraftClient return false; } } - + /// /// Send the server a command to type in the item name in the Anvil inventory when it's open. /// @@ -3140,7 +3140,7 @@ namespace MinecraftClient if (inventories.Values.ToList().Last().Type != ContainerType.Anvil) return false; - + return handler.SendRenameItem(itemName); } @@ -3563,7 +3563,7 @@ namespace MinecraftClient if (!Config.Signature.ShowIllegalSignedChat && !message.isSystemChat && !(bool)message.isSignatureLegal!) return; messageText = ChatParser.ParseSignedChat(message, links); - + if (message.isSystemChat) { if (Config.Signature.MarkSystemMessage) @@ -4555,7 +4555,7 @@ namespace MinecraftClient Entity entity = entities[entityID]; entity.Metadata = metadata; int itemEntityMetadataFieldIndex = protocolversion < Protocol18Handler.MC_1_17_Version ? 7 : 8; - + if (entity.Type.ContainsItem() && metadata.TryGetValue(itemEntityMetadataFieldIndex, out object? itemObj) && itemObj is not null && itemObj.GetType() == typeof(Item)) { Item item = (Item)itemObj; diff --git a/MinecraftClient/Mcp/MccMcpCapabilities.cs b/MinecraftClient/Mcp/MccMcpCapabilities.cs index 60a03f76..43b6a837 100644 --- a/MinecraftClient/Mcp/MccMcpCapabilities.cs +++ b/MinecraftClient/Mcp/MccMcpCapabilities.cs @@ -1392,18 +1392,18 @@ public sealed class MccMcpCapabilities : IMccMcpCapabilities bool success = client.SendLocationUpdate(); return success ? MccMcpResult.Ok(new - { - success, - direction = parsedDirection.ToString(), - yaw = client.GetYaw(), - pitch = client.GetPitch(), - location = ToCoordinate(current) - }) + { + success, + direction = parsedDirection.ToString(), + yaw = client.GetYaw(), + pitch = client.GetPitch(), + location = ToCoordinate(current) + }) : MccMcpResult.Fail("action_failed", data: new - { - success, - direction = parsedDirection.ToString() - }); + { + success, + direction = parsedDirection.ToString() + }); }); } @@ -1426,19 +1426,19 @@ public sealed class MccMcpCapabilities : IMccMcpCapabilities bool success = client.SendLocationUpdate(); return success ? MccMcpResult.Ok(new - { - success, - yaw = client.GetYaw(), - pitch = client.GetPitch(), - location = ToCoordinate(current) - }) + { + success, + yaw = client.GetYaw(), + pitch = client.GetPitch(), + location = ToCoordinate(current) + }) : MccMcpResult.Fail("action_failed", data: new - { - success, - yaw, - pitch, - location = ToCoordinate(current) - }); + { + success, + yaw, + pitch, + location = ToCoordinate(current) + }); }); } diff --git a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs index f3b4be23..d140bbcc 100644 --- a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs +++ b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesIn.cs @@ -22,6 +22,6 @@ public enum ConfigurationPacketTypesIn ClearDialog, // Added in 1.21.6 ShowDialog, // Added in 1.21.6 CodeOfConduct, // Added in 1.21.9 - + Unknown } diff --git a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs index 30b7c909..1bb492d2 100644 --- a/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs +++ b/MinecraftClient/Protocol/Handlers/ConfigurationPacketTypesOut.cs @@ -12,6 +12,6 @@ public enum ConfigurationPacketTypesOut KnownDataPacks, CustomClickAction, // Added in 1.21.6 AcceptCodeOfConduct, // Added in 1.21.9 - + Unknown } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/DataTypes.cs b/MinecraftClient/Protocol/Handlers/DataTypes.cs index 3578fdf5..182944a6 100644 --- a/MinecraftClient/Protocol/Handlers/DataTypes.cs +++ b/MinecraftClient/Protocol/Handlers/DataTypes.cs @@ -459,7 +459,7 @@ namespace MinecraftClient.Protocol.Handlers var nbt = null as Dictionary; var item = null as Item; var strcturedComponentsToAdd = new List(); - + switch (protocolversion) { // MC 1.13.2 and greater @@ -467,10 +467,10 @@ namespace MinecraftClient.Protocol.Handlers itemCount = ReadNextVarInt(cache); if (itemCount <= 0) return null; - + itemId = ReadNextVarInt(cache); item = new Item(itemPalette.FromId(itemId), itemCount, null); - + var numberOfComponentsToAdd = ReadNextVarInt(cache); var numberofComponentsToRemove = ReadNextVarInt(cache); var structuredComponentHandler = new StructuredComponentsHandler(protocolversion, this, itemPalette); @@ -506,55 +506,55 @@ namespace MinecraftClient.Protocol.Handlers return item; case >= Protocol18Handler.MC_1_13_2_Version: - { - var itemPresent = ReadNextBool(cache); + { + var itemPresent = ReadNextBool(cache); - if (!itemPresent) - return null; + if (!itemPresent) + return null; - itemId = ReadNextVarInt(cache); + itemId = ReadNextVarInt(cache); - if (itemId == -1) - return null; + if (itemId == -1) + return null; - var type = itemPalette.FromId(itemId); - itemCount = ReadNextByte(cache); - nbt = ReadNextNbt(cache); - return new Item(type, itemCount, itemId, nbt); - } + var type = itemPalette.FromId(itemId); + itemCount = ReadNextByte(cache); + nbt = ReadNextNbt(cache); + return new Item(type, itemCount, itemId, nbt); + } case >= Protocol18Handler.MC_1_13_Version: - { - itemId = ReadNextShort(cache); + { + itemId = ReadNextShort(cache); - if (itemId == -1) - return null; + if (itemId == -1) + return null; - var type = itemPalette.FromId(itemId); - itemCount = ReadNextByte(cache); - nbt = ReadNextNbt(cache); - return new Item(type, itemCount, itemId, nbt); - } + var type = itemPalette.FromId(itemId); + itemCount = ReadNextByte(cache); + nbt = ReadNextNbt(cache); + return new Item(type, itemCount, itemId, nbt); + } default: - { - itemId = ReadNextShort(cache); + { + itemId = ReadNextShort(cache); - if (itemId == -1) - return null; + if (itemId == -1) + return null; - itemCount = ReadNextByte(cache); - var data = ReadNextShort(cache); - nbt = ReadNextNbt(cache); + itemCount = ReadNextByte(cache); + var data = ReadNextShort(cache); + nbt = ReadNextNbt(cache); - // For 1.8 - 1.12.2 we combine Item Id and Item Data/Damage to a single value using: (id << 16) | data - return new Item(itemPalette.FromId((itemId << 16) | (ushort)data), itemCount, data, nbt); - } + // For 1.8 - 1.12.2 we combine Item Id and Item Data/Damage to a single value using: (id << 16) | data + return new Item(itemPalette.FromId((itemId << 16) | (ushort)data), itemCount, data, nbt); + } } } private void ReadNextDetail(Queue cache) { var potionEffectId = ReadNextVarInt(cache); - + // Details var potionEffectAmplifier = ReadNextVarInt(cache); var duration = ReadNextVarInt(cache); // -1 for infinite @@ -1179,14 +1179,14 @@ namespace MinecraftClient.Protocol.Handlers if (protocolversion >= Protocol18Handler.MC_1_20_6_Version) ReadNextVarInt(cache); // BlockState (minecraft:block) break; - + case 2: // 1.18 if (protocolversion > Protocol18Handler.MC_1_17_1_Version) ReadNextVarInt(cache); // Block state (minecraft:block before 1.20.6, minecraft:block_marker in 1.20.6+) break; case 3: - if (protocolversion is (< Protocol18Handler.MC_1_17_Version or > Protocol18Handler.MC_1_17_1_Version) + if (protocolversion is (< Protocol18Handler.MC_1_17_Version or > Protocol18Handler.MC_1_17_1_Version) and < Protocol18Handler.MC_1_20_6_Version) ReadNextVarInt( cache); // Block State (minecraft:block before 1.18, minecraft:block_marker after 1.18 up to 1.20.6) @@ -1346,7 +1346,7 @@ namespace MinecraftClient.Protocol.Handlers break; case 45: // 1.21+ - if(protocolversion >= Protocol18Handler.MC_1_21_Version) + if (protocolversion >= Protocol18Handler.MC_1_21_Version) ReadVibration(cache); break; case 99: @@ -1389,7 +1389,7 @@ namespace MinecraftClient.Protocol.Handlers ReadNextFloat(cache); // Entity eye height ReadNextVarInt(cache); // Ticks } - + /// /// Read a single villager trade from a cache of bytes and remove it from the cache /// diff --git a/MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs b/MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs index 7baca1ba..644be909 100755 --- a/MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs +++ b/MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs @@ -133,7 +133,7 @@ namespace MinecraftClient.Protocol.Handlers.Forge break; case FMLVersion.FML3: // Example ModInfo for Minecraft 1.18 and greater (FML3) - + // "forgeData": { // "channels": [], // "mods": [], @@ -169,24 +169,26 @@ namespace MinecraftClient.Protocol.Handlers.Forge // [ Channel Version ][ String ] // [ Required On Client ][ Bool ] - for (var i = 0; i < modsSize; i++) { + for (var i = 0; i < modsSize; i++) + { var channelSizeAndVersionFlag = dataTypes.ReadNextVarInt(dataPackage); var channelSize = channelSizeAndVersionFlag >> 1; int VERSION_FLAG_IGNORESERVERONLY = 0b1; var isIgnoreServerOnly = (channelSizeAndVersionFlag & VERSION_FLAG_IGNORESERVERONLY) != 0; - + var modId = dataTypes.ReadNextString(dataPackage); - + string IGNORESERVERONLY = "IGNORED"; var modVersion = isIgnoreServerOnly ? IGNORESERVERONLY : dataTypes.ReadNextString(dataPackage); - - for (var i1 = 0; i1 < channelSize; i1++) { + + for (var i1 = 0; i1 < channelSize; i1++) + { dataTypes.ReadNextString(dataPackage); // channelName dataTypes.ReadNextString(dataPackage); // channelVersion dataTypes.ReadNextBool(dataPackage); // requiredOnClient } - + mods.Add(modId, modVersion); Mods.Add(new ForgeMod(modId, modVersion)); } @@ -213,7 +215,8 @@ namespace MinecraftClient.Protocol.Handlers.Forge /// The code below is converted from forge source code, see: /// https://github.com/MinecraftForge/MinecraftForge/blob/cb12df41e13da576b781be695f80728b9594c25f/src/main/java/net/minecraftforge/network/ServerStatusPing.java#L361 /// - private static Queue decodeOptimized(string encodedData) { + private static Queue decodeOptimized(string encodedData) + { int size0 = encodedData[0]; int size1 = encodedData[1]; int size = size0 | (size1 << 15); diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1202.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1202.cs index 1e771589..7781a9c9 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1202.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1202.cs @@ -178,7 +178,7 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes { 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) }; - + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.PluginMessage }, @@ -201,7 +201,7 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes { 0x04, ConfigurationPacketTypesOut.Pong }, { 0x05, ConfigurationPacketTypesOut.ResourcePackResponse } }; - + protected override Dictionary GetListIn() => typeIn; protected override Dictionary GetListOut() => typeOut; protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1204.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1204.cs index 0f7bcd04..46721231 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1204.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1204.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette1204 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Added in 1.19.4 { 0x01, PacketTypesIn.SpawnEntity }, // Changed in 1.19 (Wiki name: Spawn Entity) @@ -125,7 +125,7 @@ public class PacketPalette1204 : PacketTypePalette { 0x74, PacketTypesIn.Tags }, // (Wiki name: Update Tags) }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // (Wiki name: Confirm Teleportation) { 0x01, PacketTypesOut.QueryBlockNBT }, // (Wiki name: Query Block Entity Tag) @@ -184,7 +184,7 @@ public class PacketPalette1204 : PacketTypePalette { 0x36, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item) }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.PluginMessage }, { 0x01, ConfigurationPacketTypesIn.Disconnect }, @@ -198,7 +198,7 @@ public class PacketPalette1204 : PacketTypePalette { 0x09, ConfigurationPacketTypesIn.UpdateTags }, }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.PluginMessage }, @@ -207,9 +207,9 @@ public class PacketPalette1204 : PacketTypePalette { 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 + + 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/PacketPalette1206.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1206.cs index 2a5abce5..f053d41e 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1206.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1206.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette1206 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Added in 1.19.4 { 0x01, PacketTypesIn.SpawnEntity }, // Changed in 1.19 (Wiki name: Spawn Entity) @@ -130,7 +130,7 @@ public class PacketPalette1206 : PacketTypePalette { 0x79, PacketTypesIn.ProjectilePower }, // Added in 1.20.6 }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // (Wiki name: Confirm Teleportation) { 0x01, PacketTypesOut.QueryBlockNBT }, // (Wiki name: Query Block Entity Tag) @@ -192,7 +192,7 @@ public class PacketPalette1206 : PacketTypePalette { 0x39, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item) }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.CookieRequest }, { 0x01, ConfigurationPacketTypesIn.PluginMessage }, @@ -211,7 +211,7 @@ public class PacketPalette1206 : PacketTypePalette { 0x0E, ConfigurationPacketTypesIn.KnownDataPacks } }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.CookieResponse }, @@ -222,9 +222,9 @@ public class PacketPalette1206 : PacketTypePalette { 0x06, ConfigurationPacketTypesOut.ResourcePackResponse }, { 0x07, ConfigurationPacketTypesOut.KnownDataPacks } }; - - 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 + + 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/PacketPalette121.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette121.cs index fc8b64bb..8c35b2c8 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette121.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette121.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette121 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Added in 1.19.4 { 0x01, PacketTypesIn.SpawnEntity }, // Changed in 1.19 (Wiki name: Spawn Entity) @@ -132,7 +132,7 @@ public class PacketPalette121 : PacketTypePalette { 0x7B, PacketTypesIn.ServerLinks } // Added in 1.21 }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // (Wiki name: Confirm Teleportation) { 0x01, PacketTypesOut.QueryBlockNBT }, // (Wiki name: Query Block Entity Tag) @@ -194,7 +194,7 @@ public class PacketPalette121 : PacketTypePalette { 0x39, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item) }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.CookieRequest }, { 0x01, ConfigurationPacketTypesIn.PluginMessage }, @@ -215,7 +215,7 @@ public class PacketPalette121 : PacketTypePalette { 0x10, ConfigurationPacketTypesIn.ServerLinks } // Added in 1.21 (Not used) }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.CookieResponse }, @@ -226,9 +226,9 @@ public class PacketPalette121 : PacketTypePalette { 0x06, ConfigurationPacketTypesOut.ResourcePackResponse }, { 0x07, ConfigurationPacketTypesOut.KnownDataPacks } }; - - 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 + + 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/PacketPalette1212.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1212.cs index 76deae7e..e5aa2e63 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1212.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1212.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette1212 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Bundle delimiter { 0x01, PacketTypesIn.SpawnEntity }, // Add Entity @@ -139,7 +139,7 @@ public class PacketPalette1212 : PacketTypePalette { 0x82, PacketTypesIn.ServerLinks } // Server Links }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation { 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query @@ -203,7 +203,7 @@ public class PacketPalette1212 : PacketTypePalette { 0x3B, PacketTypesOut.UseItem }, // Use Item }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.CookieRequest }, { 0x01, ConfigurationPacketTypesIn.PluginMessage }, @@ -224,7 +224,7 @@ public class PacketPalette1212 : PacketTypePalette { 0x10, ConfigurationPacketTypesIn.ServerLinks } }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.CookieResponse }, @@ -235,9 +235,9 @@ public class PacketPalette1212 : PacketTypePalette { 0x06, ConfigurationPacketTypesOut.ResourcePackResponse }, { 0x07, ConfigurationPacketTypesOut.KnownDataPacks } }; - - protected override Dictionary GetListIn() => typeIn; - protected override Dictionary GetListOut() => typeOut; - protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; - protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; - } + + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; + protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; +} diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1214.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1214.cs index 8ab00e22..a7b90eca 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1214.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1214.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette1214 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Bundle delimiter { 0x01, PacketTypesIn.SpawnEntity }, // Add Entity @@ -139,7 +139,7 @@ public class PacketPalette1214 : PacketTypePalette { 0x82, PacketTypesIn.ServerLinks } // Server Links }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation { 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query @@ -205,7 +205,7 @@ public class PacketPalette1214 : PacketTypePalette { 0x3D, PacketTypesOut.UseItem }, // Use Item }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.CookieRequest }, { 0x01, ConfigurationPacketTypesIn.PluginMessage }, @@ -226,7 +226,7 @@ public class PacketPalette1214 : PacketTypePalette { 0x10, ConfigurationPacketTypesIn.ServerLinks } }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.CookieResponse }, @@ -237,9 +237,9 @@ public class PacketPalette1214 : PacketTypePalette { 0x06, ConfigurationPacketTypesOut.ResourcePackResponse }, { 0x07, ConfigurationPacketTypesOut.KnownDataPacks } }; - - protected override Dictionary GetListIn() => typeIn; - protected override Dictionary GetListOut() => typeOut; - protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; - protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; - } + + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; + protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; +} diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1215.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1215.cs index 4ecc5079..0e8f7a93 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1215.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1215.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette1215 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Bundle delimiter { 0x01, PacketTypesIn.SpawnEntity }, // Add Entity @@ -139,7 +139,7 @@ public class PacketPalette1215 : PacketTypePalette { 0x82, PacketTypesIn.ServerLinks } // Server Links }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation { 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query @@ -207,7 +207,7 @@ public class PacketPalette1215 : PacketTypePalette { 0x3F, PacketTypesOut.UseItem }, // Use Item }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.CookieRequest }, { 0x01, ConfigurationPacketTypesIn.PluginMessage }, @@ -228,7 +228,7 @@ public class PacketPalette1215 : PacketTypePalette { 0x10, ConfigurationPacketTypesIn.ServerLinks } }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.CookieResponse }, @@ -239,9 +239,9 @@ public class PacketPalette1215 : PacketTypePalette { 0x06, ConfigurationPacketTypesOut.ResourcePackResponse }, { 0x07, ConfigurationPacketTypesOut.KnownDataPacks } }; - - protected override Dictionary GetListIn() => typeIn; - protected override Dictionary GetListOut() => typeOut; - protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; - protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; - } + + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; + protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; +} diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1216.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1216.cs index e49504fd..3f1520f7 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1216.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1216.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette1216 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Bundle delimiter { 0x01, PacketTypesIn.SpawnEntity }, // Add Entity @@ -142,7 +142,7 @@ public class PacketPalette1216 : PacketTypePalette { 0x85, PacketTypesIn.ShowDialog } // Show Dialog (new in 1.21.6) }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation { 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query @@ -212,7 +212,7 @@ public class PacketPalette1216 : PacketTypePalette { 0x41, PacketTypesOut.CustomClickAction } // Custom Click Action (new in 1.21.6) }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.CookieRequest }, { 0x01, ConfigurationPacketTypesIn.PluginMessage }, @@ -235,7 +235,7 @@ public class PacketPalette1216 : PacketTypePalette { 0x12, ConfigurationPacketTypesIn.ShowDialog } // New in 1.21.6 }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.CookieResponse }, @@ -247,9 +247,9 @@ public class PacketPalette1216 : PacketTypePalette { 0x07, ConfigurationPacketTypesOut.KnownDataPacks }, { 0x08, ConfigurationPacketTypesOut.CustomClickAction } // New in 1.21.6 }; - - protected override Dictionary GetListIn() => typeIn; - protected override Dictionary GetListOut() => typeOut; - protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; - protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; - } + + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; + protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; +} diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1219.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1219.cs index 0f4bfe90..5aab09bc 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1219.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette1219.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette1219 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Bundle delimiter { 0x01, PacketTypesIn.SpawnEntity }, // Add Entity @@ -147,7 +147,7 @@ public class PacketPalette1219 : PacketTypePalette { 0x8A, PacketTypesIn.ShowDialog } // Show Dialog }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation { 0x01, PacketTypesOut.QueryBlockNBT }, // Block Entity Tag Query @@ -217,7 +217,7 @@ public class PacketPalette1219 : PacketTypePalette { 0x41, PacketTypesOut.CustomClickAction } // Custom Click Action }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.CookieRequest }, { 0x01, ConfigurationPacketTypesIn.PluginMessage }, @@ -241,7 +241,7 @@ public class PacketPalette1219 : PacketTypePalette { 0x13, ConfigurationPacketTypesIn.CodeOfConduct } // New in 1.21.9 }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.CookieResponse }, @@ -254,9 +254,9 @@ public class PacketPalette1219 : PacketTypePalette { 0x08, ConfigurationPacketTypesOut.CustomClickAction }, { 0x09, ConfigurationPacketTypesOut.AcceptCodeOfConduct } // New in 1.21.9 }; - - protected override Dictionary GetListIn() => typeIn; - protected override Dictionary GetListOut() => typeOut; - protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; - protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; - } + + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; + protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; +} diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette17.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette17.cs index bd337612..ecbdf4a9 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette17.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette17.cs @@ -114,7 +114,7 @@ namespace MinecraftClient.Protocol.Handlers.PacketPalettes protected override Dictionary GetListIn() => typeIn; protected override Dictionary GetListOut() => typeOut; - + protected override Dictionary GetConfigurationListIn() => new(); protected override Dictionary GetConfigurationListOut() => new(); } diff --git a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette261.cs b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette261.cs index ead41d2c..0f58c527 100644 --- a/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette261.cs +++ b/MinecraftClient/Protocol/Handlers/PacketPalettes/PacketPalette261.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace MinecraftClient.Protocol.Handlers.PacketPalettes; public class PacketPalette261 : PacketTypePalette - { - private readonly Dictionary typeIn = new() +{ + private readonly Dictionary typeIn = new() { { 0x00, PacketTypesIn.Bundle }, // Bundle delimiter { 0x01, PacketTypesIn.SpawnEntity }, // Add Entity @@ -149,7 +149,7 @@ public class PacketPalette261 : PacketTypePalette { 0x8C, PacketTypesIn.ShowDialog } // Show Dialog }; - private readonly Dictionary typeOut = new() + private readonly Dictionary typeOut = new() { { 0x00, PacketTypesOut.TeleportConfirm }, // Accept Teleportation { 0x01, PacketTypesOut.Attack }, // Attack (new in 26.1) @@ -221,7 +221,7 @@ public class PacketPalette261 : PacketTypePalette { 0x44, PacketTypesOut.CustomClickAction } // Custom Click Action }; - private readonly Dictionary configurationTypesIn = new() + private readonly Dictionary configurationTypesIn = new() { { 0x00, ConfigurationPacketTypesIn.CookieRequest }, { 0x01, ConfigurationPacketTypesIn.PluginMessage }, @@ -245,7 +245,7 @@ public class PacketPalette261 : PacketTypePalette { 0x13, ConfigurationPacketTypesIn.CodeOfConduct } }; - private readonly Dictionary configurationTypesOut = new() + private readonly Dictionary configurationTypesOut = new() { { 0x00, ConfigurationPacketTypesOut.ClientInformation }, { 0x01, ConfigurationPacketTypesOut.CookieResponse }, @@ -258,9 +258,9 @@ public class PacketPalette261 : PacketTypePalette { 0x08, ConfigurationPacketTypesOut.CustomClickAction }, { 0x09, ConfigurationPacketTypesOut.AcceptCodeOfConduct } }; - - protected override Dictionary GetListIn() => typeIn; - protected override Dictionary GetListOut() => typeOut; - protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; - protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; - } + + protected override Dictionary GetListIn() => typeIn; + protected override Dictionary GetListOut() => typeOut; + protected override Dictionary GetConfigurationListIn() => configurationTypesIn!; + protected override Dictionary GetConfigurationListOut() => configurationTypesOut!; +} diff --git a/MinecraftClient/Protocol/Handlers/Protocol16.cs b/MinecraftClient/Protocol/Handlers/Protocol16.cs index bb0fb863..78c6cde9 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol16.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol16.cs @@ -949,7 +949,7 @@ namespace MinecraftClient.Protocol.Handlers { return false; //Currently not implemented } - + public bool SendRenameItem(string itemName) { return false; diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 9f56a622..62d3bee1 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -2985,71 +2985,71 @@ namespace MinecraftClient.Protocol.Handlers handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount); break; case PacketTypesIn.NamedSoundEffect: - { - string? soundName = dataTypes.ReadNextString(packetData); - int category = dataTypes.ReadNextVarInt(packetData); - double x = dataTypes.ReadNextInt(packetData) / 8.0D; - double y = dataTypes.ReadNextInt(packetData) / 8.0D; - double z = dataTypes.ReadNextInt(packetData) / 8.0D; - float volume = dataTypes.ReadNextFloat(packetData); - float pitch = protocolVersion < MC_1_10_Version - ? dataTypes.ReadNextByte(packetData) / 63.0f - : dataTypes.ReadNextFloat(packetData); - - handler.OnSoundEffect(soundName, new Location(x, y, z), category, volume, pitch, null); - break; - } - case PacketTypesIn.SoundEffect: - { - string? soundName; - if (protocolVersion >= MC_1_19_Version) - soundName = ReadSoundEventHolderName(packetData); - else { - dataTypes.ReadNextVarInt(packetData); // Sound id - soundName = null; - } + string? soundName = dataTypes.ReadNextString(packetData); + int category = dataTypes.ReadNextVarInt(packetData); + double x = dataTypes.ReadNextInt(packetData) / 8.0D; + double y = dataTypes.ReadNextInt(packetData) / 8.0D; + double z = dataTypes.ReadNextInt(packetData) / 8.0D; + float volume = dataTypes.ReadNextFloat(packetData); + float pitch = protocolVersion < MC_1_10_Version + ? dataTypes.ReadNextByte(packetData) / 63.0f + : dataTypes.ReadNextFloat(packetData); - if (protocolVersion < MC_1_19_Version && packetData.Count < 21) + handler.OnSoundEffect(soundName, new Location(x, y, z), category, volume, pitch, null); break; - - int category = dataTypes.ReadNextVarInt(packetData); - double x = dataTypes.ReadNextInt(packetData) / 8.0D; - double y = dataTypes.ReadNextInt(packetData) / 8.0D; - double z = dataTypes.ReadNextInt(packetData) / 8.0D; - float volume = dataTypes.ReadNextFloat(packetData); - float pitch = protocolVersion < MC_1_10_Version - ? dataTypes.ReadNextByte(packetData) / 63.0f - : dataTypes.ReadNextFloat(packetData); - - if (protocolVersion >= MC_1_19_Version) - dataTypes.ReadNextLong(packetData); // Seed - - handler.OnSoundEffect(soundName, new Location(x, y, z), category, volume, pitch, null); - break; - } - case PacketTypesIn.EntitySoundEffect: - { - string? soundName; - if (protocolVersion >= MC_1_19_Version) - soundName = ReadSoundEventHolderName(packetData); - else - { - dataTypes.ReadNextVarInt(packetData); // Sound id - soundName = null; } + case PacketTypesIn.SoundEffect: + { + string? soundName; + if (protocolVersion >= MC_1_19_Version) + soundName = ReadSoundEventHolderName(packetData); + else + { + dataTypes.ReadNextVarInt(packetData); // Sound id + soundName = null; + } - int category = dataTypes.ReadNextVarInt(packetData); - int entityId = dataTypes.ReadNextVarInt(packetData); - float volume = dataTypes.ReadNextFloat(packetData); - float pitch = dataTypes.ReadNextFloat(packetData); + if (protocolVersion < MC_1_19_Version && packetData.Count < 21) + break; - if (protocolVersion >= MC_1_19_Version) - dataTypes.ReadNextLong(packetData); // Seed + int category = dataTypes.ReadNextVarInt(packetData); + double x = dataTypes.ReadNextInt(packetData) / 8.0D; + double y = dataTypes.ReadNextInt(packetData) / 8.0D; + double z = dataTypes.ReadNextInt(packetData) / 8.0D; + float volume = dataTypes.ReadNextFloat(packetData); + float pitch = protocolVersion < MC_1_10_Version + ? dataTypes.ReadNextByte(packetData) / 63.0f + : dataTypes.ReadNextFloat(packetData); - handler.OnSoundEffect(soundName, null, category, volume, pitch, entityId); - break; - } + if (protocolVersion >= MC_1_19_Version) + dataTypes.ReadNextLong(packetData); // Seed + + handler.OnSoundEffect(soundName, new Location(x, y, z), category, volume, pitch, null); + break; + } + case PacketTypesIn.EntitySoundEffect: + { + string? soundName; + if (protocolVersion >= MC_1_19_Version) + soundName = ReadSoundEventHolderName(packetData); + else + { + dataTypes.ReadNextVarInt(packetData); // Sound id + soundName = null; + } + + int category = dataTypes.ReadNextVarInt(packetData); + int entityId = dataTypes.ReadNextVarInt(packetData); + float volume = dataTypes.ReadNextFloat(packetData); + float pitch = dataTypes.ReadNextFloat(packetData); + + if (protocolVersion >= MC_1_19_Version) + dataTypes.ReadNextLong(packetData); // Seed + + handler.OnSoundEffect(soundName, null, category, volume, pitch, entityId); + break; + } case PacketTypesIn.HeldItemChange: case PacketTypesIn.SetHeldSlot: handler.OnHeldItemChange(dataTypes.ReadNextByte(packetData)); // Slot diff --git a/MinecraftClient/Protocol/Handlers/Protocol18Forge.cs b/MinecraftClient/Protocol/Handlers/Protocol18Forge.cs index 0e93c0bb..e940fc11 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18Forge.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18Forge.cs @@ -377,7 +377,7 @@ namespace MinecraftClient.Protocol.Handlers string registryName = dataTypes.ReadNextString(packetData); ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.forge_fml2_registry, registryName)); } - + fmlResponsePacket.AddRange(DataTypes.GetVarInt(99)); fmlResponseReady = true; break; @@ -410,7 +410,7 @@ namespace MinecraftClient.Protocol.Handlers // [ Version ][ String ] // // We're ignoring this packet in MCC - + if (Settings.Config.Logging.DebugMessages) { ConsoleIO.WriteLineFormatted("§8" + "Received FML3 Server Mod Data List"); @@ -505,7 +505,7 @@ namespace MinecraftClient.Protocol.Handlers { return new ForgeInfo(FMLVersion.FML3); } - return new ForgeInfo(FMLVersion.FML2); + return new ForgeInfo(FMLVersion.FML2); } else throw new InvalidOperationException(Translations.error_forgeforce); } @@ -568,6 +568,6 @@ namespace MinecraftClient.Protocol.Handlers } } return false; - } + } } } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent.cs index b458b786..4741eed0 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/AttributeModifiersComponent.cs @@ -6,13 +6,13 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class AttributeModifiersComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class AttributeModifiersComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfAttributes { get; set; } public List Attributes { get; set; } = new(); public bool ShowInTooltip { get; set; } - + public override void Parse(Queue data) { NumberOfAttributes = DataTypes.ReadNextVarInt(data); @@ -27,13 +27,13 @@ public class AttributeModifiersComponent(DataTypes dataTypes, ItemPalette itemPa { var data = new List(); data.AddRange(DataTypes.GetVarInt(NumberOfAttributes)); - - if(Attributes.Count != NumberOfAttributes) + + if (Attributes.Count != NumberOfAttributes) throw new ArgumentNullException($"Can not serialize a AttributeModifiersComponent when the Attributes count != NumberOfAttributes!"); - + foreach (var attribute in Attributes) data.AddRange(attribute.Serialize()); - + data.AddRange(DataTypes.GetBool(ShowInTooltip)); return new Queue(data); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BannerPatternsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BannerPatternsComponent.cs index 497dd330..fb2a21a4 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BannerPatternsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BannerPatternsComponent.cs @@ -5,12 +5,12 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class BannerPatternsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class BannerPatternsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfLayers { get; set; } public List Layers { get; set; } = []; - + public override void Parse(Queue data) { NumberOfLayers = DataTypes.ReadNextVarInt(data); @@ -44,17 +44,17 @@ public class BannerPatternsComponent(DataTypes dataTypes, ItemPalette itemPalett if (bannerLayer.PatternType == 0) { - if(string.IsNullOrEmpty(bannerLayer.AssetId) || string.IsNullOrEmpty(bannerLayer.TranslationKey)) + if (string.IsNullOrEmpty(bannerLayer.AssetId) || string.IsNullOrEmpty(bannerLayer.TranslationKey)) throw new Exception("Can't serialize BannerPatternsComponent because AssetId or TranslationKey is null/empty!"); - + data.AddRange(DataTypes.GetString(bannerLayer.AssetId)); data.AddRange(DataTypes.GetString(bannerLayer.TranslationKey)); } - + data.AddRange(DataTypes.GetVarInt(bannerLayer.DyeColor)); } } - + return new Queue(data); } } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BaseColorComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BaseColorComponent.cs index 417c658c..615328d2 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BaseColorComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BaseColorComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class BaseColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class BaseColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int DyeColor { get; set; } - + public override void Parse(Queue data) { DyeColor = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BeesComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BeesComponent.cs index cbe0424b..575bfda3 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BeesComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BeesComponent.cs @@ -6,12 +6,12 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class BeesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class BeesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfBees { get; set; } public List Bees { get; set; } = []; - + public override void Parse(Queue data) { NumberOfBees = DataTypes.ReadNextVarInt(data); @@ -30,7 +30,7 @@ public class BeesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp { if (NumberOfBees != Bees.Count) throw new Exception("Can't serialize the BeeComponent because NumberOfBees and Bees.Count differ!"); - + foreach (var bee in Bees) { data.AddRange(DataTypes.GetNbt(bee.EntityDataNbt)); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BlockStateComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BlockStateComponent.cs index c36bb10c..8bbeeb2b 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BlockStateComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BlockStateComponent.cs @@ -4,15 +4,15 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class BlockStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class BlockStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public List<(string, string)> Properties { get; set; } = []; - + public override void Parse(Queue data) { var count = DataTypes.ReadNextVarInt(data); - for(var i = 0; i < count; i++) + for (var i = 0; i < count; i++) Properties.Add((DataTypes.ReadNextString(data), DataTypes.ReadNextString(data))); } @@ -25,7 +25,7 @@ public class BlockStateComponent(DataTypes dataTypes, ItemPalette itemPalette, S data.AddRange(DataTypes.GetString(key)); data.AddRange(DataTypes.GetString(value)); } - + return new Queue(data); } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs index 753a621b..76e11195 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs @@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class BundleContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class BundleContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public List Items { get; set; } = []; diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent.cs index d561788b..aeff50f2 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanBreakComponent.cs @@ -7,13 +7,13 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CanBreakComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CanBreakComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfPredicates { get; set; } public List BlockPredicates { get; set; } = new(); public bool ShowInTooltip { get; set; } - + public override void Parse(Queue data) { NumberOfPredicates = DataTypes.ReadNextVarInt(data); @@ -28,13 +28,13 @@ public class CanBreakComponent(DataTypes dataTypes, ItemPalette itemPalette, Sub { var data = new List(); data.AddRange(DataTypes.GetVarInt(NumberOfPredicates)); - - if(NumberOfPredicates > 0 && BlockPredicates.Count == 0) + + if (NumberOfPredicates > 0 && BlockPredicates.Count == 0) throw new ArgumentNullException($"Can not serialize a CanBreakComponent when the BlockPredicates is empty but NumberOfPredicates is > 0!"); - + foreach (var blockPredicate in BlockPredicates) data.AddRange(blockPredicate.Serialize()); - + data.AddRange(DataTypes.GetBool(ShowInTooltip)); return new Queue(data); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent.cs index 2a15d58d..0134563e 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CanPlaceOnComponent.cs @@ -7,13 +7,13 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CanPlaceOnComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CanPlaceOnComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfPredicates { get; set; } public List BlockPredicates { get; set; } = new(); public bool ShowInTooltip { get; set; } - + public override void Parse(Queue data) { NumberOfPredicates = DataTypes.ReadNextVarInt(data); @@ -28,13 +28,13 @@ public class CanPlaceOnComponent(DataTypes dataTypes, ItemPalette itemPalette, S { var data = new List(); data.AddRange(DataTypes.GetVarInt(NumberOfPredicates)); - - if(NumberOfPredicates > 0 && BlockPredicates.Count == 0) + + if (NumberOfPredicates > 0 && BlockPredicates.Count == 0) throw new ArgumentNullException($"Can not serialize a CanPlaceOnComponent when the BlockPredicates is empty but NumberOfPredicates is > 0!"); - + foreach (var blockPredicate in BlockPredicates) data.AddRange(blockPredicate.Serialize()); - + data.AddRange(DataTypes.GetBool(ShowInTooltip)); return new Queue(data); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs index 55e597a3..5a5259ad 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs @@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class ChargedProjectilesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class ChargedProjectilesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public List Items { get; set; } = []; diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerComponent.cs index f198952a..5264f43d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerComponent.cs @@ -5,11 +5,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class ContainerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class ContainerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public List Items { get; set; } = []; - + public override void Parse(Queue data) { var count = DataTypes.ReadNextVarInt(data); @@ -23,7 +23,7 @@ public class ContainerComponent(DataTypes dataTypes, ItemPalette itemPalette, Su data.AddRange(DataTypes.GetVarInt(Items.Count)); foreach (var item in Items) data.AddRange(DataTypes.GetItemSlot(item, ItemPalette)); - + return new Queue(data); } } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerLootComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerLootComponent.cs index a1ebfa6c..8b68ecd7 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerLootComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ContainerLootComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class ContainerLootComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class ContainerLootComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } - + public override void Parse(Queue data) { Nbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent.cs index 06989ec9..6d188397 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSlotLockComponent.cs @@ -4,5 +4,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CreativeSlotLockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CreativeSlotLockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EmptyComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent.cs index 4abf1782..9509d539 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomDataComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CustomDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CustomDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } = new(); - + public override void Parse(Queue data) { Nbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent.cs index 2aa9ee0b..20df0870 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomModelDataComponent.cs @@ -10,7 +10,7 @@ public class CustomModelDataComponent(DataTypes dataTypes, ItemPalette itemPalet public List Flags { get; set; } = []; public List Strings { get; set; } = []; public List Colors { get; set; } = []; - + public override void Parse(Queue data) { Floats = ReadList(data, static (dataTypes, componentData) => dataTypes.ReadNextFloat(componentData)); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent.cs index 140b60d5..1104b598 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/CustomNameComponent.cs @@ -5,12 +5,12 @@ using MinecraftClient.Protocol.Message; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class CustomNameComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class CustomNameComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public string CustomName { get; set; } = string.Empty; public Dictionary? CustomNameNbt { get; set; } - + public override void Parse(Queue data) { CustomNameNbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent.cs index 3c377177..c105ee0c 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DamageComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class DamageComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class DamageComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Damage { get; set; } - + public override void Parse(Queue data) { Damage = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DebugStickStateComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DebugStickStateComponent.cs index 3d2eba6d..a39a352d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DebugStickStateComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DebugStickStateComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class DebugStickStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class DebugStickStateComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } - + public override void Parse(Queue data) { Nbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent.cs index deb3f584..d887ecee 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/DyeColorComponent.cs @@ -4,12 +4,12 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class DyeColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class DyeColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Color { get; set; } public bool ShowInTooltip { get; set; } - + public override void Parse(Queue data) { Color = DataTypes.ReadNextInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent.cs index af8032fc..6528ffb5 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentGlintOverrideComponent.cs @@ -8,7 +8,7 @@ public class EnchantmentGlintOverrideComponent(DataTypes dataTypes, ItemPalette : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public bool HasGlint { get; set; } - + public override void Parse(Queue data) { HasGlint = DataTypes.ReadNextBool(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent.cs index 579777be..8322201f 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EnchantmentsComponent.cs @@ -5,7 +5,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class EnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class EnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfEnchantments { get; set; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EntityDataComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EntityDataComponent.cs index a40b7bc6..ba31c9f9 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EntityDataComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/EntityDataComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class EntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class EntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } - + public override void Parse(Queue data) { Nbt = DataTypes.ReadNextNbt(data); @@ -22,8 +22,10 @@ public class EntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, S } } -public class BucketEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) - : EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) {} +public class BucketEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) +{ } -public class BlockEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) - : EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) {} \ No newline at end of file +public class BlockEntityDataComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + : EntityDataComponent(dataTypes, itemPalette, subComponentRegistry) +{ } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent.cs index e0eed96c..351eb684 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireResistantComponent.cs @@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class FireResistantComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class FireResistantComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EmptyComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworkExplosionComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworkExplosionComponent.cs index b85a0d93..a515f3bb 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworkExplosionComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworkExplosionComponent.cs @@ -8,11 +8,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class FireworkExplosionComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class FireworkExplosionComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public FireworkExplosionSubComponent? FireworkExplosionSubComponent { get; set; } - + public override void Parse(Queue data) { FireworkExplosionSubComponent = (FireworkExplosionSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.FireworkExplosion, data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworksComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworksComponent.cs index 46fdfacd..db73c815 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworksComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FireworksComponent.cs @@ -9,14 +9,14 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int FlightDuration { get; set; } public int NumberOfExplosions { get; set; } public List Explosions { get; set; } = []; - + public override void Parse(Queue data) { FlightDuration = DataTypes.ReadNextVarInt(data); @@ -24,7 +24,7 @@ public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, Su if (NumberOfExplosions > 0) { - for(var i = 0; i < NumberOfExplosions; i++) + for (var i = 0; i < NumberOfExplosions; i++) Explosions.Add( (FireworkExplosionSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.FireworkExplosion, data)); @@ -40,8 +40,8 @@ public class FireworksComponent(DataTypes dataTypes, ItemPalette itemPalette, Su { if (NumberOfExplosions != Explosions.Count) throw new Exception("Can't serialize FireworksComponent because NumberOfExplosions and the lenght of Explosions differ!"); - - foreach(var explosion in Explosions) + + foreach (var explosion in Explosions) data.AddRange(explosion.Serialize().ToList()); } return new Queue(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent.cs index 276de892..eb5ed17d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/FoodComponentComponent.cs @@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Nutrition { get; set; } @@ -15,7 +15,7 @@ public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette public bool CanAlwaysEat { get; set; } public float SecondsToEat { get; set; } public List Effects { get; set; } = new(); - + public override void Parse(Queue data) { Nutrition = DataTypes.ReadNextVarInt(data); @@ -23,8 +23,8 @@ public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette CanAlwaysEat = DataTypes.ReadNextBool(data); SecondsToEat = DataTypes.ReadNextFloat(data); var numberOfEffects = DataTypes.ReadNextVarInt(data); - - for(var i = 0; i < numberOfEffects; i++) + + for (var i = 0; i < numberOfEffects; i++) Effects.Add((EffectSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.Effect, data)); } @@ -37,9 +37,9 @@ public class FoodComponentComponent(DataTypes dataTypes, ItemPalette itemPalette data.AddRange(DataTypes.GetFloat(SecondsToEat)); data.AddRange(DataTypes.GetVarInt(Effects.Count)); - foreach(var effect in Effects) + foreach (var effect in Effects) data.AddRange(effect.Serialize()); - + return new Queue(data); } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent.cs index 13a7197a..9f659b9f 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideAdditionalTooltipComponent.cs @@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class HideAdditionalTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class HideAdditionalTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EmptyComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent.cs index b1d0783e..77cdc7fa 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/HideTooltipComponent.cs @@ -3,5 +3,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class HideTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class HideTooltipComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EmptyComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/InstrumentComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/InstrumentComponent.cs index 8c0895eb..87692b70 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/InstrumentComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/InstrumentComponent.cs @@ -4,7 +4,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class InstrumentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class InstrumentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { // holder ID: 0 = inline instrument data, N>0 = registry reference (id = N-1) @@ -20,7 +20,7 @@ public class InstrumentComponent(DataTypes dataTypes, ItemPalette itemPalette, S public int UseDuration { get; set; } public float Range { get; set; } - + public override void Parse(Queue data) { InstrumentHolderId = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent.cs index 5006fad0..2ecfe0f1 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/IntangibleProjectileComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class IntangibleProjectileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class IntangibleProjectileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } = new(); - + public override void Parse(Queue data) { Nbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent.cs index 3aa26373..4b42c779 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ItemNameComponent.cs @@ -5,12 +5,12 @@ using MinecraftClient.Protocol.Message; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class ItemNameComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class ItemNameComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public string ItemName { get; set; } = string.Empty; public Dictionary? ItemNameNbt { get; set; } - + public override void Parse(Queue data) { ItemNameNbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LockComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LockComponent.cs index cc7b924c..85d050e2 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LockComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LockComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class LockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class LockComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } - + public override void Parse(Queue data) { Nbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LodestoneTrackerComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LodestoneTrackerComponent.cs index b1cdda3a..f3353755 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LodestoneTrackerComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LodestoneTrackerComponent.cs @@ -5,14 +5,14 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class LodestoneTrackerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class LodestoneTrackerComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public bool HasGlobalPosition { get; set; } public string Dimension { get; set; } = null!; public Location Position { get; set; } public bool Tracked { get; set; } - + public override void Parse(Queue data) { HasGlobalPosition = DataTypes.ReadNextBool(data); @@ -22,7 +22,7 @@ public class LodestoneTrackerComponent(DataTypes dataTypes, ItemPalette itemPale Dimension = DataTypes.ReadNextString(data); Position = DataTypes.ReadNextLocation(data); } - + Tracked = DataTypes.ReadNextBool(data); } @@ -36,7 +36,7 @@ public class LodestoneTrackerComponent(DataTypes dataTypes, ItemPalette itemPale data.AddRange(DataTypes.GetString(Dimension)); data.AddRange(DataTypes.GetLocation(Position)); } - + data.AddRange(DataTypes.GetBool(Tracked)); return new Queue(data); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LoreComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LoreComponent.cs index 2c5219f9..d8cb5161 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LoreComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/LoreComponent.cs @@ -5,19 +5,19 @@ using MinecraftClient.Protocol.Message; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class LoreNameComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class LoreNameComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfLines { get; set; } public List Lines { get; set; } = []; public List> LinesNbt { get; set; } = []; - + public override void Parse(Queue data) { NumberOfLines = DataTypes.ReadNextVarInt(data); - + if (NumberOfLines <= 0) return; - + for (var i = 0; i < NumberOfLines; i++) { var lineNbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent.cs index af5a6989..457e74b5 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapColorComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MapColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MapColorComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Id { get; set; } - + public override void Parse(Queue data) { Id = DataTypes.ReadNextInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent.cs index 4c38ec50..70b8b28d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapDecorationsComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MapDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MapDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } = new(); - + public override void Parse(Queue data) { Nbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent.cs index 88312a23..712b721f 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapIdComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MapIdComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MapIdComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Id { get; set; } - + public override void Parse(Queue data) { Id = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent.cs index cda1ced4..c7d58700 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MapPostProcessingComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MapPostProcessingComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MapPostProcessingComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Type { get; set; } - + public override void Parse(Queue data) { Type = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent.cs index fd90e8bf..45e8545b 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxDamageComponent.cs @@ -8,7 +8,7 @@ public class MaxDamageComponent(DataTypes dataTypes, ItemPalette itemPalette, Su : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int MaxDamage { get; set; } - + public override void Parse(Queue data) { MaxDamage = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent.cs index 6bd20710..32da4c9f 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/MaxStackSizeComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class MaxStackSizeComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class MaxStackSizeComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int MaxStackSize { get; set; } - + public override void Parse(Queue data) { MaxStackSize = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/NoteBlockSoundComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/NoteBlockSoundComponent.cs index 985c7609..5d7c0792 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/NoteBlockSoundComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/NoteBlockSoundComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class NoteBlockSoundComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class NoteBlockSoundComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public string Identifier { get; set; } = null!; - + public override void Parse(Queue data) { Identifier = DataTypes.ReadNextString(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/OmniousBottleAmplifierComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/OmniousBottleAmplifierComponent.cs index 6f688b79..1c35b944 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/OmniousBottleAmplifierComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/OmniousBottleAmplifierComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class OmniousBottleAmplifierComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class OmniousBottleAmplifierComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Amplifier { get; set; } - + public override void Parse(Queue data) { Amplifier = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotDecorationsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotDecorationsComponent.cs index e7bf200e..97b91827 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotDecorationsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotDecorationsComponent.cs @@ -4,15 +4,15 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class PotDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class PotDecorationsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public List Items { get; set; } = []; - + public override void Parse(Queue data) { var count = DataTypes.ReadNextVarInt(data); - for(var i = 0; i < count; i++) + for (var i = 0; i < count; i++) Items.Add(DataTypes.ReadNextVarInt(data)); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent.cs index ff76f5a7..b56e6897 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/PotionContentsComponent.cs @@ -6,7 +6,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public bool HasPotionId { get; set; } @@ -14,7 +14,7 @@ public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalett public bool HasCustomColor { get; set; } public int CustomColor { get; set; } public List Effects { get; set; } = new(); - + public override void Parse(Queue data) { HasPotionId = DataTypes.ReadNextBool(data); @@ -44,7 +44,7 @@ public class PotionContentsComponent(DataTypes dataTypes, ItemPalette itemPalett data.AddRange(DataTypes.GetVarInt(Effects.Count)); foreach (var effect in Effects) data.AddRange(effect.Serialize()); - + return new Queue(data); } } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ProfileComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ProfileComponent.cs index d8540488..ff98f5de 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ProfileComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ProfileComponent.cs @@ -18,7 +18,7 @@ public class ProfileComponent(DataTypes dataTypes, ItemPalette itemPalette, SubC public string? CapeAssetId { get; set; } public string? ElytraAssetId { get; set; } public ProfileSkinModel? Model { get; set; } - + public override void Parse(Queue data) { ResetState(); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent.cs index 2814cf2b..cbe3b9e9 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RarityComponent.cs @@ -5,11 +5,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class RarityComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class RarityComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public ItemRarity Rarity { get; set; } - + public override void Parse(Queue data) { Rarity = (ItemRarity)DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RecipesComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RecipesComponent.cs index 7f95bcd0..9df0e22b 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RecipesComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RecipesComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class RecipesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class RecipesComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public Dictionary? Nbt { get; set; } - + public override void Parse(Queue data) { Nbt = DataTypes.ReadNextNbt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent.cs index b025a0a7..951f14f5 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/RepairCostComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class RepairCostComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class RepairCostComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int Cost { get; set; } - + public override void Parse(Queue data) { Cost = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent.cs index 0ddbc431..a741d54d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/StoredEnchantmentsComponent.cs @@ -5,5 +5,5 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class StoredEnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class StoredEnchantmentsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : EnchantmentsComponent(dataTypes, itemPalette, subComponentRegistry); \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent.cs index d97dee90..b6518820 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/SuspiciousStewEffectsComponent.cs @@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class SuspiciousStewEffectsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class SuspiciousStewEffectsComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfEffects { get; set; } @@ -28,7 +28,7 @@ public class SuspiciousStewEffectsComponent(DataTypes dataTypes, ItemPalette ite if (NumberOfEffects != Effects.Count) throw new InvalidOperationException("Can not serialize SuspiciousStewEffectsComponent1206 because umberOfEffects != Effects.Count!"); - + foreach (var effect in Effects) { data.AddRange(DataTypes.GetVarInt(effect.TypeId)); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent.cs index 033d41bf..2d761739 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ToolComponent.cs @@ -7,14 +7,14 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class ToolComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class ToolComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public int NumberOfRules { get; set; } public List Rules { get; set; } = new(); public float DefaultMiningSpeed { get; set; } public int DamagePerBlock { get; set; } - + public override void Parse(Queue data) { NumberOfRules = DataTypes.ReadNextVarInt(data); @@ -30,13 +30,13 @@ public class ToolComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp { var data = new List(); data.AddRange(DataTypes.GetVarInt(NumberOfRules)); - - if(Rules.Count != NumberOfRules) + + if (Rules.Count != NumberOfRules) throw new ArgumentNullException($"Can not serialize a ToolComponent1206 when the Rules count != NumberOfRules!"); - + foreach (var rule in Rules) data.AddRange(rule.Serialize()); - + data.AddRange(DataTypes.GetFloat(DefaultMiningSpeed)); data.AddRange(DataTypes.GetVarInt(DamagePerBlock)); return new Queue(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/TrimComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/TrimComponent.cs index ed474825..90b79127 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/TrimComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/TrimComponent.cs @@ -24,7 +24,7 @@ public class TrimComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp public string TrimPatternTypeDescription { get; set; } = null!; public bool Decal { get; set; } public bool ShowInTooltip { get; set; } - + public override void Parse(Queue data) { TrimMaterialType = DataTypes.ReadNextVarInt(data); @@ -73,16 +73,16 @@ public class TrimComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp { if (string.IsNullOrEmpty(AssetName)) throw new NullReferenceException("Can't serialize the TrimComponent because the Asset Name is null!"); - + data.AddRange(DataTypes.GetString(AssetName)); data.AddRange(DataTypes.GetVarInt(Ingredient)); data.AddRange(DataTypes.GetFloat(ItemModelIndex)); data.AddRange(DataTypes.GetVarInt(NumberOfOverrides)); if (NumberOfOverrides > 0) { - if(NumberOfOverrides != Overrides?.Count) + if (NumberOfOverrides != Overrides?.Count) throw new NullReferenceException("Can't serialize the TrimComponent because value of NumberOfOverrides and the size of Overrides don't match!"); - + foreach (var (armorMaterialType, assetName) in Overrides) { data.AddRange(DataTypes.GetVarInt(armorMaterialType)); @@ -97,15 +97,15 @@ public class TrimComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComp { if (string.IsNullOrEmpty(TrimPatternTypeAssetName)) throw new NullReferenceException("Can't serialize the TrimComponent because the TrimPatternTypeAssetName is null!"); - + data.AddRange(DataTypes.GetString(TrimPatternTypeAssetName)); data.AddRange(DataTypes.GetVarInt(TemplateItem)); data.AddRange(DataTypes.GetNbt(TrimPatternTypeDescriptionNbt)); data.AddRange(DataTypes.GetBool(Decal)); } - + data.AddRange(DataTypes.GetBool(ShowInTooltip)); - + return new Queue(data); } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/UnbreakableComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/UnbreakableComponent.cs index bfc09cda..d7fc891a 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/UnbreakableComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/UnbreakableComponent.cs @@ -4,11 +4,11 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_20_6; -public class UnbrekableComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class UnbrekableComponent1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public bool Unbrekable { get; set; } - + public override void Parse(Queue data) { Unbrekable = DataTypes.ReadNextBool(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent.cs index c366e6b7..9a2b9a30 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WritableBlookContentComponent.cs @@ -9,7 +9,7 @@ namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_2 public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public List Pages { get; set; } = []; - + public override void Parse(Queue data) { var count = DataTypes.ReadNextVarInt(data); @@ -19,10 +19,10 @@ public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette item var rawContent = DataTypes.ReadNextString(data); var hasFilteredContent = DataTypes.ReadNextBool(data); var filteredContent = null as string; - - if(hasFilteredContent) + + if (hasFilteredContent) filteredContent = DataTypes.ReadNextString(data); - + Pages.Add(new BookPage(rawContent, hasFilteredContent, filteredContent)); } } @@ -30,7 +30,7 @@ public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette item public override Queue Serialize() { var data = new List(); - + data.AddRange(DataTypes.GetVarInt(Pages.Count)); foreach (var page in Pages) @@ -40,9 +40,9 @@ public class WritableBlookContentComponent(DataTypes dataTypes, ItemPalette item if (page.HasFilteredContent) { - if(page.FilteredContent is null) + if (page.FilteredContent is null) throw new InvalidOperationException("Can not serialize WritableBlookContentComponent because page.HasFilteredContent = true, but FilteredContent is null!"); - + data.AddRange(DataTypes.GetString(page.FilteredContent)); } } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent.cs index 55650913..4f42d19f 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/WrittenBlookContentComponent.cs @@ -17,7 +17,7 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP public int NumberOfPages { get; set; } public List Pages { get; set; } = []; public bool Resolved { get; set; } - + public override void Parse(Queue data) { RawTitle = DataTypes.ReadNextString(data); @@ -25,7 +25,7 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP if (HasFilteredTitle) FilteredTitle = DataTypes.ReadNextString(data); - + Author = DataTypes.ReadNextString(data); Generation = DataTypes.ReadNextVarInt(data); NumberOfPages = DataTypes.ReadNextVarInt(data); @@ -37,13 +37,13 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP var hasFilteredContent = DataTypes.ReadNextBool(data); Dictionary? filteredContentNbt = null; string? filteredContent = null; - + if (hasFilteredContent) { filteredContentNbt = DataTypes.ReadNextNbt(data); filteredContent = ChatParser.ParseText(filteredContentNbt); } - + Pages.Add(new BookPage(rawContent, hasFilteredContent, filteredContent, rawContentNbt, filteredContentNbt)); } @@ -53,18 +53,18 @@ public class WrittenBlookContentComponent(DataTypes dataTypes, ItemPalette itemP public override Queue Serialize() { var data = new List(); - + data.AddRange(DataTypes.GetString(RawTitle)); data.AddRange(DataTypes.GetBool(HasFilteredTitle)); if (HasFilteredTitle) { - if(FilteredTitle is null) + if (FilteredTitle is null) throw new InvalidOperationException("Can not serialize WrittenBookContentComponent because HasFilteredTitle is true but FilteredTitle is null!"); - + data.AddRange(DataTypes.GetString(FilteredTitle)); } - + data.AddRange(DataTypes.GetString(Author)); data.AddRange(DataTypes.GetVarInt(Generation)); data.AddRange(DataTypes.GetVarInt(Pages.Count)); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21/JukeBoxPlayableComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21/JukeBoxPlayableComponent.cs index d5f7c6f5..e1e0a3e1 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21/JukeBoxPlayableComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21/JukeBoxPlayableComponent.cs @@ -7,7 +7,7 @@ using MinecraftClient.Protocol.Handlers.StructuredComponents.Core; namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Components._1_21; -public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) +public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : StructuredComponent(dataTypes, itemPalette, subComponentRegistry) { public bool DirectMode { get; set; } @@ -18,7 +18,7 @@ public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalet public float? Duration { get; set; } public int? Output { get; set; } public bool ShowTooltip { get; set; } - + public override void Parse(Queue data) { DirectMode = DataTypes.ReadNextBool(data); @@ -46,22 +46,22 @@ public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalet public override Queue Serialize() { var data = new List(); - + data.AddRange(DataTypes.GetBool(DirectMode)); if (!DirectMode) { if (string.IsNullOrEmpty(SongName?.Trim())) throw new ArgumentNullException($"Can not serialize JukeBoxPlayableComponent due to SongName being null or empty!"); - + data.AddRange(DataTypes.GetString(SongName)); } if (DirectMode) { - if(SongType is null) + if (SongType is null) throw new ArgumentNullException($"Can not serialize JukeBoxPlayableComponent due to SongType being null!"); - + data.AddRange(DataTypes.GetVarInt((int)SongType)); if (SongType == 0) @@ -91,9 +91,9 @@ public class JukeBoxPlayableComponent(DataTypes dataTypes, ItemPalette itemPalet data.AddRange(DataTypes.GetVarInt((int)Output)); } } - + data.AddRange(DataTypes.GetBool(ShowTooltip)); - + return new Queue(data); } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/EquippableComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/EquippableComponent.cs index 46191449..eb3a93b0 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/EquippableComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/EquippableComponent.cs @@ -27,7 +27,7 @@ public class EquippableComponent(DataTypes dataTypes, ItemPalette itemPalette, S { Slot = DataTypes.ReadNextVarInt(data); EquipSound = (SoundEventSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.SoundEvent, data); - + HasModel = DataTypes.ReadNextBool(data); if (HasModel) Model = DataTypes.ReadNextString(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/TypedEntityDataComponent261.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/TypedEntityDataComponent261.cs index d3d7c507..15940d06 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/TypedEntityDataComponent261.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/26_1/TypedEntityDataComponent261.cs @@ -26,4 +26,5 @@ public class TypedEntityDataComponent261(DataTypes dataTypes, ItemPalette itemPa } public class BlockEntityDataComponent261(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) - : TypedEntityDataComponent261(dataTypes, itemPalette, subComponentRegistry) {} + : TypedEntityDataComponent261(dataTypes, itemPalette, subComponentRegistry) +{ } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent.cs index 897d41b8..72905355 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/AttributeSubComponent.cs @@ -12,7 +12,7 @@ public class AttributeSubComponent(DataTypes dataTypes, SubComponentRegistry sub public double Value { get; set; } public int Operation { get; set; } public int Slot { get; set; } - + protected override void Parse(Queue data) { TypeId = DataTypes.ReadNextVarInt(data); @@ -28,10 +28,10 @@ public class AttributeSubComponent(DataTypes dataTypes, SubComponentRegistry sub var data = new List(); data.AddRange(DataTypes.GetVarInt(TypeId)); data.AddRange(DataTypes.GetUUID(Uuid)); - + if (string.IsNullOrEmpty(Name?.Trim())) throw new ArgumentNullException($"Can not serialize AttributeSubComponent due to Name being null or empty!"); - + data.AddRange(DataTypes.GetString(Name)); data.AddRange(DataTypes.GetDouble(Value)); data.AddRange(DataTypes.GetVarInt(Operation)); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs index d66eb47c..74639c6e 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockPredicateSubcomponent.cs @@ -12,7 +12,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr public List? Properties { get; set; } public bool HasNbt { get; set; } public Dictionary? Nbt { get; set; } - + protected override void Parse(Queue data) { HasBlocks = DataTypes.ReadNextBool(data); @@ -31,7 +31,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr } HasNbt = DataTypes.ReadNextBool(data); - + if (HasNbt) Nbt = DataTypes.ReadNextNbt(data); } @@ -39,22 +39,22 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr public override Queue Serialize() { var data = new List(); - + // Block Sets data.AddRange(DataTypes.GetBool(HasBlocks)); if (HasBlocks) { - if(BlockSet is null) + if (BlockSet is null) throw new ArgumentNullException($"Can not serialize a BlockPredicate when the BlockSet is empty but HasBlocks is true!"); - + data.AddRange(BlockSet.Serialize()); } - + // Properties data.AddRange(DataTypes.GetBool(HasProperities)); if (HasProperities) { - if(Properties is null || Properties.Count == 0) + if (Properties is null || Properties.Count == 0) throw new ArgumentNullException($"Can not serialize a BlockPredicate when the Properties is empty but HasProperties is true!"); data.AddRange(DataTypes.GetVarInt(Properties.Count)); @@ -66,12 +66,12 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr data.AddRange(DataTypes.GetBool(HasNbt)); if (HasNbt) { - if(Nbt is null) + if (Nbt is null) throw new ArgumentNullException($"Can not serialize a BlockPredicate when the Nbt is empty but HasNbt is true!"); - + data.AddRange(DataTypes.GetNbt(Nbt)); } - + return new Queue(data); } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent.cs index 70f2b78c..2fe1be6d 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/BlockSetSubcomponent.cs @@ -9,7 +9,7 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC public int Type { get; set; } public string? TagName { get; set; } public List? BlockIds { get; set; } - + protected override void Parse(Queue data) { Type = DataTypes.ReadNextVarInt(data); @@ -18,9 +18,9 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC TagName = DataTypes.ReadNextString(data); if (Type == 0) return; - + BlockIds = []; - + for (var i = 0; i < Type - 1; i++) BlockIds.Add(DataTypes.ReadNextVarInt(data)); } @@ -33,16 +33,16 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC { if (string.IsNullOrEmpty(TagName?.Trim())) throw new ArgumentNullException($"Can not serialize an empty tag name when the Block Set type is 0!"); - + data.AddRange(DataTypes.GetString(TagName)); } if (Type == 0) return new Queue(data); - - if(BlockIds is null || BlockIds.Count == 0) + + if (BlockIds is null || BlockIds.Count == 0) throw new ArgumentNullException($"Can not serialize an empty list of Block IDs in a Block Set when the type is not 0!"); - - for(var i = 0; i < Type - 1; i++) + + for (var i = 0; i < Type - 1; i++) data.AddRange(DataTypes.GetVarInt(BlockIds[i])); return new Queue(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent.cs index ac6b28c9..05b3c918 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/DetailsSubComponent.cs @@ -13,7 +13,7 @@ public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subCo public bool ShowIcon { get; set; } public bool HasHiddenEffects { get; set; } public DetailsSubComponent? Detail { get; set; } - + protected override void Parse(Queue data) { Amplifier = DataTypes.ReadNextVarInt(data); @@ -22,8 +22,8 @@ public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subCo ShowParticles = DataTypes.ReadNextBool(data); ShowIcon = DataTypes.ReadNextBool(data); HasHiddenEffects = DataTypes.ReadNextBool(data); - - if(HasHiddenEffects) + + if (HasHiddenEffects) Detail = (DetailsSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.Details, data); } @@ -39,9 +39,9 @@ public class DetailsSubComponent(DataTypes dataTypes, SubComponentRegistry subCo if (HasHiddenEffects) { - if(Detail is null) + if (Detail is null) throw new ArgumentNullException($"Can not serialize a DetailSubComponent1206 when the Detail is empty but HasHiddenEffects is true!"); - + data.AddRange(Detail.Serialize()); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent.cs index 250cbd6f..d17d43f0 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/EffectSubComponent.cs @@ -8,7 +8,7 @@ public class EffectSubComponent(DataTypes dataTypes, SubComponentRegistry subCom { public PotionEffectSubComponent TypeId { get; set; } = null!; public float Probability { get; set; } - + protected override void Parse(Queue data) { TypeId = (PotionEffectSubComponent)SubComponentRegistry.ParseSubComponent(SubComponents.PotionEffect, data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/FireworkExplosionSubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/FireworkExplosionSubComponent.cs index 37fec5b7..8073964c 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/FireworkExplosionSubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/FireworkExplosionSubComponent.cs @@ -13,7 +13,7 @@ public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegi public List FadeColors { get; set; } = []; public bool HasTrail { get; set; } public bool HasTwinkle { get; set; } - + protected override void Parse(Queue data) { Shape = DataTypes.ReadNextVarInt(data); @@ -21,12 +21,12 @@ public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegi for (var i = 0; i < NumberOfColors; i++) Colors.Add(DataTypes.ReadNextInt(data)); - + NumberOfFadeColors = DataTypes.ReadNextVarInt(data); for (var i = 0; i < NumberOfFadeColors; i++) FadeColors.Add(DataTypes.ReadNextInt(data)); - + HasTrail = DataTypes.ReadNextBool(data); HasTwinkle = DataTypes.ReadNextBool(data); } @@ -45,7 +45,7 @@ public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegi foreach (var color in Colors) data.AddRange(DataTypes.GetInt(color)); } - + data.AddRange(DataTypes.GetVarInt(NumberOfFadeColors)); if (NumberOfFadeColors > 0) { @@ -55,7 +55,7 @@ public class FireworkExplosionSubComponent(DataTypes dataTypes, SubComponentRegi foreach (var fadeColor in FadeColors) data.AddRange(DataTypes.GetInt(fadeColor)); } - + data.AddRange(DataTypes.GetBool(HasTrail)); data.AddRange(DataTypes.GetBool(HasTwinkle)); return new Queue(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent.cs index d667c5b3..dc9e31f0 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PotionEffectSubComponent.cs @@ -8,7 +8,7 @@ public class PotionEffectSubComponent(DataTypes dataTypes, SubComponentRegistry { public int TypeId { get; set; } public DetailsSubComponent Details { get; set; } = null!; - + protected override void Parse(Queue data) { TypeId = DataTypes.ReadNextVarInt(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs index af83fc08..52e18770 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/PropertySubComponent.cs @@ -11,7 +11,7 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC public string? ExactValue { get; set; } public string? MinValue { get; set; } public string? MaxValue { get; set; } - + protected override void Parse(Queue data) { Name = DataTypes.ReadNextString(data); @@ -34,7 +34,7 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC if (string.IsNullOrEmpty(Name?.Trim())) throw new ArgumentNullException($"Can not serialize a Property sub-component if the Name is null or empty!"); - + data.AddRange(DataTypes.GetString(Name)); data.AddRange(DataTypes.GetBool(IsExactMatch)); @@ -42,7 +42,7 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC { if (string.IsNullOrEmpty(ExactValue?.Trim())) throw new ArgumentNullException($"Can not serialize a Property sub-component if the ExactValue is null or empty when the type is Exact Match!"); - + data.AddRange(DataTypes.GetString(ExactValue)); } else @@ -50,12 +50,12 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC data.AddRange(DataTypes.GetBool(MinValue is not null)); if (MinValue is not null) data.AddRange(DataTypes.GetString(MinValue)); - + data.AddRange(DataTypes.GetBool(MaxValue is not null)); if (MaxValue is not null) data.AddRange(DataTypes.GetString(MaxValue)); } - + return new Queue(data); } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent.cs index 1356ceef..74565c9b 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_20_6/RuleSubComponent.cs @@ -11,18 +11,18 @@ public class RuleSubComponent(DataTypes dataTypes, SubComponentRegistry subCompo public float Speed { get; set; } public bool HasCorrectDropForBlocks { get; set; } public bool CorrectDropForBlocks { get; set; } - + protected override void Parse(Queue data) { Blocks = (BlockSetSubcomponent)SubComponentRegistry.ParseSubComponent(SubComponents.BlockSet, data); HasSpeed = DataTypes.ReadNextBool(data); - - if(HasSpeed) + + if (HasSpeed) Speed = DataTypes.ReadNextFloat(data); - + HasCorrectDropForBlocks = DataTypes.ReadNextBool(data); - - if(HasCorrectDropForBlocks) + + if (HasCorrectDropForBlocks) CorrectDropForBlocks = DataTypes.ReadNextBool(data); } @@ -31,13 +31,13 @@ public class RuleSubComponent(DataTypes dataTypes, SubComponentRegistry subCompo var data = new List(); data.AddRange(Blocks.Serialize()); data.AddRange(DataTypes.GetBool(HasSpeed)); - if(HasSpeed) + if (HasSpeed) data.AddRange(DataTypes.GetFloat(Speed)); data.AddRange(DataTypes.GetBool(HasCorrectDropForBlocks)); - if(HasCorrectDropForBlocks) + if (HasCorrectDropForBlocks) data.AddRange(DataTypes.GetBool(CorrectDropForBlocks)); - + return new Queue(data); } } \ No newline at end of file diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_21/AttributeSubComponent121.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_21/AttributeSubComponent121.cs index 46b70970..60bc94dc 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_21/AttributeSubComponent121.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_21/AttributeSubComponent121.cs @@ -11,7 +11,7 @@ public class AttributeSubComponent121(DataTypes dataTypes, SubComponentRegistry public double Value { get; set; } public int Operation { get; set; } public int Slot { get; set; } - + protected override void Parse(Queue data) { TypeId = DataTypes.ReadNextVarInt(data); @@ -25,10 +25,10 @@ public class AttributeSubComponent121(DataTypes dataTypes, SubComponentRegistry { var data = new List(); data.AddRange(DataTypes.GetVarInt(TypeId)); - + if (string.IsNullOrEmpty(ResourceLocation?.Trim())) throw new ArgumentNullException($"Can not serialize AttributeSubComponent121 due to ResourceLocation being null or empty!"); - + data.AddRange(DataTypes.GetString(ResourceLocation)); data.AddRange(DataTypes.GetDouble(Value)); data.AddRange(DataTypes.GetVarInt(Operation)); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_21/SoundEventSubComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_21/SoundEventSubComponent.cs index cb10dcee..2c2885c8 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_21/SoundEventSubComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/Subcomponents/1_21/SoundEventSubComponent.cs @@ -10,13 +10,13 @@ public class SoundEventSubComponent(DataTypes dataTypes, SubComponentRegistry su public string? SoundName { get; set; } public bool HasFixedRange { get; set; } public float FixedRange { get; set; } - + protected override void Parse(Queue data) { Type = DataTypes.ReadNextVarInt(data); if (Type != 0) return; - + SoundName = DataTypes.ReadNextString(data); HasFixedRange = DataTypes.ReadNextBool(data); @@ -30,14 +30,14 @@ public class SoundEventSubComponent(DataTypes dataTypes, SubComponentRegistry su data.AddRange(DataTypes.GetVarInt(Type)); if (Type != 0) return new Queue(data); - + if (string.IsNullOrEmpty(SoundName?.Trim())) throw new ArgumentNullException($"Can not serialize SoundEventSubComponent due to SoundName being null or empty!"); - + data.AddRange(DataTypes.GetString(SoundName)); data.AddRange(DataTypes.GetBool(HasFixedRange)); - - if(HasFixedRange) + + if (HasFixedRange) data.AddRange(DataTypes.GetFloat(FixedRange)); return new Queue(data); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/StructuredComponentRegistry.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/StructuredComponentRegistry.cs index 3ae07057..9ff1f12c 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/StructuredComponentRegistry.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/StructuredComponentRegistry.cs @@ -33,7 +33,7 @@ public abstract class StructuredComponentRegistry(DataTypes dataTypes, ItemPalet if (ComponentParsers.TryGetValue(name, out var type)) { var component = - Activator.CreateInstance(type, dataTypes, itemPalette, subComponentRegistry) as StructuredComponent + Activator.CreateInstance(type, dataTypes, itemPalette, subComponentRegistry) as StructuredComponent ?? throw new InvalidOperationException($"Could not instantiate a parser for a structured component type {name}"); component.TypeId = id; diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/SubComponentRegistry.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/SubComponentRegistry.cs index 4a991fd7..0da8120b 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/SubComponentRegistry.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/SubComponentRegistry.cs @@ -10,7 +10,7 @@ public abstract class SubComponentRegistry(DataTypes dataTypes) protected void RegisterSubComponent(string name) where T : SubComponent { - if(_subComponentParsers.TryGetValue(name, out _)) + if (_subComponentParsers.TryGetValue(name, out _)) throw new Exception($"Sub component {name} already registered!"); _subComponentParsers.Add(name, typeof(T)); @@ -23,17 +23,17 @@ public abstract class SubComponentRegistry(DataTypes dataTypes) public SubComponent ParseSubComponent(string name, Queue data) { - if(!_subComponentParsers.TryGetValue(name, out var subComponentParserType)) + if (!_subComponentParsers.TryGetValue(name, out var subComponentParserType)) throw new Exception($"Sub component {name} not registered!"); - var instance= Activator.CreateInstance(subComponentParserType, dataTypes, this) as SubComponent ?? + var instance = Activator.CreateInstance(subComponentParserType, dataTypes, this) as SubComponent ?? throw new InvalidOperationException($"Could not create instance of a sub component parser type: {subComponentParserType.Name}"); - + var parseMethod = instance.GetType().GetMethod("Parse", BindingFlags.Instance | BindingFlags.NonPublic); - + if (parseMethod is null) throw new InvalidOperationException($"Sub component parser type {subComponentParserType.Name} does not have a Parse method."); - + parseMethod.Invoke(instance, new object[] { data }); return instance; } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry1206.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry1206.cs index 2e0a9eb4..18ae967c 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry1206.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry1206.cs @@ -6,7 +6,7 @@ namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Registries; public class StructuredComponentsRegistry1206 : StructuredComponentRegistry { - public StructuredComponentsRegistry1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + public StructuredComponentsRegistry1206(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : base(dataTypes, itemPalette, subComponentRegistry) { RegisterComponent(0, "minecraft:custom_data"); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry121.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry121.cs index 922c1d90..7a2376f3 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry121.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Registries/StructuredComponentsRegistry121.cs @@ -7,7 +7,7 @@ namespace MinecraftClient.Protocol.Handlers.StructuredComponents.Registries; public class StructuredComponentsRegistry121 : StructuredComponentRegistry { - public StructuredComponentsRegistry121(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) + public StructuredComponentsRegistry121(DataTypes dataTypes, ItemPalette itemPalette, SubComponentRegistry subComponentRegistry) : base(dataTypes, itemPalette, subComponentRegistry) { RegisterComponent(0, "minecraft:custom_data"); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/StructuredComponentsHandler.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/StructuredComponentsHandler.cs index bd148ab3..48f0747a 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/StructuredComponentsHandler.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/StructuredComponentsHandler.cs @@ -10,7 +10,7 @@ namespace MinecraftClient.Protocol.Handlers.StructuredComponents; public class StructuredComponentsHandler { private StructuredComponentRegistry ComponentRegistry { get; } - + public StructuredComponentsHandler( int protocolVersion, DataTypes dataTypes, @@ -25,9 +25,9 @@ public class StructuredComponentsHandler _ => throw new NotSupportedException($"Protocol version {protocolVersion} is not supported for subcomponent registries!") }; - var subcomponentRegistry = Activator.CreateInstance(subcomponentRegistryType, dataTypes) as SubComponentRegistry + var subcomponentRegistry = Activator.CreateInstance(subcomponentRegistryType, dataTypes) as SubComponentRegistry ?? throw new InvalidOperationException($"Failed to instantiate a component registry for type {nameof(subcomponentRegistryType)}"); - + // Get the appropriate component registry type based on the protocol version and then instantiate it var registryType = protocolVersion switch { @@ -40,7 +40,7 @@ public class StructuredComponentsHandler _ => throw new NotSupportedException($"Protocol version {protocolVersion} is not supported for structured component registries!") }; - ComponentRegistry = Activator.CreateInstance(registryType, dataTypes, itemPalette, subcomponentRegistry) as StructuredComponentRegistry + ComponentRegistry = Activator.CreateInstance(registryType, dataTypes, itemPalette, subcomponentRegistry) as StructuredComponentRegistry ?? throw new InvalidOperationException($"Failed to instantiate a component registry for type {nameof(registryType)}"); } diff --git a/MinecraftClient/Protocol/IMinecraftCom.cs b/MinecraftClient/Protocol/IMinecraftCom.cs index df0a37fe..d8f87a2a 100644 --- a/MinecraftClient/Protocol/IMinecraftCom.cs +++ b/MinecraftClient/Protocol/IMinecraftCom.cs @@ -282,7 +282,7 @@ namespace MinecraftClient.Protocol /// /// bool SendPlayerSession(PlayerKeyPair? playerKeyPair); - + /// /// Send the server a command to type in the item name in the Anvil inventory when it's open. /// @@ -301,7 +301,7 @@ namespace MinecraftClient.Protocol /// The cookie identifier/name /// The cookie data byte array bool SendCookieResponse(string name, byte[]? data); - + /// /// Send the server known data packs /// diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index be406ef8..ec3881eb 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -49,7 +49,7 @@ namespace MinecraftClient.Protocol void DeleteCookie(string key); void Transfer(string newHost, int newPort); - + /// /// Invoke a task on the main thread, wait for completion and retrieve return value. /// @@ -518,7 +518,7 @@ namespace MinecraftClient.Protocol /// Header /// Footer void OnTabListHeaderAndFooter(string header, string footer); - + /// /// Called when tradeList is received from server /// @@ -604,7 +604,7 @@ namespace MinecraftClient.Protocol /// True if packet was successfully sent bool ClickContainerButton(int windowId, int buttonId); - + /// /// Send a rename item packet when the anvil inventory is open and there is an item in the first slot /// diff --git a/MinecraftClient/Protocol/Message/ChatParser.cs b/MinecraftClient/Protocol/Message/ChatParser.cs index e6da1e08..02819d4d 100644 --- a/MinecraftClient/Protocol/Message/ChatParser.cs +++ b/MinecraftClient/Protocol/Message/ChatParser.cs @@ -62,14 +62,17 @@ namespace MinecraftClient.Protocol.Message public static void ReadChatType(Dictionary registryCodec) { Dictionary chatTypeDictionary = ChatId2Type ?? new(); - + // Check if the chat type registry is in the correct format - if (!registryCodec.ContainsKey("minecraft:chat_type")) { - + if (!registryCodec.ContainsKey("minecraft:chat_type")) + { + // If not, then we force the registry to be in the correct format - if (registryCodec.ContainsKey("chat_type")) { - - foreach (var key in registryCodec.Keys.ToArray()) { + if (registryCodec.ContainsKey("chat_type")) + { + + foreach (var key in registryCodec.Keys.ToArray()) + { // Skip entries with a namespace already if (key.Contains(':', StringComparison.OrdinalIgnoreCase)) continue; @@ -79,12 +82,12 @@ namespace MinecraftClient.Protocol.Message } } } - + var chatTypeListNbt = (object[])(((Dictionary)registryCodec["minecraft:chat_type"])["value"]); foreach (var (chatName, chatId) in from Dictionary chatTypeNbt in chatTypeListNbt - let chatName = (string)chatTypeNbt["name"] - let chatId = (int)chatTypeNbt["id"] - select (chatName, chatId)) + let chatName = (string)chatTypeNbt["name"] + let chatId = (int)chatTypeNbt["id"] + select (chatName, chatId)) { chatTypeDictionary[chatId] = chatName switch { diff --git a/MinecraftClient/Protocol/Session/SessionToken.cs b/MinecraftClient/Protocol/Session/SessionToken.cs index 1364012b..a5d9f35c 100644 --- a/MinecraftClient/Protocol/Session/SessionToken.cs +++ b/MinecraftClient/Protocol/Session/SessionToken.cs @@ -28,7 +28,7 @@ namespace MinecraftClient.Protocol.Session public string ServerIDhash { get; set; } [Key(6)] public byte[]? ServerPublicKey { get; set; } - + [IgnoreMember] public Task? SessionPreCheckTask = null; diff --git a/MinecraftClient/Scripting/CSharpRunner.cs b/MinecraftClient/Scripting/CSharpRunner.cs index eebd61ec..158b6eae 100644 --- a/MinecraftClient/Scripting/CSharpRunner.cs +++ b/MinecraftClient/Scripting/CSharpRunner.cs @@ -120,7 +120,7 @@ namespace MinecraftClient.Scripting var loc = failure.Location.GetMappedLineSpan(); var line = code.Split('\n')[loc.StartLinePosition.Line]; - + ConsoleIO.WriteLogLine($"[Script] Error in {scriptName}, on line ({line.Trim()}): [{failure.Id}] {failure.GetMessage()}"); } diff --git a/MinecraftClient/Scripting/ChatBot.cs b/MinecraftClient/Scripting/ChatBot.cs index 83824281..3206092a 100644 --- a/MinecraftClient/Scripting/ChatBot.cs +++ b/MinecraftClient/Scripting/ChatBot.cs @@ -226,7 +226,8 @@ namespace MinecraftClient.Scripting /// Sound pitch /// Source entity for entity-sound packets when tracked public virtual void OnSoundEffect(string? soundName, Location? location, int category, float volume, float pitch, - Entity? sourceEntity) { } + Entity? sourceEntity) + { } /// /// Called when an entity rotates @@ -405,7 +406,8 @@ namespace MinecraftClient.Scripting /// Player/entity names. Present when method is 0, 3, or 4. public virtual void OnTeam(string teamName, byte method, string displayName, byte friendlyFlags, string nameTagVisibility, string collisionRule, int color, - string prefix, string suffix, List players) { } + string prefix, string suffix, List players) + { } /// /// Called when the client received the Tab Header and Footer @@ -413,7 +415,7 @@ namespace MinecraftClient.Scripting /// Header /// Footer public virtual void OnTabListHeaderAndFooter(string header, string footer) { } - + /// /// Called when an inventory/container was updated by server /// @@ -1068,7 +1070,7 @@ namespace MinecraftClient.Scripting { Handler.BotLoad(chatBot); } - + /// /// Set an App Variable /// @@ -1079,7 +1081,7 @@ namespace MinecraftClient.Scripting { Config.AppVar.SetVar(name, value); } - + /// /// Get a value from an App Variable /// @@ -1089,7 +1091,7 @@ namespace MinecraftClient.Scripting { return Config.AppVar.GetVar(name); } - + /// /// Replaces variables in text with their values from the App Var registry /// diff --git a/MinecraftClient/Scripting/DynamicRun/Builder/Compiler.cs b/MinecraftClient/Scripting/DynamicRun/Builder/Compiler.cs index c7524acd..163f6038 100644 --- a/MinecraftClient/Scripting/DynamicRun/Builder/Compiler.cs +++ b/MinecraftClient/Scripting/DynamicRun/Builder/Compiler.cs @@ -78,7 +78,7 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder var MinecraftClientDll = typeof(Program).Assembly.Location; // The path to MinecraftClient.dll // We're on a self-contained binary, so we need to extract the executable to get the assemblies. - if (string.IsNullOrEmpty(MinecraftClientDll)) + if (string.IsNullOrEmpty(MinecraftClientDll)) { // Create a temporary file to copy the executable to. var executablePath = Environment.ProcessPath; @@ -86,29 +86,29 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder throw new InvalidOperationException("Cannot determine the process path for self-contained scripting extraction."); var tempPath = Path.Combine(Path.GetTempPath(), "mcc-scripting"); Directory.CreateDirectory(tempPath); - + var tempFile = Path.Combine(tempPath, "mcc-executable"); var useExisting = false; // Check if we already have the executable in the temporary path. - foreach (var file in Directory.EnumerateFiles(tempPath)) + foreach (var file in Directory.EnumerateFiles(tempPath)) { - if (file.EndsWith("mcc-executable")) + if (file.EndsWith("mcc-executable")) { // Check if the file is the same as the current executable. - if (File.ReadAllBytes(file).SequenceEqual(File.ReadAllBytes(executablePath))) + if (File.ReadAllBytes(file).SequenceEqual(File.ReadAllBytes(executablePath))) { useExisting = true; break; } - + // If not, refresh the cache. File.Delete(file); break; } } - - if (!File.Exists(executablePath)) + + if (!File.Exists(executablePath)) { throw new FileNotFoundException("[Script Error] Could not locate the current folder of MCC for scripting."); } @@ -141,7 +141,8 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder assemblyrefs.Add(new("Microsoft.Win32.Primitives")); assemblyrefs.Add(new("System.Collections.Concurrent")); - foreach (var refs in assemblyrefs) { + foreach (var refs in assemblyrefs) + { Assembly? loadedAssembly; try { @@ -153,19 +154,22 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder continue; } - if (string.IsNullOrEmpty(loadedAssembly.Location)) { + if (string.IsNullOrEmpty(loadedAssembly.Location)) + { // Check if we can access the file from the executable. var reference = files.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x.RelativePath) == refs.Name); var refCount = files.Count(x => Path.GetFileNameWithoutExtension(x.RelativePath) == refs.Name); - if (refCount > 1) { + if (refCount > 1) + { // Safety net for the case where the assembly is referenced multiple times. // Should not happen normally, but we can make exceptions when it does happen. throw new InvalidOperationException( "[Script Error] Too many references to the same assembly. Assembly name: " + refs.Name); } - if (reference is null) { + if (reference is null) + { // Facade assemblies may not be in the bundle - skip them silently continue; } diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index f1f9453e..ce7beada 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -758,9 +758,9 @@ namespace MinecraftClient [TomlInlineComment("$Main.General.AuthlibUser$")] public string AuthUser = ""; - - public enum LoginType { mojang, microsoft,yggdrasil }; + + public enum LoginType { mojang, microsoft, yggdrasil }; public enum LoginMethod { mcc, browser }; } @@ -770,7 +770,7 @@ namespace MinecraftClient { [TomlInlineComment("$Main.Advanced.enable_sentry$")] public bool EnableSentry = true; - + [TomlInlineComment("$Main.Advanced.language$")] public string Language = "en_us"; @@ -1515,7 +1515,7 @@ namespace MinecraftClient string varname = var_name.ToString(); string varname_lower = Settings.ToLowerIfNeed(varname); i = i + varname.Length + 1; - + if (TryGetReadOnlyVar(varname_lower, out object? readOnlyVar)) { result.Append(readOnlyVar.ToString()); diff --git a/MinecraftClient/Tui/ServerStatusPanelBuilder.cs b/MinecraftClient/Tui/ServerStatusPanelBuilder.cs index 2c8daf6f..bff8fe7c 100644 --- a/MinecraftClient/Tui/ServerStatusPanelBuilder.cs +++ b/MinecraftClient/Tui/ServerStatusPanelBuilder.cs @@ -91,7 +91,7 @@ namespace MinecraftClient.Tui row.Inlines.Add(Value(versionClean, McColors.Aqua)); row.Inlines.Add(new Run(" (") { Foreground = McColors.Gray }); row.Inlines.Add(new Run(string.Format(Translations.mcc_server_info_label_protocol, info.ProtocolVersion)) - { Foreground = McColors.Gray }); + { Foreground = McColors.Gray }); row.Inlines.Add(new Run(")") { Foreground = McColors.Gray }); panel.Children.Add(row); } @@ -107,7 +107,7 @@ namespace MinecraftClient.Tui row.Inlines.Add(Value(resolvedMcVer, McColors.Green)); row.Inlines.Add(new Run(" (") { Foreground = McColors.Gray }); row.Inlines.Add(new Run(string.Format(Translations.mcc_server_info_label_protocol, info.ResolvedProtocol)) - { Foreground = McColors.Gray }); + { Foreground = McColors.Gray }); row.Inlines.Add(new Run(")") { Foreground = McColors.Gray }); panel.Children.Add(row); } @@ -126,7 +126,7 @@ namespace MinecraftClient.Tui var row = new TextBlock(); row.Inlines!.Add(Label(Translations.mcc_server_info_label_ping)); row.Inlines.Add(new Run(string.Format(Translations.mcc_server_info_label_ping_ms, info.PingMs)) - { Foreground = pingColor }); + { Foreground = pingColor }); panel.Children.Add(row); } diff --git a/MinecraftClient/Tui/TuiConsoleBackend.cs b/MinecraftClient/Tui/TuiConsoleBackend.cs index 523b27f1..9579cd23 100644 --- a/MinecraftClient/Tui/TuiConsoleBackend.cs +++ b/MinecraftClient/Tui/TuiConsoleBackend.cs @@ -277,7 +277,8 @@ namespace MinecraftClient.Tui { Thread.Sleep(1000); Environment.Exit(0); - }) { Name = "TUI-Exit-Guard", IsBackground = true }.Start(); + }) + { Name = "TUI-Exit-Guard", IsBackground = true }.Start(); } private volatile bool _shutdownRequested;