From b99ae535d28e0b954f5a5d218c948821523649e3 Mon Sep 17 00:00:00 2001 From: TheFifthRider Date: Thu, 30 Oct 2025 19:03:35 -0400 Subject: [PATCH 1/4] fix: NPE when spam clicking right click with a chisel. This should be marked as nullable :( --- .../BitsRecovery/CollectibleBehaviorScrapeCrucible.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs b/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs index eb30d39..c976da5 100644 --- a/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs +++ b/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs @@ -1,6 +1,8 @@ #nullable enable +using System; using SmithingPlus.Metal; using SmithingPlus.Util; +using Vintagestory; using Vintagestory.API.Common; using Vintagestory.GameContent; @@ -39,7 +41,7 @@ public override bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, Entity public override void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, - BlockSelection blockSel, + BlockSelection? blockSel, EntitySelection entitySel, ref EnumHandling handling) { @@ -48,6 +50,7 @@ public override void OnHeldInteractStop(float secondsUsed, if (byEntity.World.Side == EnumAppSide.Server) { if (byEntity is not EntityPlayer entityPlayer) return; + if (blockSel?.Position is null) return; var groundStorage = TryGetSelectedGroundStorage(entityPlayer, blockSel); if (!TryGetCrucibleStack(entityPlayer, blockSel, out var crucibleSlot) || crucibleSlot?.Itemstack is not { } crucibleStack) @@ -118,7 +121,7 @@ private static bool IsSelectingValidCrucible(EntityPlayer entityPlayer, BlockSel private static bool TryGetCrucibleStack(EntityPlayer entityPlayer, BlockSelection? blockSel, out ItemSlot? atSlot) { - atSlot = null; + atSlot = null; if (blockSel == null) return false; var groundStorage = TryGetSelectedGroundStorage(entityPlayer, blockSel); if (groundStorage?.GetSlotAt(blockSel) is not { Itemstack: not null } targetSlot) return false; @@ -128,7 +131,7 @@ private static bool TryGetCrucibleStack(EntityPlayer entityPlayer, BlockSelectio private static BlockEntityGroundStorage? TryGetSelectedGroundStorage(EntityPlayer entityPlayer, BlockSelection blockSel) - { + { var blockEntity = entityPlayer.World.BlockAccessor.GetBlockEntity(blockSel.Position); return blockEntity as BlockEntityGroundStorage; } From a034385c5e83cdfb581981cebf3ca98d58d7aabe Mon Sep 17 00:00:00 2001 From: TheFifthRider Date: Thu, 30 Oct 2025 19:05:11 -0400 Subject: [PATCH 2/4] style: Revert accidental whitespace --- SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs b/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs index c976da5..8e005cd 100644 --- a/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs +++ b/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs @@ -121,7 +121,7 @@ private static bool IsSelectingValidCrucible(EntityPlayer entityPlayer, BlockSel private static bool TryGetCrucibleStack(EntityPlayer entityPlayer, BlockSelection? blockSel, out ItemSlot? atSlot) { - atSlot = null; + atSlot = null; if (blockSel == null) return false; var groundStorage = TryGetSelectedGroundStorage(entityPlayer, blockSel); if (groundStorage?.GetSlotAt(blockSel) is not { Itemstack: not null } targetSlot) return false; From 8c66c9d670083e41afa75bd5c78f56a9a5af7453 Mon Sep 17 00:00:00 2001 From: TheFifthRider Date: Thu, 30 Oct 2025 19:05:27 -0400 Subject: [PATCH 3/4] style: Revert accidental whitespace --- SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs b/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs index 8e005cd..e34b0d6 100644 --- a/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs +++ b/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs @@ -131,7 +131,7 @@ private static bool TryGetCrucibleStack(EntityPlayer entityPlayer, BlockSelectio private static BlockEntityGroundStorage? TryGetSelectedGroundStorage(EntityPlayer entityPlayer, BlockSelection blockSel) - { + { var blockEntity = entityPlayer.World.BlockAccessor.GetBlockEntity(blockSel.Position); return blockEntity as BlockEntityGroundStorage; } From 5fdc9a7de2ac0e9ee9a008648ece5fc4d0cc7cf3 Mon Sep 17 00:00:00 2001 From: TheFifthRider Date: Thu, 30 Oct 2025 19:06:10 -0400 Subject: [PATCH 4/4] style: Remove unused imports --- SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs b/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs index e34b0d6..23db430 100644 --- a/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs +++ b/SmithingPlus/BitsRecovery/CollectibleBehaviorScrapeCrucible.cs @@ -1,8 +1,6 @@ #nullable enable -using System; using SmithingPlus.Metal; using SmithingPlus.Util; -using Vintagestory; using Vintagestory.API.Common; using Vintagestory.GameContent;