From c55991f5e0bfdf2db094347df49ee516284e3df9 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 27 Nov 2015 16:48:01 +0100 Subject: [PATCH] Adjusted page display in NEI handler a bit --- .../nei/INeiRecipeHandler.java | 4 ++-- .../nei/NEIBookletRecipe.java | 4 ++-- .../nei/NEIREconstructorRecipe.java | 5 +++-- .../nei/NeiScreenEvents.java | 19 ++++++++----------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/nei/INeiRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/INeiRecipeHandler.java index b11fafa3c..7982fc2ea 100644 --- a/src/main/java/ellpeck/actuallyadditions/nei/INeiRecipeHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/nei/INeiRecipeHandler.java @@ -10,9 +10,9 @@ package ellpeck.actuallyadditions.nei; -import net.minecraft.item.ItemStack; +import ellpeck.actuallyadditions.booklet.page.BookletPage; public interface INEIRecipeHandler{ - ItemStack getStackForInfo(int page); + BookletPage getPageForInfo(int neiIndex); } diff --git a/src/main/java/ellpeck/actuallyadditions/nei/NEIBookletRecipe.java b/src/main/java/ellpeck/actuallyadditions/nei/NEIBookletRecipe.java index 5644035c6..0e6cb640b 100644 --- a/src/main/java/ellpeck/actuallyadditions/nei/NEIBookletRecipe.java +++ b/src/main/java/ellpeck/actuallyadditions/nei/NEIBookletRecipe.java @@ -118,8 +118,8 @@ public class NEIBookletRecipe extends TemplateRecipeHandler implements INEIRecip for(int i = 0; i < Math.min(maxLines, text.size()); i++){ GuiDraw.drawString(text.get(i)+(i == maxLines-1 && text.size() > maxLines ? EnumChatFormatting.RESET+""+EnumChatFormatting.BLACK+"..." : ""), 0, 18+25+i*(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT+1), 0, false); } - GuiDraw.drawString(EnumChatFormatting.GOLD+chapter.getLocalizedName(), 0, 95, 0, false); - GuiDraw.drawString(EnumChatFormatting.GOLD+"Page "+stack.thePage.getID(), 0, 105, 0, false); + GuiDraw.drawString(EnumChatFormatting.ITALIC+chapter.getLocalizedName(), 0, 97, 0, false); + GuiDraw.drawString(EnumChatFormatting.ITALIC+"Page "+stack.thePage.getID(), 0, 107, 0, false); } } diff --git a/src/main/java/ellpeck/actuallyadditions/nei/NEIREconstructorRecipe.java b/src/main/java/ellpeck/actuallyadditions/nei/NEIREconstructorRecipe.java index cbaef4c9c..a1a573167 100644 --- a/src/main/java/ellpeck/actuallyadditions/nei/NEIREconstructorRecipe.java +++ b/src/main/java/ellpeck/actuallyadditions/nei/NEIREconstructorRecipe.java @@ -15,6 +15,7 @@ import codechicken.nei.PositionedStack; import codechicken.nei.recipe.RecipeInfo; import codechicken.nei.recipe.TemplateRecipeHandler; import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.booklet.BookletUtils; import ellpeck.actuallyadditions.booklet.page.BookletPage; import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler; import ellpeck.actuallyadditions.util.ItemUtil; @@ -41,8 +42,8 @@ public class NEIReconstructorRecipe extends TemplateRecipeHandler implements INE } @Override - public ItemStack getStackForInfo(int page){ - return new ItemStack(InitBlocks.blockAtomicReconstructor); + public BookletPage getPageForInfo(int page){ + return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockAtomicReconstructor)); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/nei/NeiScreenEvents.java b/src/main/java/ellpeck/actuallyadditions/nei/NeiScreenEvents.java index 975682327..a3e587862 100644 --- a/src/main/java/ellpeck/actuallyadditions/nei/NeiScreenEvents.java +++ b/src/main/java/ellpeck/actuallyadditions/nei/NeiScreenEvents.java @@ -17,7 +17,6 @@ import ellpeck.actuallyadditions.booklet.BookletUtils; import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.InitBooklet; import ellpeck.actuallyadditions.booklet.page.BookletPage; -import ellpeck.actuallyadditions.util.ItemUtil; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.StringUtil; import net.minecraft.client.Minecraft; @@ -52,7 +51,7 @@ public class NEIScreenEvents{ event.buttonList.add(this.neiButton); IRecipeHandler handler = theGui.getCurrentRecipeHandlers().get(theGui.recipetype); - this.neiButton.visible = handler instanceof INEIRecipeHandler && ((INEIRecipeHandler)handler).getStackForInfo(theGui.page) != null; + this.neiButton.visible = handler instanceof INEIRecipeHandler && ((INEIRecipeHandler)handler).getPageForInfo(theGui.page) != null; } } @@ -62,18 +61,16 @@ public class NEIScreenEvents{ GuiRecipe theGui = (GuiRecipe)event.gui; IRecipeHandler handler = theGui.getCurrentRecipeHandlers().get(theGui.recipetype); - boolean isPage = handler instanceof INEIRecipeHandler && ((INEIRecipeHandler)handler).getStackForInfo(theGui.page) != null; + boolean isPage = handler instanceof INEIRecipeHandler && ((INEIRecipeHandler)handler).getPageForInfo(theGui.page) != null; this.neiButton.visible = isPage; if(isPage && event.button.id == NEI_BUTTON_ID){ - for(BookletPage page : InitBooklet.pagesWithItemStackData){ - if(ItemUtil.contains(page.getItemStacksForPage(), ((INEIRecipeHandler)handler).getStackForInfo(theGui.page), true)){ - GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen, false, true); - Minecraft.getMinecraft().displayGuiScreen(book); - BookletUtils.openIndexEntry(book, page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true); - BookletUtils.openChapter(book, page.getChapter(), page); - break; - } + BookletPage page = ((INEIRecipeHandler)handler).getPageForInfo(theGui.page); + if(page != null){ + GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen, false, true); + Minecraft.getMinecraft().displayGuiScreen(book); + BookletUtils.openIndexEntry(book, page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true); + BookletUtils.openChapter(book, page.getChapter(), page); } } }