diff --git a/MinecraftClient/CommandHandler/ArgumentType/BotNameArgumentType.cs b/MinecraftClient/CommandHandler/ArgumentType/BotNameArgumentType.cs index 1f49da98..b17bdf1c 100644 --- a/MinecraftClient/CommandHandler/ArgumentType/BotNameArgumentType.cs +++ b/MinecraftClient/CommandHandler/ArgumentType/BotNameArgumentType.cs @@ -17,7 +17,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType public override Task ListSuggestions(CommandContext context, SuggestionsBuilder builder) { McClient? client = CmdResult.currentHandler; - if (client != null) + if (client is not null) { var botList = client.GetLoadedChatBots(); foreach (var bot in botList) diff --git a/MinecraftClient/CommandHandler/ArgumentType/HotbarSlotArgumentType.cs b/MinecraftClient/CommandHandler/ArgumentType/HotbarSlotArgumentType.cs index ebf05813..a71349b6 100644 --- a/MinecraftClient/CommandHandler/ArgumentType/HotbarSlotArgumentType.cs +++ b/MinecraftClient/CommandHandler/ArgumentType/HotbarSlotArgumentType.cs @@ -18,10 +18,10 @@ namespace MinecraftClient.CommandHandler.ArgumentType public override Task ListSuggestions(CommandContext context, SuggestionsBuilder builder) { McClient? client = CmdResult.currentHandler; - if (client != null) + if (client is not null) { Inventory.Container? inventory = client.GetInventory(0); - if (inventory != null) + if (inventory is not null) { for (int i = 1; i <= 9; ++i) { diff --git a/MinecraftClient/CommandHandler/ArgumentType/InventoryIdArgumentType.cs b/MinecraftClient/CommandHandler/ArgumentType/InventoryIdArgumentType.cs index 15164956..d485f82a 100644 --- a/MinecraftClient/CommandHandler/ArgumentType/InventoryIdArgumentType.cs +++ b/MinecraftClient/CommandHandler/ArgumentType/InventoryIdArgumentType.cs @@ -18,7 +18,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType public override Task ListSuggestions(CommandContext context, SuggestionsBuilder builder) { McClient? client = CmdResult.currentHandler; - if (client != null) + if (client is not null) { var invList = client.GetInventories(); foreach (var inv in invList) diff --git a/MinecraftClient/CommandHandler/ArgumentType/InventorySlotArgumentType.cs b/MinecraftClient/CommandHandler/ArgumentType/InventorySlotArgumentType.cs index 2536aa1e..b9e01942 100644 --- a/MinecraftClient/CommandHandler/ArgumentType/InventorySlotArgumentType.cs +++ b/MinecraftClient/CommandHandler/ArgumentType/InventorySlotArgumentType.cs @@ -19,7 +19,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType public override Task ListSuggestions(CommandContext context, SuggestionsBuilder builder) { McClient? client = CmdResult.currentHandler; - if (client != null && context.Nodes.Count >= 2) + if (client is not null && context.Nodes.Count >= 2) { string invName = context.Nodes[1].Range.Get(builder.Input); if (!int.TryParse(invName, out int invId)) @@ -33,11 +33,11 @@ namespace MinecraftClient.CommandHandler.ArgumentType }; Inventory.Container? inventory = client.GetInventory(invId); - if (inventory != null) + if (inventory is not null) { foreach ((int slot, Inventory.Item item) in inventory.Items) { - if (item != null && item.Count > 0) + if (item is not null && item.Count > 0) { string slotStr = slot.ToString(); if (slotStr.StartsWith(builder.RemainingLowerCase, StringComparison.InvariantCultureIgnoreCase)) diff --git a/MinecraftClient/CommandHandler/ArgumentType/MapBotMapIdArgumentType.cs b/MinecraftClient/CommandHandler/ArgumentType/MapBotMapIdArgumentType.cs index bd1ffee6..7b8b9b5d 100644 --- a/MinecraftClient/CommandHandler/ArgumentType/MapBotMapIdArgumentType.cs +++ b/MinecraftClient/CommandHandler/ArgumentType/MapBotMapIdArgumentType.cs @@ -19,10 +19,10 @@ namespace MinecraftClient.CommandHandler.ArgumentType public override Task ListSuggestions(CommandContext context, SuggestionsBuilder builder) { McClient? client = CmdResult.currentHandler; - if (client != null) + if (client is not null) { var bot = (Map?)client.GetLoadedChatBots().Find(bot => bot.GetType().Name == "Map"); - if (bot != null) + if (bot is not null) { var mapList = bot.cachedMaps; foreach (var map in mapList) diff --git a/MinecraftClient/CommandHandler/ArgumentType/PlayerNameArgumentType.cs b/MinecraftClient/CommandHandler/ArgumentType/PlayerNameArgumentType.cs index b5092251..4a622924 100644 --- a/MinecraftClient/CommandHandler/ArgumentType/PlayerNameArgumentType.cs +++ b/MinecraftClient/CommandHandler/ArgumentType/PlayerNameArgumentType.cs @@ -19,7 +19,7 @@ namespace MinecraftClient.CommandHandler.ArgumentType public override Task ListSuggestions(CommandContext context, SuggestionsBuilder builder) { McClient? client = CmdResult.currentHandler; - if (client != null) + if (client is not null) { var entityList = client.GetEntities().Values.ToList(); foreach (var entity in entityList) diff --git a/MinecraftClient/Protocol/Handlers/Packet/s2c/DeclareCommands.cs b/MinecraftClient/Protocol/Handlers/Packet/s2c/DeclareCommands.cs index 6883b6cf..b4e58cc2 100644 --- a/MinecraftClient/Protocol/Handlers/Packet/s2c/DeclareCommands.cs +++ b/MinecraftClient/Protocol/Handlers/Packet/s2c/DeclareCommands.cs @@ -235,7 +235,7 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c return false; List> currentArguments = signedArguments; - if (signedCapture != null) + if (signedCapture is not null) { currentArguments = new List>(signedArguments.Count + 1); currentArguments.AddRange(signedArguments); @@ -317,7 +317,7 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c case CommandNodeKind.Literal: return TryConsumeLiteral(command, position, node.Name!, out nextPosition); case CommandNodeKind.Argument: - if (node.Argument == null || !TryConsumeArgument(command, position, node.Argument.Value, out nextPosition)) + if (node.Argument is null || !TryConsumeArgument(command, position, node.Argument.Value, out nextPosition)) return false; if (node.Argument.Value.IsSigned) @@ -585,7 +585,7 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c }; } - if (name == null) + if (name is null) { layout = s_unknownLegacyArgumentType; return true; 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 5c5044f7..09f6d7a9 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/BundleContentsComponent.cs @@ -17,7 +17,7 @@ public class BundleContentsComponent(DataTypes dataTypes, ItemPalette itemPalett for (var i = 0; i < count; i++) { var item = dataTypes.ReadNextItemSlot(data, itemPalette); - if (item != null) + if (item is not null) Items.Add(item); } } 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 7305ee8c..ecbf18da 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_20_6/ChargedProjectilesComponent.cs @@ -17,7 +17,7 @@ public class ChargedProjectilesComponent(DataTypes dataTypes, ItemPalette itemPa for (var i = 0; i < count; i++) { var item = dataTypes.ReadNextItemSlot(data, itemPalette); - if (item != null) + if (item is not null) Items.Add(item); } } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/ConsumableComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/ConsumableComponent.cs index ad931c61..cd85f621 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/ConsumableComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/ConsumableComponent.cs @@ -114,7 +114,7 @@ public class ConsumableComponent(DataTypes dataTypes, ItemPalette itemPalette, S var data = new List(); data.AddRange(DataTypes.GetFloat(ConsumeSeconds)); data.AddRange(DataTypes.GetVarInt(Animation)); - if (Sound != null) data.AddRange(Sound.Serialize()); + if (Sound is not null) data.AddRange(Sound.Serialize()); data.AddRange(DataTypes.GetBool(HasConsumeParticles)); data.AddRange(DataTypes.GetVarInt(Effects.Count)); foreach (var effect in Effects) 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 c63e3f4d..a71e5197 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/EquippableComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/EquippableComponent.cs @@ -61,25 +61,25 @@ public class EquippableComponent(DataTypes dataTypes, ItemPalette itemPalette, S { var data = new List(); data.AddRange(DataTypes.GetVarInt(Slot)); - if (EquipSound != null) data.AddRange(EquipSound.Serialize()); + if (EquipSound is not null) data.AddRange(EquipSound.Serialize()); data.AddRange(DataTypes.GetBool(HasModel)); - if (HasModel && Model != null) + if (HasModel && Model is not null) data.AddRange(DataTypes.GetString(Model)); data.AddRange(DataTypes.GetBool(HasCameraOverlay)); - if (HasCameraOverlay && CameraOverlay != null) + if (HasCameraOverlay && CameraOverlay is not null) data.AddRange(DataTypes.GetString(CameraOverlay)); data.AddRange(DataTypes.GetBool(HasAllowedEntities)); if (HasAllowedEntities) { data.AddRange(DataTypes.GetVarInt(AllowedEntitiesType)); - if (AllowedEntitiesType == 0 && AllowedEntitiesTag != null) + if (AllowedEntitiesType == 0 && AllowedEntitiesTag is not null) { data.AddRange(DataTypes.GetString(AllowedEntitiesTag)); } - else if (AllowedEntitiesIds != null) + else if (AllowedEntitiesIds is not null) { foreach (var id in AllowedEntitiesIds) data.AddRange(DataTypes.GetVarInt(id)); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/RepairableComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/RepairableComponent.cs index 08dcb91c..dcdc36ff 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/RepairableComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/RepairableComponent.cs @@ -30,11 +30,11 @@ public class RepairableComponent(DataTypes dataTypes, ItemPalette itemPalette, S { var data = new List(); data.AddRange(DataTypes.GetVarInt(Type)); - if (Type == 0 && TagName != null) + if (Type == 0 && TagName is not null) { data.AddRange(DataTypes.GetString(TagName)); } - else if (ItemIds != null) + else if (ItemIds is not null) { foreach (var id in ItemIds) data.AddRange(DataTypes.GetVarInt(id)); diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/UseCooldownComponent.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/UseCooldownComponent.cs index 60f175c6..620deb1e 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/UseCooldownComponent.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Components/1_21_2/UseCooldownComponent.cs @@ -24,7 +24,7 @@ public class UseCooldownComponent(DataTypes dataTypes, ItemPalette itemPalette, var data = new List(); data.AddRange(DataTypes.GetFloat(Seconds)); data.AddRange(DataTypes.GetBool(HasCooldownGroup)); - if (HasCooldownGroup && CooldownGroup != null) + if (HasCooldownGroup && CooldownGroup is not null) data.AddRange(DataTypes.GetString(CooldownGroup)); return new Queue(data); } 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 c8bf2369..05e0d6d2 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 @@ -44,7 +44,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr data.AddRange(DataTypes.GetBool(HasBlocks)); if (HasBlocks) { - if(BlockSet == 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()); @@ -54,7 +54,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr data.AddRange(DataTypes.GetBool(HasProperities)); if (HasProperities) { - if(Properties == 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,7 +66,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr data.AddRange(DataTypes.GetBool(HasNbt)); if (HasNbt) { - if(Nbt == 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)); 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 dbc7c40a..4f6e01a7 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 @@ -39,7 +39,7 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC if (Type == 0) return new Queue(data); - if(BlockIds == 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++) 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 6170dffa..d35de380 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 @@ -47,12 +47,12 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC } else { - data.AddRange(DataTypes.GetBool(MinValue != null)); - if (MinValue != null) + data.AddRange(DataTypes.GetBool(MinValue is not null)); + if (MinValue is not null) data.AddRange(DataTypes.GetString(MinValue)); - data.AddRange(DataTypes.GetBool(MaxValue != null)); - if (MaxValue != null) + data.AddRange(DataTypes.GetBool(MaxValue is not null)); + if (MaxValue is not null) data.AddRange(DataTypes.GetString(MaxValue)); } diff --git a/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/SubComponentRegistry.cs b/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/SubComponentRegistry.cs index 49665709..4a991fd7 100644 --- a/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/SubComponentRegistry.cs +++ b/MinecraftClient/Protocol/Handlers/StructuredComponents/Core/SubComponentRegistry.cs @@ -31,7 +31,7 @@ public abstract class SubComponentRegistry(DataTypes dataTypes) var parseMethod = instance.GetType().GetMethod("Parse", BindingFlags.Instance | BindingFlags.NonPublic); - if (parseMethod == null) + 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 });