Add filter argument to inventory list function
RobertBouillon opened this issue · 2 comments
Update inventory.list()
to be inventory.list([filter])
, where filter is a JEI-like search string.
The main issue is performance when searching for items in large inventories by tag. Tags don't come back in the list by default, so you have to iterate through getItemDetail
. Presumably Lua is going to be slower than Java and there will be some marshalling overhead - this could be avoided if we could push the filtering functionality up into Java.
Tags don't come back in the list by default, so you have to iterate through
getItemDetail
It's worth noting that you can (and should!) cache getItemDetail
. In the case of tags, these will be unique for each item's name
1. More generally, the combination of name
and nbt
should uniquely determine all info returned by getItemDetail
.
Footnotes
-
Well, assuming datapacks or the mods do not change. ↩