From a4ff7ae43806af0ce2415da7930debb522d8c612 Mon Sep 17 00:00:00 2001 From: Anon Date: Thu, 4 Jun 2026 11:20:24 +0200 Subject: [PATCH 1/9] feat(AutoAttack): implement random cooldown range for attack timing --- MinecraftClient/ChatBots/AutoAttack.cs | 71 +++++++++++++++----------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/MinecraftClient/ChatBots/AutoAttack.cs b/MinecraftClient/ChatBots/AutoAttack.cs index 8395eed8..fe5ec292 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) { @@ -172,22 +180,27 @@ namespace MinecraftClient.ChatBots if (entitiesToAttack.ContainsKey(priorityEntity)) { // check entity distance and health again - if (ShouldAttackEntity(entitiesToAttack[priorityEntity])) - { - InteractEntity(priorityEntity, Config.Interaction); // hit the entity! - SendAnimation(Inventory.Hand.MainHand); // Arm animation - } + if (ShouldAttackEntity(entitiesToAttack[priorityEntity])) + { + LogToConsole($"[{DateTime.Now:HH:mm:ss.fff}] Attacking entity {priorityEntity}"); + InteractEntity(priorityEntity, Config.Interaction); // hit the entity! + SendAnimation(Inventory.Hand.MainHand); // Arm animation + } + + } } else { foreach (KeyValuePair entity in entitiesToAttack) { - // check that we are in range once again. - if (ShouldAttackEntity(entity.Value)) - { - InteractEntity(entity.Key, Config.Interaction); // hit the entity! - } + // check that we are in range once again. + if (ShouldAttackEntity(entity.Value)) + { + LogToConsole($"[{DateTime.Now:HH:mm:ss.fff}] Attacking entity {entity.Key}"); + InteractEntity(entity.Key, Config.Interaction); // hit the entity! + } + } SendAnimation(Inventory.Hand.MainHand); // Arm animation } From c6ca3dc13d942ca8e908bbfed36b639cb98ef654 Mon Sep 17 00:00:00 2001 From: Anon Date: Thu, 4 Jun 2026 11:42:41 +0200 Subject: [PATCH 2/9] Formatted the code and removed logs from Auto Attack --- MinecraftClient/ChatBots/AntiAFK.cs | 2 +- MinecraftClient/ChatBots/AutoAttack.cs | 22 ++-- MinecraftClient/ChatBots/Script.cs | 12 +- MinecraftClient/ChatBots/TelegramBridge.cs | 2 +- MinecraftClient/Commands/Entitycmd.cs | 2 +- MinecraftClient/Inventory/Item.cs | 6 +- .../Inventory/ItemPalettes/ItemPalette.cs | 2 +- .../EntityMetadataPalette1122.cs | 2 +- .../EntityMetadataPalette1191.cs | 2 +- .../EntityMetadataPalette1193.cs | 2 +- .../EntityMetadataPalette1194.cs | 2 +- .../EntityMetadataPalette18.cs | 2 +- .../Mapping/EntityTypeExtensions.cs | 3 +- MinecraftClient/Mapping/World.cs | 46 +++---- MinecraftClient/McClient.cs | 40 +++--- MinecraftClient/Mcp/MccMcpCapabilities.cs | 46 +++---- .../Handlers/ConfigurationPacketTypesIn.cs | 2 +- .../Handlers/ConfigurationPacketTypesOut.cs | 2 +- .../Protocol/Handlers/DataTypes.cs | 78 ++++++------ .../Protocol/Handlers/Forge/ForgeInfo.cs | 19 +-- .../PacketPalettes/PacketPalette1202.cs | 4 +- .../PacketPalettes/PacketPalette1204.cs | 22 ++-- .../PacketPalettes/PacketPalette1206.cs | 22 ++-- .../PacketPalettes/PacketPalette121.cs | 22 ++-- .../PacketPalettes/PacketPalette1212.cs | 22 ++-- .../PacketPalettes/PacketPalette1214.cs | 22 ++-- .../PacketPalettes/PacketPalette1215.cs | 22 ++-- .../PacketPalettes/PacketPalette1216.cs | 22 ++-- .../PacketPalettes/PacketPalette1219.cs | 22 ++-- .../PacketPalettes/PacketPalette17.cs | 2 +- .../PacketPalettes/PacketPalette261.cs | 22 ++-- .../Protocol/Handlers/Protocol16.cs | 2 +- .../Protocol/Handlers/Protocol18.cs | 116 +++++++++--------- .../Protocol/Handlers/Protocol18Forge.cs | 8 +- .../1_20_6/AttributeModifiersComponent.cs | 12 +- .../1_20_6/BannerPatternsComponent.cs | 12 +- .../Components/1_20_6/BaseColorComponent.cs | 4 +- .../Components/1_20_6/BeesComponent.cs | 6 +- .../Components/1_20_6/BlockStateComponent.cs | 8 +- .../1_20_6/BundleContentsComponent.cs | 2 +- .../Components/1_20_6/CanBreakComponent.cs | 12 +- .../Components/1_20_6/CanPlaceOnComponent.cs | 12 +- .../1_20_6/ChargedProjectilesComponent.cs | 2 +- .../Components/1_20_6/ContainerComponent.cs | 6 +- .../1_20_6/ContainerLootComponent.cs | 4 +- .../1_20_6/CreativeSlotLockComponent.cs | 2 +- .../Components/1_20_6/CustomDataComponent.cs | 4 +- .../1_20_6/CustomModelDataComponent.cs | 2 +- .../Components/1_20_6/CustomNameComponent.cs | 4 +- .../Components/1_20_6/DamageComponent.cs | 4 +- .../1_20_6/DebugStickStateComponent.cs | 4 +- .../Components/1_20_6/DyeColorComponent.cs | 4 +- .../EnchantmentGlintOverrideComponent.cs | 2 +- .../1_20_6/EnchantmentsComponent.cs | 2 +- .../Components/1_20_6/EntityDataComponent.cs | 14 ++- .../1_20_6/FireResistantComponent.cs | 2 +- .../1_20_6/FireworkExplosionComponent.cs | 4 +- .../Components/1_20_6/FireworksComponent.cs | 10 +- .../1_20_6/FoodComponentComponent.cs | 12 +- .../1_20_6/HideAdditionalTooltipComponent.cs | 2 +- .../Components/1_20_6/HideTooltipComponent.cs | 2 +- .../Components/1_20_6/InstrumentComponent.cs | 4 +- .../1_20_6/IntangibleProjectileComponent.cs | 4 +- .../Components/1_20_6/ItemNameComponent.cs | 4 +- .../Components/1_20_6/LockComponent.cs | 4 +- .../1_20_6/LodestoneTrackerComponent.cs | 8 +- .../Components/1_20_6/LoreComponent.cs | 8 +- .../Components/1_20_6/MapColorComponent.cs | 4 +- .../1_20_6/MapDecorationsComponent.cs | 4 +- .../Components/1_20_6/MapIdComponent.cs | 4 +- .../1_20_6/MapPostProcessingComponent.cs | 4 +- .../Components/1_20_6/MaxDamageComponent.cs | 2 +- .../1_20_6/MaxStackSizeComponent.cs | 4 +- .../1_20_6/NoteBlockSoundComponent.cs | 4 +- .../1_20_6/OmniousBottleAmplifierComponent.cs | 4 +- .../1_20_6/PotDecorationsComponent.cs | 6 +- .../1_20_6/PotionContentsComponent.cs | 6 +- .../Components/1_20_6/ProfileComponent.cs | 2 +- .../Components/1_20_6/RarityComponent.cs | 4 +- .../Components/1_20_6/RecipesComponent.cs | 4 +- .../Components/1_20_6/RepairCostComponent.cs | 4 +- .../1_20_6/StoredEnchantmentsComponent.cs | 2 +- .../1_20_6/SuspiciousStewEffectsComponent.cs | 4 +- .../Components/1_20_6/ToolComponent.cs | 12 +- .../Components/1_20_6/TrimComponent.cs | 14 +-- .../Components/1_20_6/UnbreakableComponent.cs | 4 +- .../1_20_6/WritableBlookContentComponent.cs | 14 +-- .../1_20_6/WrittenBlookContentComponent.cs | 16 +-- .../1_21/JukeBoxPlayableComponent.cs | 16 +-- .../Components/1_21_2/EquippableComponent.cs | 2 +- .../26_1/TypedEntityDataComponent261.cs | 3 +- .../1_20_6/AttributeSubComponent.cs | 6 +- .../1_20_6/BlockPredicateSubcomponent.cs | 20 +-- .../1_20_6/BlockSetSubcomponent.cs | 16 +-- .../1_20_6/DetailsSubComponent.cs | 10 +- .../1_20_6/EffectSubComponent.cs | 2 +- .../1_20_6/FireworkExplosionSubComponent.cs | 10 +- .../1_20_6/PotionEffectSubComponent.cs | 2 +- .../1_20_6/PropertySubComponent.cs | 10 +- .../Subcomponents/1_20_6/RuleSubComponent.cs | 18 +-- .../1_21/AttributeSubComponent121.cs | 6 +- .../1_21/SoundEventSubComponent.cs | 12 +- .../Core/StructuredComponentRegistry.cs | 2 +- .../Core/SubComponentRegistry.cs | 12 +- .../StructuredComponentsRegistry1206.cs | 2 +- .../StructuredComponentsRegistry121.cs | 2 +- .../StructuredComponentsHandler.cs | 8 +- MinecraftClient/Protocol/IMinecraftCom.cs | 4 +- .../Protocol/IMinecraftComHandler.cs | 6 +- .../Protocol/Message/ChatParser.cs | 23 ++-- .../Protocol/Session/SessionToken.cs | 2 +- MinecraftClient/Scripting/CSharpRunner.cs | 2 +- MinecraftClient/Scripting/ChatBot.cs | 14 ++- .../Scripting/DynamicRun/Builder/Compiler.cs | 28 +++-- MinecraftClient/Settings.cs | 8 +- .../Tui/ServerStatusPanelBuilder.cs | 6 +- MinecraftClient/Tui/TuiConsoleBackend.cs | 3 +- 117 files changed, 602 insertions(+), 585 deletions(-) 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 fe5ec292..f851ca0a 100644 --- a/MinecraftClient/ChatBots/AutoAttack.cs +++ b/MinecraftClient/ChatBots/AutoAttack.cs @@ -180,12 +180,11 @@ namespace MinecraftClient.ChatBots if (entitiesToAttack.ContainsKey(priorityEntity)) { // check entity distance and health again - if (ShouldAttackEntity(entitiesToAttack[priorityEntity])) - { - LogToConsole($"[{DateTime.Now:HH:mm:ss.fff}] Attacking entity {priorityEntity}"); - InteractEntity(priorityEntity, Config.Interaction); // hit the entity! - SendAnimation(Inventory.Hand.MainHand); // Arm animation - } + if (ShouldAttackEntity(entitiesToAttack[priorityEntity])) + { + InteractEntity(priorityEntity, Config.Interaction); // hit the entity! + SendAnimation(Inventory.Hand.MainHand); // Arm animation + } } @@ -194,12 +193,11 @@ namespace MinecraftClient.ChatBots { foreach (KeyValuePair entity in entitiesToAttack) { - // check that we are in range once again. - if (ShouldAttackEntity(entity.Value)) - { - LogToConsole($"[{DateTime.Now:HH:mm:ss.fff}] Attacking entity {entity.Key}"); - InteractEntity(entity.Key, Config.Interaction); // hit the entity! - } + // check that we are in range once again. + if (ShouldAttackEntity(entity.Value)) + { + 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; From d835da76d246127b1ce0a3a4ed774e167f89ef96 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:06:25 +0000 Subject: [PATCH 3/9] Update AutoAttack bot Cooldown_Time documentation to reflect new Min/Max/RandomMode options --- docs/guide/chat-bots.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/guide/chat-bots.md b/docs/guide/chat-bots.md index ff12f19c..23658d54 100644 --- a/docs/guide/chat-bots.md +++ b/docs/guide/chat-bots.md @@ -354,19 +354,19 @@ redirectFrom: - **Description:** - How long to wait between each attack in seconds. + Controls the delay between attacks. By default, MCC calculates this based on server TPS. Set `Custom` to `true` to specify your own values: - To enable it, set `Custom` (boolean) to `true` and change `value` (double) to your preferred value (eg. `1.5`). + - `Min` — minimum cooldown in seconds + - `Max` — maximum cooldown in seconds + - `RandomMode` — if enabled, picks a random cooldown between `Min` and `Max` for each attack - By default, this is disabled and MCC calculates it based on the server TPS. - - - **Format:** `Cooldown_Time = { Custom = , value = }` + - **Format:** `Cooldown_Time = { Custom = , RandomMode = , Min = , Max = }` - **Type:** `inline table` - - **Example:** `Cooldown_Time = { Custom = true, value = 1.5 }` + - **Example:** `Cooldown_Time = { Custom = true, RandomMode = true, Min = 1.0, Max = 2.0 }` - - **Default:** `{ Custom = false, value = 1.0 }` + - **Default:** `{ Custom = false, RandomMode = false, Min = 1.5, Max = 2.5 }` #### `Interaction` From 546345e8165b642b9011620b4ff881fb02bd7c1e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 19:31:21 +0000 Subject: [PATCH 4/9] Update AutoAttack bot translation for Cooldown_Time --- MinecraftClient/Resources/ConfigComments/ConfigComments.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx index 75879f54..e92415a9 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx @@ -193,7 +193,7 @@ You need to enable Entity Handling to use this bot Capped between 1 to 4 - How long to wait between each attack. Set "Custom = false" to let MCC calculate it. + Delay between attacks. Set "Custom = false" to let MCC calculate it. When Custom = true, set Min/Max for the cooldown range. If RandomMode = true, a random value between Min and Max is used for each attack. All entity types can be found here: https://mccteam.github.io/r/entity/#L15 From 2b05b7420e72d14920fa746b3089bfca21b2aa7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 06:23:11 +0000 Subject: [PATCH 5/9] Initial plan From 8757533fb904804475a23ea6b60009796791d255 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 06:29:43 +0000 Subject: [PATCH 6/9] Fix Script bots accumulating on reconnect by unloading on disconnect Script ChatBots were persisted in the static botsOnHold list across reconnects. When ScriptScheduler triggered new scripts on login, the old Script bots were still running, causing duplicate commands to be sent simultaneously. This led to command spam and crashes. Adding OnDisconnect to the Script ChatBot ensures scripts are removed from the bots list before they can be saved to botsOnHold, preventing accumulation of duplicate script instances on reconnect. --- MinecraftClient/ChatBots/Script.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MinecraftClient/ChatBots/Script.cs b/MinecraftClient/ChatBots/Script.cs index bbfe729f..e2bb6636 100644 --- a/MinecraftClient/ChatBots/Script.cs +++ b/MinecraftClient/ChatBots/Script.cs @@ -149,6 +149,12 @@ namespace MinecraftClient.ChatBots } } + public override bool OnDisconnect(DisconnectReason reason, string message) + { + UnloadBot(); + return false; + } + public override void Update() { if (csharp) //C# compiled script From 5545aabb60dbb0a8d51bba06af1d726fef6f2a53 Mon Sep 17 00:00:00 2001 From: Anon Date: Fri, 5 Jun 2026 20:57:49 +0200 Subject: [PATCH 7/9] Add reusable inventory sweep tooling --- .skills/mcc-integration-testing/SKILL.md | 43 ++ .skills/mcc-version-adaptation/SKILL.md | 55 ++ tools/README.md | 26 + tools/run-inventory-full-sweep.sh | 673 +++++++++++++++++++++++ 4 files changed, 797 insertions(+) create mode 100755 tools/run-inventory-full-sweep.sh diff --git a/.skills/mcc-integration-testing/SKILL.md b/.skills/mcc-integration-testing/SKILL.md index 168b545f..6316e0b8 100644 --- a/.skills/mcc-integration-testing/SKILL.md +++ b/.skills/mcc-integration-testing/SKILL.md @@ -115,6 +115,43 @@ Use this for TPS, movement-cadence, or packet-cadence work: Run them against a real server with a temp config and summarize counts from the captured logs. +### 4. Full inventory regression sweep + +Use this when touching inventory snapshots, player/container slot sync, creative inventory, item-slot serialization, packet palettes, game-mode updates, or block-use paths that open containers: + +```bash +tools/run-inventory-full-sweep.sh --versions "1.21.10 1.21.11" +``` + +Default coverage includes: + +- player inventory listing and inventory discovery +- creative give/delete +- inventory search +- player right/left click stack split and merge +- player drop one and drop all +- chest open via `useblock` +- container listing and close +- mirrored player slots in container windows +- shift-click and shift-right-click transfer +- container right/left click, cursor stack, drop one, and drop all +- creative middle-click command path +- log scan for packet parse failures, queue-empty crashes, unhandled exceptions, and disconnects + +Run the Issue #3112 repro after a passing sweep: + +```bash +tools/run-inventory-full-sweep.sh --versions "1.20.4" --run-issue-script +``` + +The script writes `summary.tsv` under `RUN_ROOT` and per-version logs under `/tmp/mcc-debug/inventory-full-/mcc-debug.log`. + +When a matrix has existing PASS rows, do not rerun them unless a later code change affects that row or the user asks for a full rerun. Derive remaining rows from summaries: + +```bash +awk 'FNR>1 && $2=="PASS" {print $1}' /tmp/mcc-inventory-full-sweep/*/summary.tsv | sort -V | uniq +``` + ## Preconditions Before running any scenario: @@ -165,6 +202,8 @@ Optionally override the login name with the fourth argument to the config helper - summarize the latest full-spectrum run - `tools/run-creative-e2e.sh` - ordered creative-mode E2E regression scenario +- `tools/run-inventory-full-sweep.sh` + - full inventory command/API sweep across one or more versions, with optional Issue #3112 MCCScript repro ## Evidence Discipline @@ -224,3 +263,7 @@ Always summarize: - If a test assertion fails, inspect the real MCC output before changing the code or weakening the assertion. - If an older server behaves oddly on Linux, check `use-native-transport=false` in `server.properties`. - If a matrix row fails before producing `mcc.log` or a command transcript, treat it as a harness failure, fix the environment, and rerun that row before drawing product conclusions. +- If creative inventory commands report "You must be in Creative gamemode" after RCON switched the player, inspect game-mode update parsing before assuming creative inventory is broken. Modern servers can update local game mode through game event reason `3`. +- If an inventory row crashes with `Queue empty` or `Failed to process incoming packet`, inspect packet palette routing before changing inventory code. A single shifted packet ID can make a healthy inventory feature look broken. +- For chest-open failures, separate product and harness causes. The player may be standing inside the chest or suffocating on older servers. Stand beside the chest, put a floor under the player, and retry `useblock`. +- For shared local servers, a `Done` log line does not prove RCON is ready. Retry setup commands and verify the actual RCON port from `server.properties`. diff --git a/.skills/mcc-version-adaptation/SKILL.md b/.skills/mcc-version-adaptation/SKILL.md index 706399cb..c3be7c12 100644 --- a/.skills/mcc-version-adaptation/SKILL.md +++ b/.skills/mcc-version-adaptation/SKILL.md @@ -157,6 +157,50 @@ When packet changes are detected: 2. Create new `PacketPaletteXXX.cs` based on the previous one, adjusting IDs 3. Update `PacketType18Handler.cs` routing +Use scriptable comparisons instead of eyeballing long packet tables. The packet ID is the registration index in `GameProtocols.java`: + +```bash +python3 - <<'PY' +import re +for ver in ["1.21.10", "1.21.11", "26.1"]: + path=f"MinecraftOfficial/{ver}-decompiled/net/minecraft/network/protocol/game/GameProtocols.java" + text=open(path).read() + start=text.index("CLIENTBOUND_TEMPLATE") + names=[m.group(1) for m in re.finditer(r"\.addPacket\(([^,]+),", text[start:])] + print("==", ver, len(names)) + for i, name in enumerate(names): + print(f"0x{i:02X}", name) +PY +``` + +For focused diffs: + +```bash +python3 - <<'PY' +import re +def packets(ver, marker): + text=open(f"MinecraftOfficial/{ver}-decompiled/net/minecraft/network/protocol/game/GameProtocols.java").read() + start=text.index(marker) + return [m.group(1) for m in re.finditer(r"\.addPacket\(([^,]+),", text[start:])] +left, right = "1.21.10", "1.21.11" +a, b = packets(left, "CLIENTBOUND_TEMPLATE"), packets(right, "CLIENTBOUND_TEMPLATE") +for i in range(max(len(a), len(b))): + x = a[i] if i < len(a) else "" + y = b[i] if i < len(b) else "" + if x != y: + print(f"0x{i:02X}: {left}={x} | {right}={y}") +PY +``` + +Do the same for `SERVERBOUND_TEMPLATE`. Clientbound and serverbound can change independently. Do not inherit a newer palette just because one side looks similar. For example, `1.21.11` used the same play packet order as `1.21.9/1.21.10` for the tested inventory path, while `26.1` had additional shifts. + +Known packet lessons: + +- `1.9`, `1.9.1`, and `1.9.2` need their own packet palette. They are not safe to route through the later 1.9.x palette. +- Pure `1.19` serverbound IDs differ from later 1.19.x. Do not put `MessageAcknowledgment` at `0x03`; pure 1.19 has `ChatCommand` at `0x03`, `ChatMessage` at `0x04`, and `ChatPreview` at `0x05`. +- A wrong packet palette often appears as unrelated inventory failure: creative give/delete disconnects, `Queue empty`, or `Failed to process incoming packet`. +- Game event reason `3` is `CHANGE_GAME_MODE`. If RCON changed the player to creative but MCC still refuses creative inventory commands, inspect `ChangeGameState` handling. + ## Step 5: Check Variant Encoding Changes For entity types that use variant serializers (Cat, Wolf, Frog, Painting), check if the codec changed between versions by inspecting: @@ -186,6 +230,17 @@ Compare key packet codec classes between versions. Known changes: When in doubt, compare the relevant packet class (e.g. `ClientboundAddEntityPacket.java`) between versions. +## Step 7.1: Check JoinGame and Respawn Formats + +JoinGame and Respawn are high-risk because dimension fields changed several times: + +- `1.16` and `1.16.1`: dimension type/name handling uses string identifiers in places where later versions do not. +- `1.16.2` through `1.18.2`: dimension type can be an NBT compound in JoinGame/Respawn. +- `1.19+`: dimension type commonly moves back to identifiers. +- `1.20.6+`: registry-driven IDs appear in more fields. + +When a version joins but terrain, inventory, or later packets look misaligned, inspect JoinGame/Respawn first. A single wrong dimension-field read leaves unread bytes in the packet and can make the next packet look broken. + ## Step 8: Update Block Collision Shapes (Physics Engine) MCC's physics engine uses block collision shape data from PrismarineJS `minecraft-data` to perform accurate AABB collision detection (stored in `MinecraftClient/Physics/BlockShapeData.json`, embedded as a resource). diff --git a/tools/README.md b/tools/README.md index be83c64d..87a65480 100644 --- a/tools/README.md +++ b/tools/README.md @@ -26,6 +26,32 @@ mcc-publish --rid linux-x64 Keep shared servers running by default. Do not stop or reset them unless the user explicitly asks for that, or you need to switch server versions. +### Full inventory regression sweep + +Use `tools/run-inventory-full-sweep.sh` when changing inventory, container, item-slot serialization, packet palettes, game-mode handling, or block-use behavior. It runs MCC against real local servers with temporary configs and checks player inventory, creative give/delete, search, click, drop, chest container, mirrored player slots, and crash markers. + +```bash +# Focused retest +tools/run-inventory-full-sweep.sh --versions "1.21.10 1.21.11" + +# Full default major-version sweep +tools/run-inventory-full-sweep.sh + +# Run the Issue #3112 mirrored-player-inventory script after a passing sweep +tools/run-inventory-full-sweep.sh --versions "1.20.4" --run-issue-script +``` + +Useful environment overrides: + +```bash +RUN_ROOT=/tmp/my-inventory-run \ +MCC_SERVERS=/path/to/servers \ +STOP_ON_FAIL=1 \ +tools/run-inventory-full-sweep.sh --versions "1.19 1.20.4" +``` + +The script writes `summary.tsv` under `RUN_ROOT`. Per-version MCC logs are under `/tmp/mcc-debug/inventory-full-/mcc-debug.log`, and command output blocks are saved next to the summary. + ### tmpfs build mode ```bash diff --git a/tools/run-inventory-full-sweep.sh b/tools/run-inventory-full-sweep.sh new file mode 100755 index 00000000..ea98846e --- /dev/null +++ b/tools/run-inventory-full-sweep.sh @@ -0,0 +1,673 @@ +#!/usr/bin/env bash +set -u -o pipefail + +SCRIPT_SELF="${BASH_SOURCE[0]}" +while [[ -L "$SCRIPT_SELF" ]]; do + SCRIPT_DIRNAME="$(cd -P "$(dirname "$SCRIPT_SELF")" >/dev/null 2>&1 && pwd)" + SCRIPT_SELF="$(readlink "$SCRIPT_SELF")" + [[ "$SCRIPT_SELF" != /* ]] && SCRIPT_SELF="$SCRIPT_DIRNAME/$SCRIPT_SELF" +done +REPO_ROOT="$(cd -P "$(dirname "$SCRIPT_SELF")/.." >/dev/null 2>&1 && pwd)" +SCRIPT_DIR="$REPO_ROOT/.skills/mcc-integration-testing/scripts" +RUN_ROOT="${RUN_ROOT:-/tmp/mcc-inventory-full-sweep/$(date +%Y%m%d-%H%M%S)}" +VERSIONS="${VERSIONS_OVERRIDE:-1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 26.1}" +RUN_ISSUE_SCRIPT="${RUN_ISSUE_SCRIPT:-0}" +ISSUE_VERSION="${ISSUE_VERSION:-1.20.4}" +STOP_ON_FAIL="${STOP_ON_FAIL:-1}" + +usage() { + cat <<'USAGE' +Usage: tools/run-inventory-full-sweep.sh [options] + +Runs MCC inventory command/API coverage against real local Minecraft servers. +The matrix is sequential because mc-* tmux sessions are shared state. + +Options: + --versions "1.20.4 1.21.11" Space-separated versions to test. + --run-issue-script Run the Issue #3112 MCCScript repro after a passing sweep. + --issue-version VERSION Version for the Issue #3112 repro. Default: 1.20.4. + --keep-going Continue after failures. + --stop-on-fail Stop on first failure. Default. + -h, --help Show this help. + +Environment overrides: + VERSIONS_OVERRIDE, RUN_ROOT, RUN_ISSUE_SCRIPT, ISSUE_VERSION, STOP_ON_FAIL, + MCC_SERVERS. + +Examples: + tools/run-inventory-full-sweep.sh --versions "1.21.10 1.21.11" + RUN_ISSUE_SCRIPT=1 tools/run-inventory-full-sweep.sh --versions "1.20.4" +USAGE +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --versions) + VERSIONS="$2" + shift 2 + ;; + --run-issue-script) + RUN_ISSUE_SCRIPT=1 + shift + ;; + --issue-version) + ISSUE_VERSION="$2" + shift 2 + ;; + --keep-going) + STOP_ON_FAIL=0 + shift + ;; + --stop-on-fail) + STOP_ON_FAIL=1 + shift + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "Unknown option: $1" >&2 + usage >&2 + exit 2 + ;; + esac +done + +source "$REPO_ROOT/tools/mcc-env.sh" +source "$SCRIPT_DIR/common.sh" + +mkdir -p "$RUN_ROOT" +SUMMARY="$RUN_ROOT/summary.tsv" +printf 'target\tstatus\tdetail\tlog\n' > "$SUMMARY" + +wait_for_file_pattern_local() { + local file="$1" + local pattern="$2" + local timeout="${3:-10}" + local end=$((SECONDS + timeout)) + while (( SECONDS < end )); do + if [[ -f "$file" ]] && grep -Eq "$pattern" "$file"; then + return 0 + fi + sleep 0.2 + done + return 1 +} + +sanitize_version() { + printf '%s' "$1" | tr '.-' '__' +} + +server_target_for() { + local version="$1" + local dir + if [[ -d "${MCC_SERVERS:-}/$version-Vanilla" ]]; then + printf '%s-Vanilla' "$version" + elif [[ -d "$REPO_ROOT/MinecraftOfficial/downloads/$version" ]]; then + printf '%s' "$version" + else + printf '%s-Vanilla' "$version" + fi +} + +server_dir_for() { + local target="$1" + local root="${MCC_SERVERS:-$REPO_ROOT/MinecraftOfficial/downloads}" + printf '%s/%s\n' "$root" "$target" +} + +rcon_port_for() { + local target="$1" + local props + props="$(server_dir_for "$target")/server.properties" + if [[ -f "$props" ]]; then + local port_line + port_line="$(grep -E '^rcon\.port=' "$props" | tail -n 1 || true)" + if [[ -n "$port_line" ]]; then + printf '%s\n' "${port_line#rcon.port=}" + return 0 + fi + fi + printf '25575\n' +} + +run_rcon() { + local port="$1" + local command="$2" + local attempt + for attempt in 1 2 3 4 5; do + if mc-rcon "$command" "$port" >/dev/null 2>&1; then + return 0 + fi + sleep 1 + done + return 1 +} + +run_rcon_or_detail() { + local port="$1" + local cmd="$2" + if run_rcon "$port" "$cmd"; then + return 0 + fi + FAIL_DETAIL="rcon failed: $cmd" + return 1 +} + +run_rcon_any_or_detail() { + local port="$1" + local detail="$2" + shift 2 + local cmd + for cmd in "$@"; do + if run_rcon "$port" "$cmd"; then + return 0 + fi + done + FAIL_DETAIL="$detail" + return 1 +} + +run_rcon_any() { + local port="$1" + shift + local cmd + for cmd in "$@"; do + if run_rcon "$port" "$cmd"; then + return 0 + fi + done + return 1 +} + +run_rcon_each() { + local port="$1" + shift + local cmd + for cmd in "$@"; do + run_rcon "$port" "$cmd" || true + done +} + +send_mcc_command() { + local session="$1" + local log_file="$2" + local command="$3" + local delay="${4:-1}" + local block_file="$5" + local mark + mark="$(wc -c < "$log_file" 2>/dev/null || printf '0')" + mcc-cmd --session "$session" "$command" >/dev/null + sleep "$delay" + LAST_BLOCK="$(tail -c "+$((mark + 1))" "$log_file" 2>/dev/null || true)" + { + printf '\n>>> %s\n' "$command" + printf '%s\n' "$LAST_BLOCK" + } >> "$block_file" +} + +assert_contains() { + grep -Eq "$2" <<<"$1" || { FAIL_DETAIL="$3"; return 1; } +} + +assert_not_contains() { + if grep -Eq "$2" <<<"$1"; then + FAIL_DETAIL="$3" + return 1 + fi +} + +assert_no_runtime_crash() { + local log_file="$1" + if grep -Eq 'Queue empty|Unhandled exception|Object reference not set|Failed to parse packet|Failed to process incoming packet|Connection has been lost' "$log_file"; then + FAIL_DETAIL="runtime log contains crash/disconnect marker" + return 1 + fi +} + +clear_dropped_items() { + local port="$1" + run_rcon_any "$port" "kill @e[type=item]" "kill @e[type=Item]" >/dev/null 2>&1 || true +} + +open_chest() { + local session="$1" + local log_file="$2" + local block_file="$3" + send_mcc_command "$session" "$log_file" "useblock 1 80 0" 2 "$block_file" + if wait_for_file_pattern_local "$log_file" "Inventory # 1 opened: Chest" 4; then + return 0 + fi + send_mcc_command "$session" "$log_file" "useblock 1 80 0" 2 "$block_file" + wait_for_file_pattern_local "$log_file" "Inventory # 1 opened: Chest" 12 +} + +setup_world() { + local port="$1" + run_rcon_or_detail "$port" "gamerule sendCommandFeedback true" || return 1 + run_rcon "$port" "gamerule keepInventory true" || true + run_rcon "$port" "time set day" || true + run_rcon "$port" "weather clear" || true + run_rcon "$port" "difficulty peaceful" || true +} + +setup_area() { + local port="$1" + run_rcon_each "$port" "fill -2 78 -3 3 82 3 air 0 replace" "fill -2 78 -3 3 82 3 air" "fill -2 78 -3 3 82 3 minecraft:air" + run_rcon_each "$port" "fill -2 79 -3 3 79 3 stone 0 replace" "fill -2 79 -3 3 79 3 stone" "fill -2 79 -3 3 79 3 minecraft:stone" + run_rcon_each "$port" "setblock 1 80 0 air 0 replace" "setblock 1 80 0 air" "setblock 1 80 0 minecraft:air" + run_rcon_each "$port" "setblock 1 80 0 chest 0 replace" "setblock 1 80 0 chest" "setblock 1 80 0 minecraft:chest" + run_rcon_each "$port" "blockdata 1 80 0 {Items:[]}" "data merge block 1 80 0 {Items:[]}" +} + +setup_player() { + local port="$1" + local username="$2" + run_rcon "$port" "op $username" || true + run_rcon "$port" "gamemode creative $username" || return 1 + run_rcon_any "$port" "tp $username 1.5 80 2.5" "tp $username 1 80 2" || true +} + +run_inventory_sequence() { + local version="$1" + local rcon_port="$2" + local session="$3" + local username="$4" + local log_file="$5" + local block_file="$6" + + send_mcc_command "$session" "$log_file" "inventory player drop -1 all" 1 "$block_file" || true + for slot in 36 37 38 39 40 41 42 43 44; do + send_mcc_command "$session" "$log_file" "inventory creativedelete $slot" 0.2 "$block_file" || true + done + + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_contains "$LAST_BLOCK" 'Inventory #0 - Player Inventory' "player inventory did not list" || return 1 + send_mcc_command "$session" "$log_file" "inventory inventories" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#0[[:space:]]+- Player Inventory' "inventory discovery did not list player inventory" || return 1 + + send_mcc_command "$session" "$log_file" "inventory creativegive 36 Diamond 16" 1 "$block_file" + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#36[[:space:]]*: x16[[:space:]]+Diamond' "creativegive did not populate player slot 36" || return 1 + send_mcc_command "$session" "$log_file" "inventory search Diamond 16" 1 "$block_file" + assert_contains "$LAST_BLOCK" 'Diamond' "inventory search did not find Diamond" || return 1 + send_mcc_command "$session" "$log_file" "inventory creativedelete 36" 1 "$block_file" + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_not_contains "$LAST_BLOCK" '#36[[:space:]]*: x16[[:space:]]+Diamond' "creativedelete left Diamond in player slot 36" || return 1 + + send_mcc_command "$session" "$log_file" "inventory creativegive 36 Dirt 3" 1 "$block_file" + run_rcon "$rcon_port" "gamemode survival $username" || return 1 + sleep 1 + send_mcc_command "$session" "$log_file" "inventory player click 36 right" 2 "$block_file" + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#36[[:space:]]*: x1[[:space:]]+Dirt' "player right-click did not halve Dirt stack" || return 1 + assert_contains "$LAST_BLOCK" '#-1[[:space:]]*: x2[[:space:]]+Dirt' "player right-click did not put Dirt on cursor" || return 1 + send_mcc_command "$session" "$log_file" "inventory player click 36 left" 2 "$block_file" + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#36[[:space:]]*: x3[[:space:]]+Dirt' "player left-click did not merge Dirt back into slot 36" || return 1 + assert_not_contains "$LAST_BLOCK" '#-1[[:space:]]*: x[0-9]+[[:space:]]+Dirt' "player left-click merge left Dirt on cursor" || return 1 + + run_rcon_any "$rcon_port" "tp $username 1.5 80 2.5" "tp $username 1 80 2" || true + sleep 1 + send_mcc_command "$session" "$log_file" "inventory player drop 36" 0.2 "$block_file" + clear_dropped_items "$rcon_port" + sleep 1 + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#36[[:space:]]*: x2[[:space:]]+Dirt' "single drop did not decrement Dirt stack" || return 1 + + run_rcon "$rcon_port" "gamemode creative $username" || return 1 + sleep 1 + clear_dropped_items "$rcon_port" + send_mcc_command "$session" "$log_file" "inventory creativedelete 36" 1 "$block_file" + send_mcc_command "$session" "$log_file" "inventory creativegive 36 Dirt 3" 1 "$block_file" + run_rcon "$rcon_port" "gamemode survival $username" || return 1 + run_rcon_any "$rcon_port" "tp $username 1.5 80 2.5" "tp $username 1 80 2" || true + sleep 1 + send_mcc_command "$session" "$log_file" "inventory player drop 36 all" 0.2 "$block_file" + clear_dropped_items "$rcon_port" + sleep 1 + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_not_contains "$LAST_BLOCK" '#36[[:space:]]*: x[0-9]+[[:space:]]+Dirt' "drop all left Dirt in player slot 36" || return 1 + + run_rcon "$rcon_port" "gamemode creative $username" || return 1 + run_rcon_any "$rcon_port" "tp $username 1.5 80 2.5" "tp $username 1 80 2" || true + sleep 2 + send_mcc_command "$session" "$log_file" "inventory creativegive 36 Diamond 16" 1 "$block_file" + send_mcc_command "$session" "$log_file" "inventory creativegive 37 GoldIngot 7" 1 "$block_file" + send_mcc_command "$session" "$log_file" "changeslot 9" 1 "$block_file" + run_rcon "$rcon_port" "gamemode survival $username" || return 1 + sleep 1 + open_chest "$session" "$log_file" "$block_file" || { FAIL_DETAIL="chest did not open"; return 1; } + + send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#54[[:space:]]*: x16[[:space:]]+Diamond' "container list did not mirror player slot 36 as chest slot 54" || return 1 + assert_contains "$LAST_BLOCK" '#55[[:space:]]*: x7[[:space:]]+Gold[[:space:]]+Ingot' "container list did not mirror player slot 37 as chest slot 55" || return 1 + + send_mcc_command "$session" "$log_file" "inventory container click 54 ShiftClick" 2 "$block_file" + send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#0[[:space:]]*: x16[[:space:]]+Diamond' "container shift-click did not move Diamond to chest slot 0" || return 1 + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_not_contains "$LAST_BLOCK" '#36[[:space:]]*: x16[[:space:]]+Diamond' "issue case failed: player slot 36 still showed shifted Diamond" || return 1 + + send_mcc_command "$session" "$log_file" "inventory container click 55 ShiftRightClick" 2 "$block_file" + send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#1[[:space:]]*: x7[[:space:]]+Gold[[:space:]]+Ingot' "container shift-right-click did not move GoldIngot to chest slot 1" || return 1 + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_not_contains "$LAST_BLOCK" '#37[[:space:]]*: x7[[:space:]]+Gold[[:space:]]+Ingot' "player slot 37 still showed shifted GoldIngot" || return 1 + + send_mcc_command "$session" "$log_file" "inventory search GoldIngot 7" 1 "$block_file" + assert_contains "$LAST_BLOCK" 'Gold[[:space:]]+Ingot' "inventory search did not find GoldIngot after moving to container" || return 1 + + send_mcc_command "$session" "$log_file" "inventory container click 0 right" 2 "$block_file" + send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#0[[:space:]]*: x8[[:space:]]+Diamond' "container right-click did not halve chest stack" || return 1 + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#-1[[:space:]]*: x8[[:space:]]+Diamond' "container right-click did not put half stack on cursor" || return 1 + + send_mcc_command "$session" "$log_file" "inventory container click 2 right" 2 "$block_file" + send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#2[[:space:]]*: x1[[:space:]]+Diamond' "container right-click did not place one item into empty slot 2" || return 1 + send_mcc_command "$session" "$log_file" "inventory container click 2 left" 2 "$block_file" + send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#2[[:space:]]*: x8[[:space:]]+Diamond' "container left-click did not merge cursor into slot 2" || return 1 + send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" + assert_not_contains "$LAST_BLOCK" '#-1[[:space:]]*: x[0-9]+[[:space:]]+Diamond' "container left-click merge left Diamond on cursor" || return 1 + + send_mcc_command "$session" "$log_file" "inventory container drop 2" 0.2 "$block_file" + clear_dropped_items "$rcon_port" + sleep 1 + send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" + assert_contains "$LAST_BLOCK" '#2[[:space:]]*: x7[[:space:]]+Diamond' "container single drop did not decrement chest slot 2" || return 1 + send_mcc_command "$session" "$log_file" "inventory container drop 2 all" 0.2 "$block_file" + clear_dropped_items "$rcon_port" + sleep 1 + send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" + assert_not_contains "$LAST_BLOCK" '#2[[:space:]]*: x[0-9]+[[:space:]]+Diamond' "container drop all left Diamond in chest slot 2" || return 1 + + send_mcc_command "$session" "$log_file" "inventory container close" 1 "$block_file" + send_mcc_command "$session" "$log_file" "inventory inventories" 1 "$block_file" + assert_not_contains "$LAST_BLOCK" '#1[[:space:]]*-' "container close left inventory #1 visible" || return 1 + + run_rcon "$rcon_port" "gamemode creative $username" || return 1 + sleep 1 + send_mcc_command "$session" "$log_file" "inventory creativegive 37 Emerald 1" 1 "$block_file" + send_mcc_command "$session" "$log_file" "inventory player click 37 middle" 1 "$block_file" + assert_contains "$LAST_BLOCK" 'middle' "middle-click command path did not execute" || return 1 + + assert_no_runtime_crash "$log_file" || return 1 +} + +run_one_version() { + local version="$1" + local target + target="$(server_target_for "$version")" + local safe session username version_dir cfg log_file block_file mcc_root rcon_port + safe="$(sanitize_version "$version")" + session="inventory-full-$safe" + username="InvF${safe//_/}" + username="${username:0:16}" + version_dir="$RUN_ROOT/$version" + cfg="$version_dir/MinecraftClient.ini" + log_file="/tmp/mcc-debug/$session/mcc-debug.log" + block_file="$version_dir/command-blocks.log" + mkdir -p "$version_dir" "/tmp/mcc-debug/$session" + : > "$log_file" + : > "$block_file" + + echo "== inventory $version ==" + bash "$SCRIPT_DIR/ensure_offline_server.sh" "$target" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "$version" "server setup failed" "$log_file" >> "$SUMMARY"; return 1; } + mc-start "$target" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "$version" "server start failed" "$log_file" >> "$SUMMARY"; return 1; } + wait_for_server_ready "$target" >/dev/null || true + rcon_port="$(rcon_port_for "$target")" + + bash "$SCRIPT_DIR/prepare_offline_mcc_config.sh" "$cfg" "$version" "$username" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "$version" "config setup failed" "$log_file" >> "$SUMMARY"; mc-stop "$target" --confirm >/dev/null 2>&1 || true; return 1; } + sed -i 's#^Server = .*#Server = { Host = "localhost", Port = 25565 }#' "$cfg" + FAIL_DETAIL="" + setup_world "$rcon_port" || { printf '%s\tFAIL\t%s\t%s\n' "$version" "${FAIL_DETAIL:-world setup failed}" "$log_file" >> "$SUMMARY"; mc-stop "$target" --confirm >/dev/null 2>&1 || true; return 1; } + + mcc_root="$(dirname "$cfg")" + mkdir -p "/tmp/mcc-debug/$session" + local input_file="/tmp/mcc-debug/$session/mcc_input.txt" + local pid_file="/tmp/mcc-debug/$session/mcc.pid" + : > "$input_file" + ( + cd "$mcc_root" || exit 1 + printf '%s\n' "$$" > "$pid_file" + exec env MCC_FILE_INPUT=1 MCC_INPUT_FILE="$input_file" dotnet run --project "$REPO_ROOT/MinecraftClient" -c Release --no-build > "$log_file" 2>&1 + ) & + local mcc_pid=$! + printf '%s\n' "$mcc_pid" > "$pid_file" + + local ok=0 + if ! wait_for_file_pattern_local "$log_file" "Server was successfully joined" 40; then + FAIL_DETAIL="MCC did not join server" + ok=1 + else + setup_player "$rcon_port" "$username" || { FAIL_DETAIL="player setup failed after join"; ok=1; } + setup_area "$rcon_port" || { ok=1; } + setup_player "$rcon_port" "$username" || { FAIL_DETAIL="player setup failed after area setup"; ok=1; } + sleep 2 + if [[ -z "${FAIL_DETAIL:-}" ]]; then + FAIL_DETAIL="" + run_inventory_sequence "$version" "$rcon_port" "$session" "$username" "$log_file" "$block_file" + ok=$? + fi + fi + + kill "$mcc_pid" >/dev/null 2>&1 || true + wait "$mcc_pid" >/dev/null 2>&1 || true + mc-stop "$target" --confirm >/dev/null 2>&1 || true + wait_for_server_stop "$target" >/dev/null 2>&1 || true + + if [[ "$ok" -eq 0 ]]; then + printf '%s\tPASS\tfull inventory command/API sweep\t%s\n' "$version" "$log_file" >> "$SUMMARY" + echo "PASS $version" + return 0 + fi + + printf '%s\tFAIL\t%s\t%s\n' "$version" "${FAIL_DETAIL:-unknown failure}" "$log_file" >> "$SUMMARY" + echo "${FAIL_DETAIL:-unknown failure}" >&2 + echo "FAIL $version" + return 1 +} + +write_issue3112_script() { + local script_path="$1" + cat > "$script_path" <<'CS' +//MCCScript 1.0 + +MCC.LoadBot(new Issue3112InventoryReproBot()); + +//MCCScript Extensions + +public class Issue3112InventoryReproBot : ChatBot +{ + private int ticks; + private int phase; + private bool finished; + + public override void AfterGameJoined() + { + ticks = 0; + phase = 0; + finished = false; + LogToConsole("ISSUE3112_REPRO_START"); + } + + public override void Update() + { + if (finished) + return; + + ticks++; + + if (phase == 0 && ticks >= 20) + { + PerformInternalCommand("inventory creativedelete 36"); + PerformInternalCommand("inventory creativegive 36 DiamondOre 1"); + PerformInternalCommand("changeslot 9"); + phase = 1; + ticks = 0; + return; + } + + if (phase == 1 && ticks >= 20) + { + if (!PlayerHasOre()) + { + Fail("missing ore before container click"); + return; + } + + PerformInternalCommand("useblock 1 80 0"); + phase = 2; + ticks = 0; + return; + } + + if (phase == 2 && ticks >= 40) + { + if (!GetInventories().ContainsKey(1)) + { + Fail("container did not open"); + return; + } + + PerformInternalCommand("inventory container click 54 ShiftClick"); + phase = 3; + ticks = 0; + return; + } + + if (phase == 3 && ticks >= 40) + { + if (PlayerHasOre()) + Fail("ISSUE3112_REPRO_STALE_FAIL"); + else + Pass(); + } + } + + private bool PlayerHasOre() + { + foreach (var item in GetPlayerInventory().Items.Values) + { + if (item.Type == ItemType.DiamondOre && item.Count > 0) + return true; + } + + return false; + } + + private void Pass() + { + finished = true; + LogToConsole("ISSUE3112_REPRO_PASS"); + PerformInternalCommand("inventory container close"); + } + + private void Fail(string reason) + { + finished = true; + LogToConsole(reason); + } +} +CS +} + +run_issue3112_repro() { + local version="$1" + local target + target="$(server_target_for "$version")" + local safe session username version_dir cfg log_file script_file mcc_root rcon_port + safe="$(sanitize_version "$version")" + session="issue3112-$safe" + username="Iss3112${safe//_/}" + username="${username:0:16}" + version_dir="$RUN_ROOT/issue3112-$version" + cfg="$version_dir/MinecraftClient.ini" + log_file="/tmp/mcc-debug/$session/mcc-debug.log" + script_file="$version_dir/issue3112_repro.cs" + mkdir -p "$version_dir" "/tmp/mcc-debug/$session" + : > "$log_file" + write_issue3112_script "$script_file" + + echo "== issue3112 $version ==" + bash "$SCRIPT_DIR/ensure_offline_server.sh" "$target" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "server setup failed" "$log_file" >> "$SUMMARY"; return 1; } + mc-start "$target" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "server start failed" "$log_file" >> "$SUMMARY"; return 1; } + wait_for_server_ready "$target" >/dev/null || true + rcon_port="$(rcon_port_for "$target")" + + bash "$SCRIPT_DIR/prepare_offline_mcc_config.sh" "$cfg" "$version" "$username" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "config setup failed" "$log_file" >> "$SUMMARY"; mc-stop "$target" --confirm >/dev/null 2>&1 || true; return 1; } + sed -i 's#^Server = .*#Server = { Host = "localhost", Port = 25565 }#' "$cfg" + FAIL_DETAIL="" + setup_world "$rcon_port" || { printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "${FAIL_DETAIL:-world setup failed}" "$log_file" >> "$SUMMARY"; mc-stop "$target" --confirm >/dev/null 2>&1 || true; return 1; } + + mcc_root="$(dirname "$cfg")" + local input_file="/tmp/mcc-debug/$session/mcc_input.txt" + local pid_file="/tmp/mcc-debug/$session/mcc.pid" + : > "$input_file" + ( + cd "$mcc_root" || exit 1 + printf '%s\n' "$$" > "$pid_file" + exec env MCC_FILE_INPUT=1 MCC_INPUT_FILE="$input_file" dotnet run --project "$REPO_ROOT/MinecraftClient" -c Release --no-build > "$log_file" 2>&1 + ) & + local mcc_pid=$! + printf '%s\n' "$mcc_pid" > "$pid_file" + + local ok=0 + if ! wait_for_file_pattern_local "$log_file" "Server was successfully joined" 40; then + FAIL_DETAIL="MCC did not join server" + ok=1 + else + setup_player "$rcon_port" "$username" || { FAIL_DETAIL="player setup failed after join"; ok=1; } + setup_area "$rcon_port" || { ok=1; } + setup_player "$rcon_port" "$username" || { FAIL_DETAIL="player setup failed after area setup"; ok=1; } + sleep 2 + if [[ -z "${FAIL_DETAIL:-}" ]]; then + mcc-cmd --session "$session" "script $script_file" >/dev/null + if wait_for_file_pattern_local "$log_file" "ISSUE3112_REPRO_PASS" 30; then + ok=0 + else + FAIL_DETAIL="Issue #3112 repro did not pass" + ok=1 + fi + fi + fi + + kill "$mcc_pid" >/dev/null 2>&1 || true + wait "$mcc_pid" >/dev/null 2>&1 || true + mc-stop "$target" --confirm >/dev/null 2>&1 || true + wait_for_server_stop "$target" >/dev/null 2>&1 || true + + if [[ "$ok" -eq 0 ]]; then + printf '%s\tPASS\tIssue #3112 mirrored inventory script\t%s\n' "issue3112-$version" "$log_file" >> "$SUMMARY" + echo "PASS issue3112 $version" + return 0 + fi + + printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "${FAIL_DETAIL:-unknown failure}" "$log_file" >> "$SUMMARY" + echo "${FAIL_DETAIL:-unknown failure}" >&2 + echo "FAIL issue3112 $version" + return 1 +} + +overall=0 +for version in $VERSIONS; do + if ! run_one_version "$version"; then + overall=1 + [[ "$STOP_ON_FAIL" == "1" ]] && break + fi +done + +echo "SUMMARY=$SUMMARY" + +if [[ "$RUN_ISSUE_SCRIPT" == "1" && "$overall" -eq 0 ]]; then + if ! run_issue3112_repro "$ISSUE_VERSION"; then + overall=1 + fi + echo "SUMMARY=$SUMMARY" +fi + +exit "$overall" From b10bd81bee4185964bddd277eed3e04fb1cb9e0d Mon Sep 17 00:00:00 2001 From: Anon Date: Fri, 5 Jun 2026 21:00:39 +0200 Subject: [PATCH 8/9] Keep inventory sweep generalized --- .skills/mcc-integration-testing/SKILL.md | 8 +- tools/README.md | 3 - tools/run-inventory-full-sweep.sh | 206 +---------------------- 3 files changed, 3 insertions(+), 214 deletions(-) diff --git a/.skills/mcc-integration-testing/SKILL.md b/.skills/mcc-integration-testing/SKILL.md index 6316e0b8..e7c0831d 100644 --- a/.skills/mcc-integration-testing/SKILL.md +++ b/.skills/mcc-integration-testing/SKILL.md @@ -138,12 +138,6 @@ Default coverage includes: - creative middle-click command path - log scan for packet parse failures, queue-empty crashes, unhandled exceptions, and disconnects -Run the Issue #3112 repro after a passing sweep: - -```bash -tools/run-inventory-full-sweep.sh --versions "1.20.4" --run-issue-script -``` - The script writes `summary.tsv` under `RUN_ROOT` and per-version logs under `/tmp/mcc-debug/inventory-full-/mcc-debug.log`. When a matrix has existing PASS rows, do not rerun them unless a later code change affects that row or the user asks for a full rerun. Derive remaining rows from summaries: @@ -203,7 +197,7 @@ Optionally override the login name with the fourth argument to the config helper - `tools/run-creative-e2e.sh` - ordered creative-mode E2E regression scenario - `tools/run-inventory-full-sweep.sh` - - full inventory command/API sweep across one or more versions, with optional Issue #3112 MCCScript repro + - full inventory command/API sweep across one or more versions ## Evidence Discipline diff --git a/tools/README.md b/tools/README.md index 87a65480..c69d3dd3 100644 --- a/tools/README.md +++ b/tools/README.md @@ -36,9 +36,6 @@ tools/run-inventory-full-sweep.sh --versions "1.21.10 1.21.11" # Full default major-version sweep tools/run-inventory-full-sweep.sh - -# Run the Issue #3112 mirrored-player-inventory script after a passing sweep -tools/run-inventory-full-sweep.sh --versions "1.20.4" --run-issue-script ``` Useful environment overrides: diff --git a/tools/run-inventory-full-sweep.sh b/tools/run-inventory-full-sweep.sh index ea98846e..397edd3c 100755 --- a/tools/run-inventory-full-sweep.sh +++ b/tools/run-inventory-full-sweep.sh @@ -11,8 +11,6 @@ REPO_ROOT="$(cd -P "$(dirname "$SCRIPT_SELF")/.." >/dev/null 2>&1 && pwd)" SCRIPT_DIR="$REPO_ROOT/.skills/mcc-integration-testing/scripts" RUN_ROOT="${RUN_ROOT:-/tmp/mcc-inventory-full-sweep/$(date +%Y%m%d-%H%M%S)}" VERSIONS="${VERSIONS_OVERRIDE:-1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 26.1}" -RUN_ISSUE_SCRIPT="${RUN_ISSUE_SCRIPT:-0}" -ISSUE_VERSION="${ISSUE_VERSION:-1.20.4}" STOP_ON_FAIL="${STOP_ON_FAIL:-1}" usage() { @@ -24,19 +22,15 @@ The matrix is sequential because mc-* tmux sessions are shared state. Options: --versions "1.20.4 1.21.11" Space-separated versions to test. - --run-issue-script Run the Issue #3112 MCCScript repro after a passing sweep. - --issue-version VERSION Version for the Issue #3112 repro. Default: 1.20.4. --keep-going Continue after failures. --stop-on-fail Stop on first failure. Default. -h, --help Show this help. Environment overrides: - VERSIONS_OVERRIDE, RUN_ROOT, RUN_ISSUE_SCRIPT, ISSUE_VERSION, STOP_ON_FAIL, - MCC_SERVERS. + VERSIONS_OVERRIDE, RUN_ROOT, STOP_ON_FAIL, MCC_SERVERS. Examples: tools/run-inventory-full-sweep.sh --versions "1.21.10 1.21.11" - RUN_ISSUE_SCRIPT=1 tools/run-inventory-full-sweep.sh --versions "1.20.4" USAGE } @@ -46,14 +40,6 @@ while [[ $# -gt 0 ]]; do VERSIONS="$2" shift 2 ;; - --run-issue-script) - RUN_ISSUE_SCRIPT=1 - shift - ;; - --issue-version) - ISSUE_VERSION="$2" - shift 2 - ;; --keep-going) STOP_ON_FAIL=0 shift @@ -348,7 +334,7 @@ run_inventory_sequence() { send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" assert_contains "$LAST_BLOCK" '#0[[:space:]]*: x16[[:space:]]+Diamond' "container shift-click did not move Diamond to chest slot 0" || return 1 send_mcc_command "$session" "$log_file" "inventory player list" 1 "$block_file" - assert_not_contains "$LAST_BLOCK" '#36[[:space:]]*: x16[[:space:]]+Diamond' "issue case failed: player slot 36 still showed shifted Diamond" || return 1 + assert_not_contains "$LAST_BLOCK" '#36[[:space:]]*: x16[[:space:]]+Diamond' "mirrored player slot 36 still showed shifted Diamond" || return 1 send_mcc_command "$session" "$log_file" "inventory container click 55 ShiftRightClick" 2 "$block_file" send_mcc_command "$session" "$log_file" "inventory container list" 1 "$block_file" @@ -472,187 +458,6 @@ run_one_version() { return 1 } -write_issue3112_script() { - local script_path="$1" - cat > "$script_path" <<'CS' -//MCCScript 1.0 - -MCC.LoadBot(new Issue3112InventoryReproBot()); - -//MCCScript Extensions - -public class Issue3112InventoryReproBot : ChatBot -{ - private int ticks; - private int phase; - private bool finished; - - public override void AfterGameJoined() - { - ticks = 0; - phase = 0; - finished = false; - LogToConsole("ISSUE3112_REPRO_START"); - } - - public override void Update() - { - if (finished) - return; - - ticks++; - - if (phase == 0 && ticks >= 20) - { - PerformInternalCommand("inventory creativedelete 36"); - PerformInternalCommand("inventory creativegive 36 DiamondOre 1"); - PerformInternalCommand("changeslot 9"); - phase = 1; - ticks = 0; - return; - } - - if (phase == 1 && ticks >= 20) - { - if (!PlayerHasOre()) - { - Fail("missing ore before container click"); - return; - } - - PerformInternalCommand("useblock 1 80 0"); - phase = 2; - ticks = 0; - return; - } - - if (phase == 2 && ticks >= 40) - { - if (!GetInventories().ContainsKey(1)) - { - Fail("container did not open"); - return; - } - - PerformInternalCommand("inventory container click 54 ShiftClick"); - phase = 3; - ticks = 0; - return; - } - - if (phase == 3 && ticks >= 40) - { - if (PlayerHasOre()) - Fail("ISSUE3112_REPRO_STALE_FAIL"); - else - Pass(); - } - } - - private bool PlayerHasOre() - { - foreach (var item in GetPlayerInventory().Items.Values) - { - if (item.Type == ItemType.DiamondOre && item.Count > 0) - return true; - } - - return false; - } - - private void Pass() - { - finished = true; - LogToConsole("ISSUE3112_REPRO_PASS"); - PerformInternalCommand("inventory container close"); - } - - private void Fail(string reason) - { - finished = true; - LogToConsole(reason); - } -} -CS -} - -run_issue3112_repro() { - local version="$1" - local target - target="$(server_target_for "$version")" - local safe session username version_dir cfg log_file script_file mcc_root rcon_port - safe="$(sanitize_version "$version")" - session="issue3112-$safe" - username="Iss3112${safe//_/}" - username="${username:0:16}" - version_dir="$RUN_ROOT/issue3112-$version" - cfg="$version_dir/MinecraftClient.ini" - log_file="/tmp/mcc-debug/$session/mcc-debug.log" - script_file="$version_dir/issue3112_repro.cs" - mkdir -p "$version_dir" "/tmp/mcc-debug/$session" - : > "$log_file" - write_issue3112_script "$script_file" - - echo "== issue3112 $version ==" - bash "$SCRIPT_DIR/ensure_offline_server.sh" "$target" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "server setup failed" "$log_file" >> "$SUMMARY"; return 1; } - mc-start "$target" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "server start failed" "$log_file" >> "$SUMMARY"; return 1; } - wait_for_server_ready "$target" >/dev/null || true - rcon_port="$(rcon_port_for "$target")" - - bash "$SCRIPT_DIR/prepare_offline_mcc_config.sh" "$cfg" "$version" "$username" >/dev/null || { printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "config setup failed" "$log_file" >> "$SUMMARY"; mc-stop "$target" --confirm >/dev/null 2>&1 || true; return 1; } - sed -i 's#^Server = .*#Server = { Host = "localhost", Port = 25565 }#' "$cfg" - FAIL_DETAIL="" - setup_world "$rcon_port" || { printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "${FAIL_DETAIL:-world setup failed}" "$log_file" >> "$SUMMARY"; mc-stop "$target" --confirm >/dev/null 2>&1 || true; return 1; } - - mcc_root="$(dirname "$cfg")" - local input_file="/tmp/mcc-debug/$session/mcc_input.txt" - local pid_file="/tmp/mcc-debug/$session/mcc.pid" - : > "$input_file" - ( - cd "$mcc_root" || exit 1 - printf '%s\n' "$$" > "$pid_file" - exec env MCC_FILE_INPUT=1 MCC_INPUT_FILE="$input_file" dotnet run --project "$REPO_ROOT/MinecraftClient" -c Release --no-build > "$log_file" 2>&1 - ) & - local mcc_pid=$! - printf '%s\n' "$mcc_pid" > "$pid_file" - - local ok=0 - if ! wait_for_file_pattern_local "$log_file" "Server was successfully joined" 40; then - FAIL_DETAIL="MCC did not join server" - ok=1 - else - setup_player "$rcon_port" "$username" || { FAIL_DETAIL="player setup failed after join"; ok=1; } - setup_area "$rcon_port" || { ok=1; } - setup_player "$rcon_port" "$username" || { FAIL_DETAIL="player setup failed after area setup"; ok=1; } - sleep 2 - if [[ -z "${FAIL_DETAIL:-}" ]]; then - mcc-cmd --session "$session" "script $script_file" >/dev/null - if wait_for_file_pattern_local "$log_file" "ISSUE3112_REPRO_PASS" 30; then - ok=0 - else - FAIL_DETAIL="Issue #3112 repro did not pass" - ok=1 - fi - fi - fi - - kill "$mcc_pid" >/dev/null 2>&1 || true - wait "$mcc_pid" >/dev/null 2>&1 || true - mc-stop "$target" --confirm >/dev/null 2>&1 || true - wait_for_server_stop "$target" >/dev/null 2>&1 || true - - if [[ "$ok" -eq 0 ]]; then - printf '%s\tPASS\tIssue #3112 mirrored inventory script\t%s\n' "issue3112-$version" "$log_file" >> "$SUMMARY" - echo "PASS issue3112 $version" - return 0 - fi - - printf '%s\tFAIL\t%s\t%s\n' "issue3112-$version" "${FAIL_DETAIL:-unknown failure}" "$log_file" >> "$SUMMARY" - echo "${FAIL_DETAIL:-unknown failure}" >&2 - echo "FAIL issue3112 $version" - return 1 -} - overall=0 for version in $VERSIONS; do if ! run_one_version "$version"; then @@ -663,11 +468,4 @@ done echo "SUMMARY=$SUMMARY" -if [[ "$RUN_ISSUE_SCRIPT" == "1" && "$overall" -eq 0 ]]; then - if ! run_issue3112_repro "$ISSUE_VERSION"; then - overall=1 - fi - echo "SUMMARY=$SUMMARY" -fi - exit "$overall" From 82555bd8233c969266b7cbe52559adfd51e37768 Mon Sep 17 00:00:00 2001 From: Anon Date: Fri, 5 Jun 2026 21:17:09 +0200 Subject: [PATCH 9/9] Keep version adaptation skill generalized --- .skills/mcc-version-adaptation/SKILL.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.skills/mcc-version-adaptation/SKILL.md b/.skills/mcc-version-adaptation/SKILL.md index c3be7c12..54b1c782 100644 --- a/.skills/mcc-version-adaptation/SKILL.md +++ b/.skills/mcc-version-adaptation/SKILL.md @@ -194,13 +194,6 @@ PY Do the same for `SERVERBOUND_TEMPLATE`. Clientbound and serverbound can change independently. Do not inherit a newer palette just because one side looks similar. For example, `1.21.11` used the same play packet order as `1.21.9/1.21.10` for the tested inventory path, while `26.1` had additional shifts. -Known packet lessons: - -- `1.9`, `1.9.1`, and `1.9.2` need their own packet palette. They are not safe to route through the later 1.9.x palette. -- Pure `1.19` serverbound IDs differ from later 1.19.x. Do not put `MessageAcknowledgment` at `0x03`; pure 1.19 has `ChatCommand` at `0x03`, `ChatMessage` at `0x04`, and `ChatPreview` at `0x05`. -- A wrong packet palette often appears as unrelated inventory failure: creative give/delete disconnects, `Queue empty`, or `Failed to process incoming packet`. -- Game event reason `3` is `CHANGE_GAME_MODE`. If RCON changed the player to creative but MCC still refuses creative inventory commands, inspect `ChangeGameState` handling. - ## Step 5: Check Variant Encoding Changes For entity types that use variant serializers (Cat, Wolf, Frog, Painting), check if the codec changed between versions by inspecting: @@ -230,17 +223,6 @@ Compare key packet codec classes between versions. Known changes: When in doubt, compare the relevant packet class (e.g. `ClientboundAddEntityPacket.java`) between versions. -## Step 7.1: Check JoinGame and Respawn Formats - -JoinGame and Respawn are high-risk because dimension fields changed several times: - -- `1.16` and `1.16.1`: dimension type/name handling uses string identifiers in places where later versions do not. -- `1.16.2` through `1.18.2`: dimension type can be an NBT compound in JoinGame/Respawn. -- `1.19+`: dimension type commonly moves back to identifiers. -- `1.20.6+`: registry-driven IDs appear in more fields. - -When a version joins but terrain, inventory, or later packets look misaligned, inspect JoinGame/Respawn first. A single wrong dimension-field read leaves unread bytes in the packet and can make the next packet look broken. - ## Step 8: Update Block Collision Shapes (Physics Engine) MCC's physics engine uses block collision shape data from PrismarineJS `minecraft-data` to perform accurate AABB collision detection (stored in `MinecraftClient/Physics/BlockShapeData.json`, embedded as a resource).