B U T T O N S

This commit is contained in:
Ellpeck 2016-11-11 18:55:32 +01:00
parent 24e2a9e88d
commit 81584c2fb1
17 changed files with 234 additions and 48 deletions

View file

@ -26,5 +26,5 @@ public interface IBookletChapter{
String getIdentifier(); String getIdentifier();
int getPageNum(IBookletPage page); int getPageIndex(IBookletPage page);
} }

View file

@ -21,9 +21,9 @@ import java.util.List;
public interface IBookletPage{ public interface IBookletPage{
List<ItemStack> getItemStacksForPage(); void getItemStacksForPage(List<ItemStack> list);
List<FluidStack> getFluidStacksForPage(); void getFluidStacksForPage(List<FluidStack> list);
IBookletChapter getChapter(); IBookletChapter getChapter();
@ -47,7 +47,7 @@ public interface IBookletPage{
void initGui(GuiBookletBase gui, int startX, int startY); void initGui(GuiBookletBase gui, int startX, int startY);
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
void updateScreen(GuiBookletBase gui, int startX, int startY); void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer);
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks); void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks);

View file

@ -32,5 +32,5 @@ public abstract class GuiBookletBase extends GuiScreen{
public abstract int getSizeY(); public abstract int getSizeY();
public abstract void addItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer); public abstract void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer);
} }

View file

@ -79,10 +79,12 @@ public final class InitBooklet{
for(IBookletPage page : chapter.getAllPages()){ for(IBookletPage page : chapter.getAllPages()){
pageCount++; pageCount++;
List<ItemStack> items = page.getItemStacksForPage(); List<ItemStack> items = new ArrayList<ItemStack>();
List<FluidStack> fluids = page.getFluidStacksForPage(); page.getItemStacksForPage(items);
List<FluidStack> fluids = new ArrayList<FluidStack>();
page.getFluidStacksForPage(fluids);
if((items != null && !items.isEmpty()) || (fluids != null && !items.isEmpty())){ if((items != null && !items.isEmpty()) || (fluids != null && !fluids.isEmpty())){
if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)){ if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)){
ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page); ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page);
infoCount++; infoCount++;

View file

@ -71,10 +71,10 @@ public class BookletChapter implements IBookletChapter{
} }
@Override @Override
public int getPageNum(IBookletPage page){ public int getPageIndex(IBookletPage page){
for(int i = 0; i < this.pages.length; i++){ for(int i = 0; i < this.pages.length; i++){
if(this.pages[i] == page){ if(this.pages[i] == page){
return i+1; return i;
} }
} }
return -1; return -1;

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.booklet.gui; package de.ellpeck.actuallyadditions.mod.booklet.gui;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
@ -34,6 +35,10 @@ public abstract class GuiBooklet extends GuiBookletBase{
public GuiScreen previousScreen; public GuiScreen previousScreen;
protected GuiBookletBase parentPage; protected GuiBookletBase parentPage;
private GuiButton buttonLeft;
private GuiButton buttonRight;
private GuiButton buttonBack;
protected int xSize; protected int xSize;
protected int ySize; protected int ySize;
protected int guiLeft; protected int guiLeft;
@ -53,6 +58,21 @@ public abstract class GuiBooklet extends GuiBookletBase{
this.guiLeft = (this.width-this.xSize)/2; this.guiLeft = (this.width-this.xSize)/2;
this.guiTop = (this.height-this.ySize)/2; this.guiTop = (this.height-this.ySize)/2;
if(this.hasPageLeftButton()){
this.buttonLeft = new TexturedButton(RES_LOC_GADGETS, -2000, this.guiLeft-12, this.guiTop+this.ySize-8, 18, 54, 18, 10);
this.buttonList.add(this.buttonLeft);
}
if(this.hasPageRightButton()){
this.buttonRight = new TexturedButton(RES_LOC_GADGETS, -2001, this.guiLeft+this.xSize-6, this.guiTop+this.ySize-8, 0, 54, 18, 10);
this.buttonList.add(this.buttonRight);
}
if(this.hasBackButton()){
this.buttonBack = new TexturedButton(RES_LOC_GADGETS, -2002, this.guiLeft-12, this.guiTop-2, 36, 54, 18, 10);
this.buttonList.add(this.buttonBack);
}
} }
@Override @Override
@ -69,6 +89,46 @@ public abstract class GuiBooklet extends GuiBookletBase{
return false; return false;
} }
public boolean hasPageLeftButton(){
return false;
}
public void onPageLeftButtonPressed(){
}
public boolean hasPageRightButton(){
return false;
}
public void onPageRightButtonPressed(){
}
public boolean hasBackButton(){
return false;
}
public void onBackButtonPressed(){
}
@Override
protected void actionPerformed(GuiButton button) throws IOException{
if(this.hasPageLeftButton() && button == this.buttonLeft){
this.onPageLeftButtonPressed();
}
else if(this.hasPageRightButton() && button == this.buttonRight){
this.onPageRightButtonPressed();
}
else if(this.hasBackButton() && button == this.buttonBack){
this.onBackButtonPressed();
}
else{
super.actionPerformed(button);
}
}
@Override @Override
protected void keyTyped(char typedChar, int keyCode) throws IOException{ protected void keyTyped(char typedChar, int keyCode) throws IOException{
if(this.previousScreen != null && keyCode == Keyboard.KEY_ESCAPE){ if(this.previousScreen != null && keyCode == Keyboard.KEY_ESCAPE){

View file

@ -89,7 +89,17 @@ public class GuiEntry extends GuiBooklet{
} }
@Override @Override
public void addItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){ public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){
} }
@Override
public boolean hasBackButton(){
return true;
}
@Override
public void onBackButtonPressed(){
this.mc.displayGuiScreen(this.parentPage);
}
} }

