diff --git a/src/main/java/codechicken/nei/BookmarkPanel.java b/src/main/java/codechicken/nei/BookmarkPanel.java index f8805f13..bdca7299 100644 --- a/src/main/java/codechicken/nei/BookmarkPanel.java +++ b/src/main/java/codechicken/nei/BookmarkPanel.java @@ -88,7 +88,6 @@ public class BookmarkPanel extends ItemPanel { realItems.add(stackA); metadata.add(meta); - needRefresh = true; } public void replaceItem(int idx, ItemStack stack) @@ -127,7 +126,6 @@ public class BookmarkPanel extends ItemPanel { realItems.remove(idx); metadata.remove(idx); - needRefresh = true; return true; } @@ -153,7 +151,6 @@ public class BookmarkPanel extends ItemPanel { realItems.add(dst, realItems.remove(src)); metadata.add(dst, metadata.remove(src)); - needRefresh = true; } @Override diff --git a/src/main/java/codechicken/nei/ItemPanel.java b/src/main/java/codechicken/nei/ItemPanel.java index 21922327..5c88bebe 100644 --- a/src/main/java/codechicken/nei/ItemPanel.java +++ b/src/main/java/codechicken/nei/ItemPanel.java @@ -14,7 +14,10 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; +import static codechicken.nei.LayoutManager.searchField; + import java.util.ArrayList; +import java.util.regex.Pattern; public class ItemPanel extends Widget { @@ -38,6 +41,8 @@ public class ItemPanel extends Widget @Deprecated public ArrayList realItems = new ArrayList<>(); + protected Pattern SPECIAL_REGEX_CHARS = Pattern.compile("[{}()\\[\\].+*?^$\\\\|]"); + public static class ItemPanelSlot { public ItemStack item; @@ -64,7 +69,6 @@ public class ItemPanel extends Widget public void setItems(ArrayList items) { newItems = items; - needRefresh = true; } public void refresh(GuiContainer gui) @@ -320,6 +324,10 @@ public class ItemPanel extends Widget return true; } + if (handleSearchInputClick(mouseX, mouseY, button)) { + return true; + } + if (handleGUIContainerClick(mouseX, mouseY, button)) { return true; } @@ -442,6 +450,24 @@ public class ItemPanel extends Widget return false; } + protected boolean handleSearchInputClick(int mouseX, int mouseY, int button) + { + + if (searchField.contains(mouseX, mouseY)) { + final FluidStack fluidStack = StackInfo.getFluid(draggedStack); + + if (fluidStack != null) { + searchField.setText(SPECIAL_REGEX_CHARS.matcher(fluidStack.getLocalizedName()).replaceAll("\\\\$0")); + } else { + searchField.setText(SPECIAL_REGEX_CHARS.matcher(draggedStack.getDisplayName()).replaceAll("\\\\$0")); + } + + return true; + } + + return false; + } + @Override public void mouseUp(int mousex, int mousey, int button) { ItemPanelSlot hoverSlot = getSlotMouseOver(mousex, mousey); diff --git a/src/main/java/codechicken/nei/ItemsGrid.java b/src/main/java/codechicken/nei/ItemsGrid.java index 700b4b3f..20dd5434 100644 --- a/src/main/java/codechicken/nei/ItemsGrid.java +++ b/src/main/java/codechicken/nei/ItemsGrid.java @@ -36,11 +36,6 @@ public class ItemsGrid protected boolean[] validSlotMap; protected boolean[] invalidSlotMap; - private int[] guiSize; - - protected boolean needRefresh = false; - - public ArrayList getItems() { return realItems; @@ -107,8 +102,6 @@ public class ItemsGrid columns = width / SLOT_SIZE; rows = height / SLOT_SIZE; - - needRefresh = true; } } @@ -134,51 +127,14 @@ public class ItemsGrid } page = Math.max(0, Math.min(page, numPages - 1)); - - needRefresh = true; } public void refresh(GuiContainer gui) { - if (!needRefresh(gui)) { - return; - } - updateGuiOverlapSlots(gui); shiftPage(0); - - needRefresh = false; } - private boolean needRefresh(GuiContainer gui) - { - - if (needRefresh == true) { - return true; - } - - if (gui == null && guiSize == null) { - return false; - } - - if (gui == null) { - guiSize = null; - return true; - } - - if (guiSize == null) { - guiSize = new int[]{ gui.guiLeft, gui.guiTop, gui.width, gui.height }; - return true; - } - - if (gui.guiLeft != guiSize[0] || gui.guiTop != guiSize[1] || gui.width != guiSize[2] || gui.height != guiSize[3]) { - guiSize = new int[]{ gui.guiLeft, gui.guiTop, gui.width, gui.height }; - return true; - } - - return false; - } - private void updateGuiOverlapSlots(GuiContainer gui) { invalidSlotMap = new boolean[rows * columns]; diff --git a/src/main/java/codechicken/nei/NEIClientUtils.java b/src/main/java/codechicken/nei/NEIClientUtils.java index 927e024f..da2545dc 100644 --- a/src/main/java/codechicken/nei/NEIClientUtils.java +++ b/src/main/java/codechicken/nei/NEIClientUtils.java @@ -157,7 +157,10 @@ public class NEIClientUtils extends NEIServerUtils final List> handlerSlots; try { GuiInfo.readLock.lock(); - handlerSlots = GuiInfo.guiHandlers.stream().map(handler -> handler.getItemSpawnSlots(gui, typestack)).collect(Collectors.toCollection(LinkedList::new)); + handlerSlots = GuiInfo.guiHandlers.stream() + .map(handler -> handler.getItemSpawnSlots(gui, typestack)) + .filter(x -> x != null) + .collect(Collectors.toCollection(LinkedList::new)); } finally { GuiInfo.readLock.unlock(); }