mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +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;
|
package ellpeck.actuallyadditions.nei;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||||
|
|
||||||
public interface INEIRecipeHandler{
|
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++){
|
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(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.ITALIC+chapter.getLocalizedName(), 0, 97, 0, false);
|
||||||
GuiDraw.drawString(EnumChatFormatting.GOLD+"Page "+stack.thePage.getID(), 0, 105, 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.RecipeInfo;
|
||||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||||
|
import ellpeck.actuallyadditions.booklet.BookletUtils;
|
||||||
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||||
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
|
import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler;
|
||||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
import ellpeck.actuallyadditions.util.ItemUtil;
|
||||||
|
@ -41,8 +42,8 @@ public class NEIReconstructorRecipe extends TemplateRecipeHandler implements INE
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackForInfo(int page){
|
public BookletPage getPageForInfo(int page){
|
||||||
return new ItemStack(InitBlocks.blockAtomicReconstructor);
|
return BookletUtils.getFirstPageForStack(new ItemStack(InitBlocks.blockAtomicReconstructor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,7 +17,6 @@ import ellpeck.actuallyadditions.booklet.BookletUtils;
|
||||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||||
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
||||||
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||||
import ellpeck.actuallyadditions.util.ItemUtil;
|
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
import ellpeck.actuallyadditions.util.StringUtil;
|
import ellpeck.actuallyadditions.util.StringUtil;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -52,7 +51,7 @@ public class NEIScreenEvents{
|
||||||
|
|
||||||
event.buttonList.add(this.neiButton);
|
event.buttonList.add(this.neiButton);
|
||||||
IRecipeHandler handler = theGui.getCurrentRecipeHandlers().get(theGui.recipetype);
|
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;
|
GuiRecipe theGui = (GuiRecipe)event.gui;
|
||||||
|
|
||||||
IRecipeHandler handler = theGui.getCurrentRecipeHandlers().get(theGui.recipetype);
|
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;
|
this.neiButton.visible = isPage;
|
||||||
|
|
||||||
if(isPage && event.button.id == NEI_BUTTON_ID){
|
if(isPage && event.button.id == NEI_BUTTON_ID){
|
||||||
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
BookletPage page = ((INEIRecipeHandler)handler).getPageForInfo(theGui.page);
|
||||||
if(ItemUtil.contains(page.getItemStacksForPage(), ((INEIRecipeHandler)handler).getStackForInfo(theGui.page), true)){
|
if(page != null){
|
||||||
GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen, false, true);
|
GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen, false, true);
|
||||||
Minecraft.getMinecraft().displayGuiScreen(book);
|
Minecraft.getMinecraft().displayGuiScreen(book);
|
||||||
BookletUtils.openIndexEntry(book, page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true);
|
BookletUtils.openIndexEntry(book, page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true);
|
||||||
BookletUtils.openChapter(book, page.getChapter(), page);
|
BookletUtils.openChapter(book, page.getChapter(), page);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue