@sleek pecan
public override ItemStack OnPickBlock(IWorldAccessor world, BlockPos pos, ref EnumHandling handling)
{
ItemStack pickedStack = base.OnPickBlock(world, pos, ref handling);
if (pickedStack != null)
{
pickedStack = pickedStack.Clone();
}
IWorldChunk chunk = world.ChunkProvider.GetChunk(pos.X / 32, pos.Y / 32, pos.Z / 32);
string desc = chunk.GetModdata<string>(pos.ToString() + "-itemizerdesc", "");
string name = chunk.GetModdata<string>(pos.ToString() + "-itemizername", "");
if (desc != "" && pickedStack != null)
{
pickedStack.Attributes.SetString("itemizerDesc", desc);
}
if (name != "" && pickedStack != null)
{
pickedStack.Attributes.SetString("itemizerName", name);
}
return pickedStack;
}```
Going with the dnspy decompile, but, can you do a
if (pickedStack is null) {
return null;
}
after calling base.OnPickBlock?
Similarly, after looking up the chunk, can you do
if (chunk is null) {
return pickedStack;
This is crashing clients as they try and log in, when the world hasn't really properly loaded yet
There are likely other places that can blow up like this, but
```System.NullReferenceException: Object reference not set to an instance of an object.
at itemizer.ItemizerBlockBehavior.OnPickBlock(IWorldAccessor world, BlockPos pos, EnumHandling& handling) in D:\Documents\Developpement\_Vintage Story\vsmods_vscode\itemizer\itemizer\src\ItemizerBehavior.cs:line 138
at Vintagestory.API.Common.Block.OnPickBlock(IWorldAccessor world, BlockPos pos) in VintagestoryApi\Common\Collectible\Block\Block.cs:line 1267
at Vintagestory.GameContent.BlockMultiblock.<>c__DisplayClass16_0.<OnPickBlock>b__2(Block block) in VSEssentials\Block\BlockMultiblock.cs:line 229
at Vintagestory.GameContent.BlockMultiblock.Handle[T,K](IBlockAccessor ba, Int32 x, Int32 y, Int32 z, BlockCallDelegateInterface`2 onImplementsInterface, BlockCallDelegateBlock`1 onIsMultiblock, BlockCallDelegateBlock`1 onOtherwise) in VSEssentials\Block\BlockMultiblock.cs:line 91
at Vintagestory.GameContent.BlockMultiblock.OnPickBlock(IWorldAccessor world, BlockPos pos) in VSEssentials\Block\BlockMultiblock.cs:line 224
at Vintagestory.API.Common.Block.GetPlacedBlockName(IWorldAccessor world, BlockPos pos) in VintagestoryApi\Common\Collectible\Block\Block.cs:line 2199
at Vintagestory.Client.NoObf.HudElementBlockAndEntityInfo.ComposeBlockInfoHud() in VintagestoryLib\Client\Systems\Gui\Huds\HudElementBlockAndEntityInfo.cs:line 56
is being caused by these issues, and leaves players with no opertunity to change what they are looking at to something that isn't going to crash them