mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Adjusted page display in NEI handler a bit
This commit is contained in:
parent
be21628161
commit
c55991f5e0
4 changed files with 15 additions and 17 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue