Ellpeck / ActuallyAdditions

A Minecraft Mod about lots of useful gadgets and things!
http://minecraft.curseforge.com/projects/actually-additions
MIT License
215 stars 99 forks source link

Item Interface's getSlots method is slow #1288

Closed TomyLobo closed 5 years ago

TomyLobo commented 5 years ago

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