Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter argument to inventory list function #1785

Closed
RobertBouillon opened this issue Apr 10, 2024 · 2 comments
Closed

Add filter argument to inventory list function #1785

RobertBouillon opened this issue Apr 10, 2024 · 2 comments
Labels
area-Minecraft This affects CC's Minecraft-specific content. enhancement An extension of a feature or a new feature. wontfix A bug which I won't fix or an enhancement which won't be implemented.

Comments

@RobertBouillon
Copy link

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.

@RobertBouillon RobertBouillon added the enhancement An extension of a feature or a new feature. label Apr 10, 2024
@SquidDev
Copy link
Member

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.

@SquidDev SquidDev added the area-Minecraft This affects CC's Minecraft-specific content. label Apr 14, 2024
@SquidDev SquidDev added the wontfix A bug which I won't fix or an enhancement which won't be implemented. label May 26, 2024
@SquidDev
Copy link
Member

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.

@SquidDev SquidDev closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Minecraft This affects CC's Minecraft-specific content. enhancement An extension of a feature or a new feature. wontfix A bug which I won't fix or an enhancement which won't be implemented.
Projects
None yet
Development

No branches or pull requests

2 participants