View file

@ -62,7 +62,7 @@ public class GuiMainPage extends GuiBooklet{
} }
@Override @Override
public void addItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){ public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){
} }
} }

View file

@ -10,8 +10,10 @@
package de.ellpeck.actuallyadditions.mod.booklet.gui; package de.ellpeck.actuallyadditions.mod.booklet.gui;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.booklet.page.ItemDisplay; import de.ellpeck.actuallyadditions.mod.booklet.page.ItemDisplay;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
@ -27,6 +29,7 @@ import java.util.List;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiPage extends GuiBooklet{ public class GuiPage extends GuiBooklet{
private int pageTimer;
private final List<ItemDisplay> itemDisplays = new ArrayList<ItemDisplay>(); private final List<ItemDisplay> itemDisplays = new ArrayList<ItemDisplay>();
public final IBookletPage[] pages = new IBookletPage[2]; public final IBookletPage[] pages = new IBookletPage[2];
@ -87,8 +90,8 @@ public class GuiPage extends GuiBooklet{
@Override @Override
public void initGui(){ public void initGui(){
super.initGui();
this.itemDisplays.clear(); this.itemDisplays.clear();
super.initGui();
for(int i = 0; i < this.pages.length; i++){ for(int i = 0; i < this.pages.length; i++){
IBookletPage page = this.pages[i]; IBookletPage page = this.pages[i];
@ -105,9 +108,11 @@ public class GuiPage extends GuiBooklet{
for(int i = 0; i < this.pages.length; i++){ for(int i = 0; i < this.pages.length; i++){
IBookletPage page = this.pages[i]; IBookletPage page = this.pages[i];
if(page != null){ if(page != null){
page.updateScreen(this, this.guiLeft+6+i*142, this.guiTop+7); page.updateScreen(this, this.guiLeft+6+i*142, this.guiTop+7, this.pageTimer);
} }
} }
this.pageTimer++;
} }
@Override @Override
@ -138,7 +143,82 @@ public class GuiPage extends GuiBooklet{
} }
@Override @Override
public void addItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){ public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){
for(ItemDisplay display : this.itemDisplays){
if(display.x == x && display.y == y && display.scale == scale){
display.stack = renderedStack;
return;
}
}
this.itemDisplays.add(new ItemDisplay(this, x, y, scale, renderedStack, shouldTryTransfer)); this.itemDisplays.add(new ItemDisplay(this, x, y, scale, renderedStack, shouldTryTransfer));
} }
@Override
public boolean hasPageLeftButton(){
IBookletPage page = this.pages[0];
if(page != null){
IBookletChapter chapter = page.getChapter();
if(chapter != null){
return chapter.getPageIndex(page) > 0;
}
}
return false;
}
@Override
public void onPageLeftButtonPressed(){
IBookletPage page = this.pages[0];
if(page != null){
IBookletChapter chapter = page.getChapter();
if(chapter != null){
IBookletPage[] pages = chapter.getAllPages();
int pageNumToOpen = chapter.getPageIndex(page)-1;
if(pageNumToOpen >= 0 && pageNumToOpen < pages.length){
this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen]));
}
}
}
}
@Override
public boolean hasPageRightButton(){
IBookletPage page = this.pages[1];
if(page != null){
IBookletChapter chapter = page.getChapter();
if(chapter != null){
int pageIndex = chapter.getPageIndex(page);
int pageAmount = chapter.getAllPages().length;
return pageIndex+1 < pageAmount-1;
}
}
return false;
}
@Override
public void onPageRightButtonPressed(){
IBookletPage page = this.pages[1];
if(page != null){
IBookletChapter chapter = page.getChapter();
if(chapter != null){
IBookletPage[] pages = chapter.getAllPages();
int pageNumToOpen = chapter.getPageIndex(page)+1;
if(pageNumToOpen >= 0 && pageNumToOpen < pages.length){
this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen]));
}
}
}
}
@Override
public boolean hasBackButton(){
return true;
}
@Override
public void onBackButtonPressed(){
this.mc.displayGuiScreen(this.parentPage);
}
} }

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.booklet.misc;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiEntry; import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiEntry;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage; import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
@ -21,13 +22,15 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public final class BookletUtils{ public final class BookletUtils{
public static IBookletPage findFirstPageForStack(ItemStack stack){ public static IBookletPage findFirstPageForStack(ItemStack stack){
for(IBookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA){ for(IBookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA){
List<ItemStack> stacks = page.getItemStacksForPage(); List<ItemStack> stacks = new ArrayList<ItemStack>();
page.getItemStacksForPage(stacks);
if(stacks != null && !stacks.isEmpty()){ if(stacks != null && !stacks.isEmpty()){
for(ItemStack pageStack : stacks){ for(ItemStack pageStack : stacks){
if(ItemUtil.areItemsEqual(pageStack, stack, true)){ if(ItemUtil.areItemsEqual(pageStack, stack, true)){
@ -48,11 +51,11 @@ public final class BookletUtils{
return createPageGui(previousScreen, entry, page); return createPageGui(previousScreen, entry, page);
} }
public static GuiPage createPageGui(GuiScreen previousScreen, GuiBooklet parentPage, IBookletPage page){ public static GuiPage createPageGui(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page){
IBookletChapter chapter = page.getChapter(); IBookletChapter chapter = page.getChapter();
IBookletPage[] allPages = chapter.getAllPages(); IBookletPage[] allPages = chapter.getAllPages();
int pageIndex = chapter.getPageNum(page)-1; int pageIndex = chapter.getPageIndex(page);
IBookletPage page1; IBookletPage page1;
IBookletPage page2; IBookletPage page2;

View file

@ -32,8 +32,8 @@ public class BookletPage implements IBookletPage{
protected IBookletChapter chapter; protected IBookletChapter chapter;
protected List<FluidStack> fluidsForPage = new ArrayList<FluidStack>(); private final List<ItemStack> itemsForPage = new ArrayList<ItemStack>();
protected List<ItemStack> itemsForPage = new ArrayList<ItemStack>(); private final List<FluidStack> fluidsForPage = new ArrayList<FluidStack>();
protected boolean hasNoText; protected boolean hasNoText;
protected final HashMap<String, String> textReplacements = new HashMap<String, String>(); protected final HashMap<String, String> textReplacements = new HashMap<String, String>();
@ -44,13 +44,13 @@ public class BookletPage implements IBookletPage{
} }
@Override @Override
public List<ItemStack> getItemStacksForPage(){ public void getItemStacksForPage(List<ItemStack> list){
return this.itemsForPage; list.addAll(this.itemsForPage);
} }
@Override @Override
public List<FluidStack> getFluidStacksForPage(){ public void getFluidStacksForPage(List<FluidStack> list){
return this.fluidsForPage; list.addAll(this.fluidsForPage);
} }
@Override @Override
@ -115,7 +115,7 @@ public class BookletPage implements IBookletPage{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void updateScreen(GuiBookletBase gui, int startX, int startY){ public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer){
} }
@ -133,7 +133,7 @@ public class BookletPage implements IBookletPage{
@Override @Override
public boolean shouldBeOnLeftSide(){ public boolean shouldBeOnLeftSide(){
return this.chapter.getPageNum(this)%2 != 0; return (this.chapter.getPageIndex(this)+1)%2 != 0;
} }
public BookletPage setNoText(){ public BookletPage setNoText(){

View file

@ -24,17 +24,19 @@ import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List; import java.util.List;
public class ItemDisplay{ public class ItemDisplay{
private final GuiPage gui; private final GuiPage gui;
private final int x; public final int x;
private final int y; public final int y;
private final float scale; public final float scale;
private final ItemStack stack; public ItemStack stack;
private final IBookletPage page; private final IBookletPage page;
public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer){ public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer){
@ -46,10 +48,12 @@ public class ItemDisplay{
this.page = shouldTryTransfer ? BookletUtils.findFirstPageForStack(stack) : null; this.page = shouldTryTransfer ? BookletUtils.findFirstPageForStack(stack) : null;
} }
@SideOnly(Side.CLIENT)
public void drawPre(){ public void drawPre(){
AssetUtil.renderStackToGui(this.stack, this.x, this.y, this.scale); AssetUtil.renderStackToGui(this.stack, this.x, this.y, this.scale);
} }
@SideOnly(Side.CLIENT)
public void drawPost(int mouseX, int mouseY){ public void drawPost(int mouseX, int mouseY){
if(this.isHovered(mouseX, mouseY)){ if(this.isHovered(mouseX, mouseY)){
Minecraft mc = this.gui.mc; Minecraft mc = this.gui.mc;

View file

@ -32,6 +32,7 @@ import java.util.List;
public class PageCrafting extends BookletPage{ public class PageCrafting extends BookletPage{
private int recipeAt;
private String recipeTypeLocKey; private String recipeTypeLocKey;
private boolean isWildcard; private boolean isWildcard;
private final List<IRecipe> recipes; private final List<IRecipe> recipes;
@ -64,20 +65,38 @@ public class PageCrafting extends BookletPage{
} }
@Override @Override
public void initGui(GuiBookletBase gui, int startX, int startY){ @SideOnly(Side.CLIENT)
super.initGui(gui, startX, startY); public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer){
super.updateScreen(gui, startX, startY, pageTimer);
if(pageTimer%20 == 0){
this.findRecipe(gui, startX, startY);
}
}
private void findRecipe(GuiBookletBase gui, int startX, int startY){
if(!this.recipes.isEmpty()){ if(!this.recipes.isEmpty()){
IRecipe recipe = this.recipes.get(0); IRecipe recipe = this.recipes.get(this.recipeAt);
if(recipe != null){ if(recipe != null){
this.setupRecipe(gui, recipe, startX, startY); this.setupRecipe(gui, recipe, startX, startY);
} }
this.recipeAt++;
if(this.recipeAt >= this.recipes.size()){
this.recipeAt = 0;
}
} }
} }
@Override @Override
public List<ItemStack> getItemStacksForPage(){ public void initGui(GuiBookletBase gui, int startX, int startY){
List<ItemStack> stacks = super.getItemStacksForPage(); super.initGui(gui, startX, startY);
this.findRecipe(gui, startX, startY);
}
@Override
public void getItemStacksForPage(List<ItemStack> list){
super.getItemStacksForPage(list);
if(!this.recipes.isEmpty()){ if(!this.recipes.isEmpty()){
for(IRecipe recipe : this.recipes){ for(IRecipe recipe : this.recipes){
@ -88,13 +107,11 @@ public class PageCrafting extends BookletPage{
if(this.isWildcard){ if(this.isWildcard){
copy.setItemDamage(Util.WILDCARD); copy.setItemDamage(Util.WILDCARD);
} }
stacks.add(copy); list.add(copy);
} }
} }
} }
} }
return stacks;
} }
private void setupRecipe(GuiBookletBase gui, IRecipe recipe, int startX, int startY){ private void setupRecipe(GuiBookletBase gui, IRecipe recipe, int startX, int startY){
@ -152,11 +169,11 @@ public class PageCrafting extends BookletPage{
copy.setItemDamage(0); copy.setItemDamage(0);
} }
gui.addItemRenderer(copy, startX+6+x*18, startY+7+y*18, 1F, true); gui.addOrModifyItemRenderer(copy, startX+6+x*18, startY+7+y*18, 1F, true);
} }
} }
} }
gui.addItemRenderer(recipe.getRecipeOutput(), startX+100, startY+25, 1F, false); gui.addOrModifyItemRenderer(recipe.getRecipeOutput(), startX+100, startY+25, 1F, false);
} }
} }

View file

@ -109,7 +109,7 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack); IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
if(page != null){ if(page != null){
String strg1 = page.getChapter().getLocalizedName(); String strg1 = page.getChapter().getLocalizedName();
String strg2 = "Page "+page.getChapter().getPageNum(page); String strg2 = "Page "+(page.getChapter().getPageIndex(page)+1);
String strg3 = "Right-Click to open..."; String strg3 = "Right-Click to open...";
AssetUtil.renderStackToGui(page.getChapter().getDisplayItemStack() != null ? page.getChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2-10, height+41, 1F); AssetUtil.renderStackToGui(page.getChapter().getDisplayItemStack() != null ? page.getChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2-10, height+41, 1F);

View file

@ -16,8 +16,11 @@ import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.BlankRecipeCategory;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
public class BookletRecipeCategory extends BlankRecipeCategory<BookletRecipeWrapper>{ public class BookletRecipeCategory extends BlankRecipeCategory<BookletRecipeWrapper>{
@ -49,6 +52,9 @@ public class BookletRecipeCategory extends BlankRecipeCategory<BookletRecipeWrap
@Override @Override
public void setRecipe(IRecipeLayout recipeLayout, BookletRecipeWrapper wrapper, IIngredients ingredients){ public void setRecipe(IRecipeLayout recipeLayout, BookletRecipeWrapper wrapper, IIngredients ingredients){
recipeLayout.getItemStacks().init(0, true, 70, -4); recipeLayout.getItemStacks().init(0, true, 70, -4);
recipeLayout.getItemStacks().set(0, wrapper.thePage.getItemStacksForPage());
List<ItemStack> list = new ArrayList<ItemStack>();
wrapper.thePage.getItemStacksForPage(list);
recipeLayout.getItemStacks().set(0, list);
} }
} }

View file

@ -21,7 +21,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.Arrays; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class BookletRecipeWrapper extends RecipeWrapperWithButton{ public class BookletRecipeWrapper extends RecipeWrapperWithButton{
@ -34,11 +34,15 @@ public class BookletRecipeWrapper extends RecipeWrapperWithButton{
@Override @Override
public void getIngredients(IIngredients ingredients){ public void getIngredients(IIngredients ingredients){
ingredients.setInputs(ItemStack.class, this.thePage.getItemStacksForPage()); List<ItemStack> itemList = new ArrayList<ItemStack>();
ingredients.setInputs(FluidStack.class, this.thePage.getFluidStacksForPage()); this.thePage.getItemStacksForPage(itemList);
ingredients.setInputs(ItemStack.class, itemList);
ingredients.setOutputs(ItemStack.class, itemList);
ingredients.setOutputs(ItemStack.class, this.thePage.getItemStacksForPage()); List<FluidStack> fluidList = new ArrayList<FluidStack>();
ingredients.setOutputs(FluidStack.class, this.thePage.getFluidStacksForPage()); this.thePage.getFluidStacksForPage(fluidList);
ingredients.setInputs(FluidStack.class, fluidList);
ingredients.setOutputs(FluidStack.class, fluidList);
} }
@Override @Override
@ -56,7 +60,7 @@ public class BookletRecipeWrapper extends RecipeWrapperWithButton{
minecraft.fontRendererObj.drawString(text.get(i)+(i == maxLines-1 && text.size() > maxLines ? TextFormatting.RESET+""+TextFormatting.BLACK+"..." : ""), 0, 16+25+i*(minecraft.fontRendererObj.FONT_HEIGHT+1), 0, false); minecraft.fontRendererObj.drawString(text.get(i)+(i == maxLines-1 && text.size() > maxLines ? TextFormatting.RESET+""+TextFormatting.BLACK+"..." : ""), 0, 16+25+i*(minecraft.fontRendererObj.FONT_HEIGHT+1), 0, false);
} }
minecraft.fontRendererObj.drawString(TextFormatting.ITALIC+chapter.getLocalizedName(), 25, 85, 0, false); minecraft.fontRendererObj.drawString(TextFormatting.ITALIC+chapter.getLocalizedName(), 25, 85, 0, false);
minecraft.fontRendererObj.drawString(TextFormatting.ITALIC+"Page "+chapter.getPageNum(this.thePage), 25, 95, 0, false); minecraft.fontRendererObj.drawString(TextFormatting.ITALIC+"Page "+(chapter.getPageIndex(this.thePage)+1), 25, 95, 0, false);
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB