From 17fe54dfea4f21cdc863cd5bdfc5c3820929a5fc Mon Sep 17 00:00:00 2001 From: Zeffuro Date: Fri, 20 Feb 2026 23:36:37 +0100 Subject: [PATCH] Fix blocked items --- AetherBags/Addons/AddonInventoryWindow.cs | 3 +- .../Context/InventoryContextState.cs | 29 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/AetherBags/Addons/AddonInventoryWindow.cs b/AetherBags/Addons/AddonInventoryWindow.cs index 2f9a228..1756ac1 100644 --- a/AetherBags/Addons/AddonInventoryWindow.cs +++ b/AetherBags/Addons/AddonInventoryWindow.cs @@ -179,8 +179,9 @@ public unsafe class AddonInventoryWindow : InventoryAddonBase protected override void OnFinalize(AtkUnitBase* addon) { + IsSetupComplete = false; _lootedCategoryNode?.Dispose(); - + System.LootedItemsTracker.OnLootedItemsChanged -= OnLootedItemsChanged; ref var blockingAddonId = ref AgentInventoryContext.Instance()->BlockingAddonId; diff --git a/AetherBags/Inventory/Context/InventoryContextState.cs b/AetherBags/Inventory/Context/InventoryContextState.cs index 1f1e8d6..0d96179 100644 --- a/AetherBags/Inventory/Context/InventoryContextState.cs +++ b/AetherBags/Inventory/Context/InventoryContextState.cs @@ -120,15 +120,32 @@ public static unsafe class InventoryContextState var inventoryManager = InventoryManager.Instance(); if (inventoryManager == null) return; - var blockedContainer = inventoryManager->GetInventoryContainer(InventoryType.BlockedItems); - if (blockedContainer == null) return; + ScanBlockedContainer(inventoryManager, InventoryType.BlockedItems); + ScanBlockedContainer(inventoryManager, InventoryType.MailEdit); + } - for (int i = 0; i < blockedContainer->Size; i++) + private static void ScanBlockedContainer(InventoryManager* inventoryManager, InventoryType type) + { + try { - ref var item = ref blockedContainer->Items[i]; - if (item.ItemId == 0) continue; + var container = inventoryManager->GetInventoryContainer(type); + if (container == null) return; + if (container->GetSize() == 0) return; + if (!container->IsLoaded) return; + if (container->Items == null) return; - BlockedSlots.Add((item.Container, item.Slot)); + for (int i = 0; i < container->GetSize(); i++) + { + var slot = container->GetInventorySlot(i); + if (slot == null) continue; + if (slot->GetItemId() == 0) continue; + + BlockedSlots.Add((slot->Container, slot->Slot)); + } + } + catch + { + // Container became invalid during teardown } }