Feature Suggestion: Indexing
LasmGratel opened this issue ยท 6 comments
Pre-caching all recipes, ingredients defined in plugins like what JEI did
Hugely boosting up in-game searching and recipe lookup
(will be like a fully operational JEI backport)
Also the parallelization on search has massively sped this up, it's nearly as responsive as JEI; it's just missing the @mod <item>
but again, I prefer the regex search.
When playing GTNH on my laptop, there's still a delay of dozens milliseconds after clicking an item and before the recipes are shown. When I'm playing 1.12.2 modpacks as large as GTNH with JEI, the recipes are shown instantly (literally, without any noticeable delay).
Anyway, I respect developers' preference. However, you can implement the JEI-like algorithm via NEI's API, says, implementing Sorry, I've remembered something wrong. The API is for mathcing items, not for searching recipes.codechicken.nei.SearchField.ISearchProvider
with isPrimary()
returning true
, without touching codes in NEI itself. Be cautious, this will completely disable the item matcher provided by NEI, and you must load secondary ISearchProvider
s by yourself.
Oh... I believe mitchej has misread the issue after looking around the code again. The regex is used for matching/searching the items according to the text players typed in the textbox. But what the issue about is searching the recipes according to the item players clicked at. We need to refactor the TemplateRecipeHandle#loadCraftingRecipes
method (called by TemplateRecipeHandle#getRecipeHandler
) with some preloaded indexes to get rid of the delay.
I just realized that NEI leaves the recipe searching functionalities to be implemented by those mods registering recipe handlers. JEI use a registry that holds all recipes so that it can accelerate by indexing. But in NEI, there's no way to get all recipes from a handler because the API does not define such methods. This's an issue come with NEI's design. Therefore, it's impossible to make NEI as fast as JEI theoretically... ๐ฃ
The only thing we can do is parallizing the handlers like item filters. I'll try it later.