crash prevention when failing to GetContents in CardRenderer

This commit is contained in:
2026-03-16 00:36:49 +01:00
parent d7c541fcc5
commit 074b34dd24

View File

@@ -117,8 +117,20 @@ internal class CardRenderer(ICoreClientAPI api, Config config) : IDisposable
if (heldBag == null) if (heldBag == null)
continue; continue;
ItemStack[]? bagContents;
try
{
bagContents = heldBag.GetContents(bagStack, api.World);
}
catch
{
continue;
}
if (bagContents == null)
continue;
contents = []; contents = [];
ItemStack[] bagContents = heldBag.GetContents(bagStack, api.World);
foreach (ItemStack contentStack in bagContents) foreach (ItemStack contentStack in bagContents)
{ {
if (contentStack == null || contentStack.StackSize <= 0) if (contentStack == null || contentStack.StackSize <= 0)