Query itemstack of an open inventory on inventory click

I’m not sure exactly what the issue is but I am unable to query an open custom inventory with the SlotIndex property. On inventory click I am retrieving the slot index with

SlotTransaction transaction = transactions.get(0); Slot slot = transaction.getSlot(); Optional<SlotIndex> slotIndex = slot.getInventoryProperty(SlotIndex.class);

When getting the clicked slot it returns the expected result of 0 for the first slot, 1 for the second etc. However when I try to retrieve the inventory with a query the itemstack is not present.

Optional<ItemStack> item = this.getInventory().query(QueryOperationTypes.INVENTORY_PROPERTY.of(SlotIndex.of(index))).peek();
The inventory that the query is referring to is from on click where the clicked slot is transformed and then the parent method is called.

Inventory inventory = slot.transform().parent();

Please let me know if this issue is not clear enough or if you need additional details as I am not very familiar with the SpongeAPI.

When doing GUI inventory stuff I recommend TeslaLibs / on Ore.

Btw that’s how it is done there.