diff --git a/src/main/java/codechicken/nei/BookmarkPanel.java b/src/main/java/codechicken/nei/BookmarkPanel.java index 0422c0357..035583878 100644 --- a/src/main/java/codechicken/nei/BookmarkPanel.java +++ b/src/main/java/codechicken/nei/BookmarkPanel.java @@ -21,12 +21,12 @@ import javax.annotation.Nullable; +import static codechicken.nei.NEIClientUtils.translate; import static codechicken.lib.gui.GuiDraw.getMousePosition; import static codechicken.lib.gui.GuiDraw.drawRect; import java.awt.Point; import java.io.File; -import java.io.FileReader; import java.io.InputStream; import java.io.OutputStream; import java.io.FileInputStream; @@ -52,7 +52,7 @@ public class BookmarkPanel extends PanelWidget public Label namespaceLabel; - protected ArrayList namespaces = new ArrayList<>(); + protected List namespaces = new ArrayList<>(); protected int activeNamespaceIndex = 0; @@ -74,10 +74,152 @@ public BookmarkStackMeta(BookmarkRecipeId recipeId, int count, boolean ingredien } + public static enum BookmarkViewMode + { + DEFAULT, TODO_LIST + } + protected static class BookmarkGrid extends ItemsGrid { + + protected List> gridMask; protected List metadata = new ArrayList<>(); + protected BookmarkViewMode viewMode = BookmarkViewMode.DEFAULT; + protected boolean[] todoSpaces; + protected int todoItemsCount = 0; + + public void setViewMode(BookmarkViewMode mode) + { + if (viewMode == mode) { + return; + } + + viewMode = mode; + + if (mode == BookmarkViewMode.DEFAULT) { + sortIngredients(false); + todoItemsCount = 0; + gridMask = null; + } + + onGridChanged(); + } + + public BookmarkViewMode getViewMode() + { + return viewMode; + } + + @Override + public int getNumPages() + { + if (gridMask != null) { + return gridMask.size(); + } + + return super.getNumPages(); + } + + @Override + protected List getMask() + { + if (gridMask != null) { + return gridMask.size() > page? gridMask.get(page): new ArrayList<>(); + } + + return super.getMask(); + } + + private void sortIngredients(final boolean forward) + { + BookmarkStackMeta meta; + int dir = forward? 1: -1; + + for (int i = 0; i < realItems.size(); i++) { + meta = metadata.get(i); + + if (meta.recipeId != null && !meta.ingredient) { + int shift = 0; + + for (int j = i + 1; j < realItems.size(); j++) { + if (meta.recipeId.equals(metadata.get(j).recipeId)) { + if (i + shift + dir != j) { + realItems.add(i + shift + Math.max(dir, 0), realItems.remove(j)); + metadata.add(i + shift + Math.max(dir, 0), metadata.remove(j)); + } + shift++; + } + } + + for (int j = i + shift - 1; j >= 0; j--) { + if (meta.recipeId.equals(metadata.get(j).recipeId)) { + if (i + shift + dir != j) { + realItems.add(i + shift + Math.min(dir, 0), realItems.remove(j)); + metadata.add(i + shift + Math.min(dir, 0), metadata.remove(j)); + } + shift--; + } + } + + i += Math.max(0, shift); + } + + } + + } + + private void generateToDoSpaces() + { + todoItemsCount = 0; + gridMask = new ArrayList<>(); + + if (rows * columns == 0) { + return; + } + + BookmarkStackMeta meta; + int size = size(); + int idx = 0; + + while (idx < size) { + ArrayList pmask = new ArrayList<>(); + + for (int i = 0, perPage = rows * columns; i < perPage && idx < size; i++) { + if (isInvalidSlot(i)) { + pmask.add(null); + } else { + meta = getMetadata(idx); + + if (idx > 0 && ((i % columns) == 0) == (meta.recipeId != null && meta.ingredient && meta.recipeId.equals(getRecipeId(idx - 1)))) { + pmask.add(null); + } else { + pmask.add(idx++); + + if ((i % columns) == 0) { + todoItemsCount++; + } + } + + } + } + + gridMask.add(pmask); + } + + } + + protected void onGridChanged() + { + super.onGridChanged(); + + if (getViewMode() == BookmarkViewMode.TODO_LIST) { + sortIngredients(true); + generateToDoSpaces(); + } + + } + public int indexOf(ItemStack stackA, BookmarkRecipeId recipeId) { final boolean useNBT = NEIClientConfig.useNBTInBookmarks(); @@ -101,20 +243,20 @@ public void addItem(ItemStack stackA, BookmarkStackMeta meta) { realItems.add(stackA); metadata.add(meta); - refreshBuffer = true; + onGridChanged(); } public void replaceItem(int idx, ItemStack stack) { realItems.set(idx, stack); - refreshBuffer = true; + onGridChanged(); } public void removeRecipe(int idx, boolean removeFullRecipe) { final BookmarkStackMeta meta = getMetadata(idx); - if (removeFullRecipe && meta.recipeId != null) { + if (meta.recipeId != null && (removeFullRecipe || !meta.ingredient)) { removeRecipe(meta.recipeId); } else { removeItem(idx); @@ -141,7 +283,7 @@ protected boolean removeItem(int idx) { realItems.remove(idx); metadata.remove(idx); - refreshBuffer = true; + onGridChanged(); return true; } @@ -167,23 +309,26 @@ public void moveItem(int src, int dst) { realItems.add(dst, realItems.remove(src)); metadata.add(dst, metadata.remove(src)); - refreshBuffer = true; + onGridChanged(); } - private boolean isPartOfFocusedRecipe(ItemPanelSlot focused, int myIdx) { - return (NEIClientUtils.shiftKey() - && LayoutManager.bookmarkPanel.sortedStackIndex == -1 + private boolean isPartOfFocusedRecipe(ItemPanelSlot focused, int myIdx) + { + return NEIClientUtils.shiftKey() && focused != null + && LayoutManager.bookmarkPanel.sortedStackIndex == -1 && getRecipeId(focused.slotIndex) != null && getRecipeId(myIdx) != null - && getRecipeId(focused.slotIndex).equals(getRecipeId(myIdx))); + && getRecipeId(focused.slotIndex).equals(getRecipeId(myIdx)); } @Override - protected void drawSlotOutline(@Nullable ItemPanelSlot focus, int idx, Rectangle4i rect) { - if(LayoutManager.bookmarkPanel.sortedNamespaceIndex == LayoutManager.bookmarkPanel.activeNamespaceIndex && LayoutManager.bookmarkPanel.sortedStackIndex == idx) { + protected void drawSlotOutline(@Nullable ItemPanelSlot focus, int idx, Rectangle4i rect) + { + + if (LayoutManager.bookmarkPanel.sortedNamespaceIndex == LayoutManager.bookmarkPanel.activeNamespaceIndex && LayoutManager.bookmarkPanel.sortedStackIndex == idx) { drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555);//highlight - } else if(focus != null) { + } else if (focus != null) { BookmarkStackMeta meta = getMetadata(idx); if (isPartOfFocusedRecipe(focus, idx)) { drawRect(rect.x, rect.y, rect.w, rect.h, meta.ingredient? 0x88b3b300: 0x88009933);//highlight recipe @@ -283,7 +428,13 @@ public String getRenderLabel() @Override public String getLabelText() { - return String.format("(%d/%d) [%d]", getPage(), Math.max(1, getNumPages()), grid.size()); + int size = grid.size(); + + if (((BookmarkGrid) grid).getViewMode() == BookmarkViewMode.TODO_LIST) { + size = ((BookmarkGrid) grid).todoItemsCount; + } + + return String.format("(%d/%d) [%d]", getPage(), Math.max(1, getNumPages()), size); } @@ -325,7 +476,7 @@ public void addOrRemoveItem(ItemStack stackover, String handlerName, List 0) { - strings.add("");//namespace separator; ignore first namespace - } + JsonObject settings = new JsonObject(); + settings.add("viewmode", new JsonPrimitive(grid.getViewMode().toString())); + settings.add("active", new JsonPrimitive(activeNamespaceIndex == grpIdx)); + strings.add("; " + NBTJson.toJson(settings)); for (int idx = 0; idx < grid.size(); idx++) { @@ -579,19 +730,34 @@ public void loadBookmarksIfNeeded() namespaces.clear(); namespaces.add(new BookmarkGrid()); - activeNamespaceIndex = 0; + activeNamespaceIndex = -1; final JsonParser parser = new JsonParser(); + int namespaceIndex = 0; for (String itemStr: itemStrings) { + try { if (itemStr.isEmpty()) { + itemStr = "; {}"; + } + + if (itemStr.startsWith("; ")) { + JsonObject settings = parser.parse(itemStr.substring(2)).getAsJsonObject(); - if (namespaces.get(activeNamespaceIndex).size() > 0) { + if (namespaces.get(namespaceIndex).size() > 0) { //do not create empty namespaces namespaces.add(new BookmarkGrid()); - activeNamespaceIndex++; + namespaceIndex++; + } + + if (settings.get("viewmode") != null) { + namespaces.get(namespaceIndex).setViewMode(BookmarkViewMode.valueOf(settings.get("viewmode").getAsString())); + } + + if (settings.get("active") != null && settings.get("active").getAsBoolean()) { + activeNamespaceIndex = namespaceIndex; } continue; @@ -615,7 +781,7 @@ public void loadBookmarksIfNeeded() if (itemStack != null) { - namespaces.get(activeNamespaceIndex).addItem(itemStack, new BookmarkStackMeta( + namespaces.get(namespaceIndex).addItem(itemStack, new BookmarkStackMeta( recipeId, jsonObject.has("factor")? jsonObject.get("factor").getAsInt(): 0, jsonObject.has("ingredient")? jsonObject.get("ingredient").getAsBoolean(): false, @@ -630,8 +796,8 @@ public void loadBookmarksIfNeeded() } } - if (namespaces.get(activeNamespaceIndex).size() == 0) { - activeNamespaceIndex = Math.max(activeNamespaceIndex - 1, 0); + if (activeNamespaceIndex == -1) { + activeNamespaceIndex = namespaceIndex; } grid = namespaces.get(activeNamespaceIndex); @@ -651,7 +817,7 @@ protected int resizeHeader(GuiContainer gui) { final LayoutStyleMinecraft layout = (LayoutStyleMinecraft) LayoutManager.getLayoutStyle(); final int rows = (int) Math.ceil((double) layout.buttonCount / layout.numButtons); - final int diff = rows * 18 + getMarginTop(gui) - y; + final int diff = rows * BookmarkGrid.SLOT_SIZE + getMarginTop(gui) - y; if (diff > 0) { y += diff; @@ -754,7 +920,7 @@ protected ItemStack getDraggedStackWithQuantity(int mouseDownSlot) return NEIServerUtils.copyStack(stack, amount); } - + @Override public void mouseDragged(int mousex, int mousey, int button, long heldTime) { @@ -768,37 +934,59 @@ public void mouseDragged(int mousex, int mousey, int button, long heldTime) if (stack != null && (mouseOverSlot == null || mouseOverSlot.slotIndex != mouseDownSlot || heldTime > 250)) { sortedNamespaceIndex = activeNamespaceIndex; sortedStackIndex = mouseDownSlot; - grid.refreshBuffer = true; + grid.onGridChanged(); } } else { - if (mouseOverSlot == null && sortedNamespaceIndex != activeNamespaceIndex) { - mouseOverSlot = getNextSlot(mousex, mousey); - } - - if (mouseOverSlot != null) { + if (sortedNamespaceIndex != activeNamespaceIndex) { + final BookmarkGrid hoverGrid = namespaces.get(activeNamespaceIndex); + final BookmarkGrid sortedGrid = namespaces.get(sortedNamespaceIndex); + + if (mouseOverSlot == null) { + mouseOverSlot = getNextSlot(mousex, mousey, hoverGrid.getViewMode() == BookmarkViewMode.TODO_LIST); + } + + if (mouseOverSlot != null) { + final ItemStack stack = sortedGrid.getItem(sortedStackIndex); + final BookmarkStackMeta meta = sortedGrid.getMetadata(sortedStackIndex); + + sortedGrid.removeItem(sortedStackIndex); + hoverGrid.addItem(stack, meta); - if (sortedNamespaceIndex != activeNamespaceIndex) { - BookmarkGrid BGrid = namespaces.get(sortedNamespaceIndex); - BookmarkStackMeta meta = BGrid.getMetadata(sortedStackIndex); - ItemStack stack = BGrid.getItem(sortedStackIndex); - BGrid.removeItem(sortedStackIndex); - - ((BookmarkGrid) grid).addItem(stack, meta); - sortedNamespaceIndex = activeNamespaceIndex; - sortedStackIndex = grid.size() - 1; + sortedStackIndex = hoverGrid.indexOf(stack, meta.recipeId); } - if (mouseOverSlot.slotIndex != sortedStackIndex) { - ((BookmarkGrid) grid).moveItem(sortedStackIndex, mouseOverSlot.slotIndex); + } else if (mouseOverSlot == null || mouseOverSlot.slotIndex != sortedStackIndex) { + final BookmarkGrid sortedGrid = namespaces.get(sortedNamespaceIndex); + + if (mouseOverSlot != null && sortedGrid.getViewMode() == BookmarkViewMode.DEFAULT) { + sortedGrid.moveItem(sortedStackIndex, mouseOverSlot.slotIndex); sortedStackIndex = mouseOverSlot.slotIndex; + } else if (sortedGrid.getViewMode() == BookmarkViewMode.TODO_LIST) { + final ItemStack stack = sortedGrid.getItem(sortedStackIndex); + final BookmarkStackMeta meta = sortedGrid.getMetadata(sortedStackIndex); + final boolean isIngredient = sortedStackIndex > 0 && meta.recipeId != null && meta.ingredient && meta.recipeId.equals(sortedGrid.getRecipeId(sortedStackIndex - 1)); + + if (!isIngredient) { + mouseOverSlot = getSlotMouseOver(grid.marginLeft + grid.paddingLeft, mousey); + + if (mouseOverSlot != null && sortedStackIndex != mouseOverSlot.slotIndex) { + sortedGrid.moveItem(sortedStackIndex, mouseOverSlot.slotIndex); + sortedStackIndex = sortedGrid.indexOf(stack, meta.recipeId); + } + + } else if (mouseOverSlot != null && meta.recipeId != null && sortedGrid.getMetadata(mouseOverSlot.slotIndex).ingredient && meta.recipeId.equals(sortedGrid.getRecipeId(mouseOverSlot.slotIndex))) { + sortedGrid.moveItem(sortedStackIndex, mouseOverSlot.slotIndex); + sortedStackIndex = sortedGrid.indexOf(stack, meta.recipeId); + } + } - + } - } + } return; } @@ -806,22 +994,21 @@ public void mouseDragged(int mousex, int mousey, int button, long heldTime) super.mouseDragged(mousex, mousey, button, heldTime); } - private ItemPanelSlot getNextSlot(int mousex, int mousey) + private ItemPanelSlot getNextSlot(int mousex, int mousey, boolean line) { - int idx = grid.getPage() * grid.getPerPage() - grid.getPerPage(); - int gSize = grid.size(); - - for (int i = 0; i < grid.getRows() * grid.getColumns() && idx <= gSize; i++) { + final List mask = grid.getMask(); + final int columns = grid.getColumns(); + final int perPage = grid.getRows() * columns; - if (!grid.isInvalidSlot(i)) { + for (int i = mask.size(); i < perPage; i++) { + if (!grid.isInvalidSlot(i) && (!line || (i % columns) == 0)) { - if (idx == gSize && grid.getSlotRect(i).contains(mousex, mousey)) { - return new ItemPanelSlot(idx, null); + if (grid.getSlotRect(i).contains(mousex, mousey)) { + return new ItemPanelSlot(grid.size() - 1, null); } - idx++; + return null; } - } return null; @@ -840,6 +1027,37 @@ public void postDraw(int mousex, int mousey) super.postDraw(mousex, mousey); } + @Override + public boolean handleClickExt(int mousex, int mousey, int button) + { + + if (new Rectangle4i(pagePrev.x + pagePrev.w, pagePrev.y, pageNext.x - (pagePrev.x + pagePrev.w), pagePrev.h).contains(mousex, mousey)) { + final BookmarkGrid BGrid = (BookmarkGrid)grid; + + if (BGrid.getViewMode() == BookmarkViewMode.DEFAULT) { + BGrid.setViewMode(BookmarkViewMode.TODO_LIST); + } else { + BGrid.setViewMode(BookmarkViewMode.DEFAULT); + } + + saveBookmarks(); + return true; + } else { + return super.handleClickExt(mousex, mousey, button); + } + + } + + @Override + public List handleTooltip(int mx, int my, List tooltip) + { + + if (new Rectangle4i(pagePrev.x + pagePrev.w, pagePrev.y, pageNext.x - (pagePrev.x + pagePrev.w), pagePrev.h).contains(mx, my)) { + tooltip.add(translate("bookmark.viewmode.toggle.tip")); + } + + return super.handleTooltip(mx, my, tooltip); + } @Override public void mouseUp(int mousex, int mousey, int button) @@ -849,7 +1067,7 @@ public void mouseUp(int mousex, int mousey, int button) sortedNamespaceIndex = -1; sortedStackIndex = -1; mouseDownSlot = -1; - grid.refreshBuffer = true; /* make sure grid redraws the new item */ + grid.onGridChanged(); /* make sure grid redraws the new item */ saveBookmarks(); } else { super.mouseUp(mousex, mousey, button); @@ -868,6 +1086,7 @@ public boolean onMouseWheel(int shift, int mousex, int mousey) nextNamespace(); } + saveBookmarks(); return true; } @@ -900,7 +1119,6 @@ public boolean onMouseWheel(int shift, int mousex, int mousey) shiftStackSize(slot.slotIndex, shift); saveBookmarks(); - return true; } diff --git a/src/main/java/codechicken/nei/ItemPanel.java b/src/main/java/codechicken/nei/ItemPanel.java index 9b717ae75..5fdd64749 100644 --- a/src/main/java/codechicken/nei/ItemPanel.java +++ b/src/main/java/codechicken/nei/ItemPanel.java @@ -69,7 +69,7 @@ public void refresh(GuiContainer gui) if (newItems != null) { realItems = newItems; newItems = null; - refreshBuffer = true; + onGridChanged(); } super.refresh(gui); diff --git a/src/main/java/codechicken/nei/ItemsGrid.java b/src/main/java/codechicken/nei/ItemsGrid.java index f42d0515c..e7f942270 100644 --- a/src/main/java/codechicken/nei/ItemsGrid.java +++ b/src/main/java/codechicken/nei/ItemsGrid.java @@ -17,6 +17,7 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import static codechicken.lib.gui.GuiDraw.drawRect; @@ -37,13 +38,9 @@ public class ItemsGrid protected int page; protected int perPage; - protected int firstIndex; - protected int numPages; - protected int rows; protected int columns; - protected boolean[] validSlotMap; protected boolean[] invalidSlotMap; @Nullable @@ -89,7 +86,11 @@ public int getPerPage() public int getNumPages() { - return numPages; + if (perPage > 0) { + return (int) Math.ceil((float) realItems.size() / (float) perPage); + } + + return 0; } public int getRows() @@ -104,9 +105,6 @@ public int getColumns() public void setGridSize(int mleft, int mtop, int w, int h) { - if(width != w || height != h || mleft != marginLeft || mtop != marginTop) - refreshBuffer = true; - marginLeft = mleft; marginTop = mtop; @@ -122,13 +120,12 @@ public void setGridSize(int mleft, int mtop, int w, int h) public void shiftPage(int shift) { if (perPage == 0) { - numPages = 0; page = 0; return; } - numPages = (int) Math.ceil((float) realItems.size() / (float) perPage); - + final int numPages = getNumPages(); + final int oldPage = page; page += shift; if (page >= numPages) { @@ -140,8 +137,15 @@ public void shiftPage(int shift) } page = Math.max(0, Math.min(page, numPages - 1)); - if(shift != 0) - refreshBuffer = true; + + if (page != oldPage) { + onGridChanged(); + } + } + + protected void onGridChanged() + { + refreshBuffer = true; } public void refresh(GuiContainer gui) @@ -150,17 +154,22 @@ public void refresh(GuiContainer gui) shiftPage(0); } - private void updateGuiOverlapSlots(GuiContainer gui) + protected void updateGuiOverlapSlots(GuiContainer gui) { - boolean[] oldSlotMap = invalidSlotMap; + final boolean[] oldSlotMap = invalidSlotMap; + final int oldRows = rows; + final int oldColumns = columns; + invalidSlotMap = new boolean[rows * columns]; perPage = columns * rows; checkGuiOverlap(gui, 0, columns - 2, 1); checkGuiOverlap(gui, columns - 1, 1, -1); - if(NEIClientConfig.shouldCacheItemRendering() && !Arrays.equals(oldSlotMap, invalidSlotMap)) { - refreshBuffer = true; + + if (oldRows != rows || oldColumns != columns || !Arrays.equals(oldSlotMap, invalidSlotMap)) { + onGridChanged(); } + } private void checkGuiOverlap(GuiContainer gui, int start, int end, int dir) @@ -194,29 +203,45 @@ public Rectangle4i getSlotRect(int row, int column) return new Rectangle4i(marginLeft + paddingLeft + column * SLOT_SIZE, marginTop + row * SLOT_SIZE, SLOT_SIZE, SLOT_SIZE); } - public boolean isInvalidSlot(int idx) + public boolean isInvalidSlot(int index) { - return invalidSlotMap[idx]; + return invalidSlotMap[index]; } - private void drawSlotOutlines(int mousex, int mousey) + protected List getMask() { - ItemPanelSlot focused = getSlotMouseOver(mousex, mousey); + List mask = new ArrayList<>(); + int idx = page * perPage; for (int i = 0; i < rows * columns && idx < size(); i++) { - if(!invalidSlotMap[i]) { - drawSlotOutline(focused, idx, getSlotRect(i)); - idx++; + mask.add(isInvalidSlot(i)? null: idx++); + } + + return mask; + } + + private void drawSlotOutlines(int mousex, int mousey) + { + ItemPanelSlot focused = getSlotMouseOver(mousex, mousey); + final List mask = getMask(); + + for (int i = 0; i < mask.size(); i++) { + if (mask.get(i) != null) { + drawSlotOutline(focused, mask.get(i), getSlotRect(i)); } } + } - protected void drawSlotOutline(@Nullable ItemPanelSlot focused, int slotIdx, Rectangle4i rect) { - if(focused != null && focused.slotIndex == slotIdx) + protected void drawSlotOutline(@Nullable ItemPanelSlot focused, int slotIdx, Rectangle4i rect) + { + if (focused != null && focused.slotIndex == slotIdx) { drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555);//highlight + } } - private void blitExistingBuffer() { + private void blitExistingBuffer() + { Minecraft minecraft = Minecraft.getMinecraft(); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -241,7 +266,7 @@ public void draw(int mousex, int mousey) } boolean shouldCache = NEIClientConfig.shouldCacheItemRendering() && !PresetsWidget.inEditMode(); - if(shouldCache) { + if (shouldCache) { Minecraft minecraft = Minecraft.getMinecraft(); if (framebuffer == null) { framebuffer = new Framebuffer(minecraft.displayWidth, minecraft.displayHeight, true); @@ -269,11 +294,10 @@ public void draw(int mousex, int mousey) GuiContainerManager.enableMatrixStackLogging(); - int idx = page * perPage; - for (int i = 0; i < rows * columns && idx < size(); i++) { - if (!invalidSlotMap[i]) { - drawItem(getSlotRect(i), idx); - idx ++; + final List mask = getMask(); + for (int i = 0; i < mask.size(); i++) { + if (mask.get(i) != null) { + drawItem(getSlotRect(i), mask.get(i)); } } @@ -300,19 +324,21 @@ public ItemPanelSlot getSlotMouseOver(int mousex, int mousey) final int overRow = (int) ((mousey - marginTop) / SLOT_SIZE); final int overColumn = (int) ((mousex - marginLeft - paddingLeft) / SLOT_SIZE); final int slt = columns * overRow + overColumn; - int idx = page * perPage + slt; if (overRow >= rows || overColumn >= columns) { return null; } - for (int i = 0; i < slt; i++) { - if (invalidSlotMap[i]) { - idx--; - } + final List mask = getMask(); + + if (mask.size() > slt && mask.get(slt) != null) { + final int idx = mask.get(slt); + final ItemStack stack = getItem(idx).copy(); + + return new ItemPanelSlot(idx, stack); } - return idx < size()? new ItemPanelSlot(idx, realItems.get(idx)): null; + return null; } public boolean contains(int px, int py) @@ -326,7 +352,7 @@ public boolean contains(int px, int py) final int c = (int) ((px - marginLeft - paddingLeft) / SLOT_SIZE); final int slt = columns * r + c; - return r >= rows || c >= columns || !invalidSlotMap[slt]; + return r >= rows || c >= columns || !isInvalidSlot(slt); } } \ No newline at end of file diff --git a/src/main/java/codechicken/nei/PanelWidget.java b/src/main/java/codechicken/nei/PanelWidget.java index 7033a5030..67ec2c0e4 100644 --- a/src/main/java/codechicken/nei/PanelWidget.java +++ b/src/main/java/codechicken/nei/PanelWidget.java @@ -358,12 +358,14 @@ public ItemPanelSlot getSlotMouseOver(int mousex, int mousey) return grid.getSlotMouseOver(mousex, mousey); } - public int getPage() { - return grid.page + 1; + public int getPage() + { + return grid.getPage(); } - public int getNumPages() { - return grid.numPages; + public int getNumPages() + { + return grid.getNumPages(); } @Override diff --git a/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java b/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java index e848cdd9b..f9830ff20 100644 --- a/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java +++ b/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java @@ -1,6 +1,5 @@ package codechicken.nei.recipe; -import codechicken.lib.gui.GuiDraw; import codechicken.nei.ItemPanels; import codechicken.nei.LayoutManager; import codechicken.nei.NEIClientConfig; @@ -11,7 +10,6 @@ import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; -import java.awt.*; import java.util.List; public class RecipeItemInputHandler implements IContainerInputHandler { diff --git a/src/main/resources/assets/nei/lang/en_US.lang b/src/main/resources/assets/nei/lang/en_US.lang index 0a989daaf..da5de4766 100644 --- a/src/main/resources/assets/nei/lang/en_US.lang +++ b/src/main/resources/assets/nei/lang/en_US.lang @@ -8,6 +8,7 @@ nei.key.ctrl.mac=CMD nei.bookmark.toggle=Bookmarks nei.bookmark.toggle.tip=Toggle visibility of the Bookmark Panel +nei.bookmark.viewmode.toggle.tip=Toggle Bookmark View Mode nei.enchant=Enchant nei.enchant.level=Level