CC: Tweaked

CC: Tweaked

42M Downloads

Add filter argument to inventory list function

RobertBouillon opened this issue · 2 comments

commented

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.

commented

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 name1. More generally, the combination of name and nbt should uniquely determine all info returned by getItemDetail.

Footnotes

  1. Well, assuming datapacks or the mods do not change.

commented

Having spent some time thinking about this, I'm afraid I'm going to mark this as wontfix. I like the current simplicity of the inventory storage API, and don't think this brings any significant benefits.