So why not cache that value and return it whenever getSlots is called?
This became relevant when I attached an AA item interface to an Integrated Dynamics network.
ID's IngredientObserver alone used to query getSlots twice for every single slot(!) of each attached inventory.
See also this currently unreleased fix for the problem on ID's side: https://github.com/CyclopsMC/CommonCapabilitiesAPI/pull/7
The number of slots is already determined (and later discarded) here: https://github.com/Ellpeck/ActuallyAdditions/blob/master/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java#L197
So why not cache that value and return it whenever getSlots is called?
This became relevant when I attached an AA item interface to an Integrated Dynamics network. ID's IngredientObserver alone used to query getSlots twice for every single slot(!) of each attached inventory. See also this currently unreleased fix for the problem on ID's side: https://github.com/CyclopsMC/CommonCapabilitiesAPI/pull/7