JEI integration with crates
borg286 opened this issue ยท 9 comments
Would it be possible to integrate with JEI so that when the user searches for an item while having a crate open that the crate highlights items matching the query.
For large and medium crates the searched item may be found on a different window, requiring clicking left or right. It would be nice if that was already done for you if there are any matches.
Another option is to follow what Quark does and add an explicit search field between the user's inventory and the chest's inventory. I realize you have specifically reduced this space to optimize for more visible inventory. Is having a smaller font possible, or would it just be too crowded?
I've created a bug on JEI to add a callback feature: mezz/JustEnoughItems#1168
That may be the case. I'm happy to help you find the API that JEI may expose that would let you listen to queries the user is typing into jei.
Hrm. It doesn't seem like jei search field does any call outs to listeners: https://github.com/mezz/JustEnoughItems/blob/9fd168037c508d69354e9a8576758490346eb06f/src/main/java/mezz/jei/input/GuiTextFieldFilter.java#L55
That would be the way to go here. Add a listener to jei's text field, and do your own searches in your crate to highlight the item they searched for.
He seems against a callback for fear it would rely on his search bar as everyone's main text field, ie. becoming a honeypot for everyone wanting to do something different with their text field.
I'm tossing another proposal and will see if he likes it.
I'm doubting that JEI will let you get access to his search field, nor what the user typed in.
I've went barking up the tree of Extra utilities 2, to see if his "search nearby inventories" feature would somehow prioritize the item.
rwtema/Extra-Utilities-2-Source#44
This would solve it more generically, but due to the generality of my approach, I fear the idea will get shut down.
But the way that he gets user input is rather clever. Rather than having the user type in the name of an item, he expects the user to have already found the item he wants on the screen. By hovering your mouse over the item and pressing a hotkey then his code gets ran.
One proposal is to simply add a hotkey when users open your crates, and then move the screen to the page with that item and then have your UI highlight it.
Here is the meat of the code that gets items the user is hovering over
GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
if (guiScreen instanceof GuiContainer) {
GuiContainer guiContainer = (GuiContainer) guiScreen;
Slot slotUnderMouse = guiContainer.getSlotUnderMouse();
if (slotUnderMouse != null) {
ItemStack stack = slotUnderMouse.getStack();
if (StackHelper.isNonNull(stack)) {
return stack;
}
}
}
This functionality is already in JEI if you type the item you are searching for then double-click the search field it highlights the item or items from the search field and you can open various inventories with the search open, during the time it is in this mode the search bar outline becomes yellow. Note: you do need to page on the larger crates but functionality still works.