From 2aa2e547c8ee2c3e593b5119f7c79cf6f301678e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 29 Sep 2015 17:42:04 +0200 Subject: [PATCH] Added some fancy recipe auto-scrolling for multiple recipes on the same page --- .../actuallyadditions/booklet/GuiBooklet.java | 4 ++ .../booklet/InitBooklet.java | 2 +- .../booklet/page/BookletPage.java | 4 ++ .../booklet/page/PageCrafting.java | 39 +++++++++++++++---- .../booklet/page/PageCrusherRecipe.java | 2 +- .../booklet/page/PageFurnace.java | 2 +- .../booklet/page/PageTextOnly.java | 2 +- .../crafting/ItemCrafting.java | 6 +-- .../assets/actuallyadditions/lang/en_US.lang | 2 +- 9 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java index 519375c48..023ecc6bd 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java @@ -87,6 +87,10 @@ public class GuiBooklet extends GuiScreen{ super.updateScreen(); this.searchField.updateCursorCounter(); + if(this.currentIndexEntry != null && this.currentChapter != null && this.currentPage != null){ + this.currentPage.updateScreen(this.ticksElapsed); + } + boolean buttonThere = UpdateChecker.doneChecking && UpdateChecker.updateVersion > UpdateChecker.clientVersion; this.getButton(BUTTON_UPDATE_ID).visible = buttonThere; if(buttonThere){ diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index 38f41fd48..e20b08a99 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -74,7 +74,7 @@ public class InitBooklet{ new BookletChapter("greenhouseGlass", entryFunctionalNonRF, new ItemStack(InitBlocks.blockGreenhouseGlass), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeGlass).setNoText()); new BookletChapter("fishingNet", entryFunctionalNonRF, new ItemStack(InitBlocks.blockFishingNet), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFisher).setNoText()); new BookletChapter("feeder", entryFunctionalNonRF, new ItemStack(InitBlocks.blockFeeder), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFeeder).setNoText()); - new BookletChapter("compost", entryFunctionalNonRF, new ItemStack(InitBlocks.blockCompost), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemFertilizer)).addTextReplacement("", ConfigIntValues.COMPOST_AMOUNT.getValue()), new PageCrafting(2, BlockCrafting.recipeCompost).setNoText(), new PageCrafting(3, ItemCrafting.recipeMashedFood)); + new BookletChapter("compost", entryFunctionalNonRF, new ItemStack(InitBlocks.blockCompost), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemFertilizer)).addTextReplacement("", ConfigIntValues.COMPOST_AMOUNT.getValue()), new PageCrafting(2, BlockCrafting.recipeCompost).setNoText(), new PageCrafting(3, ItemCrafting.recipesMashedFood)); new BookletChapter("crate", entryFunctionalNonRF, new ItemStack(InitBlocks.blockGiantChest), new PageCrafting(1, BlockCrafting.recipeCrate)); //RF Using Blocks diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java index 850b34072..3f7558ac5 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java @@ -93,6 +93,10 @@ public class BookletPage{ return null; } + public void updateScreen(int ticksElapsed){ + + } + @SuppressWarnings("unchecked") protected void renderTooltipAndTransfer(GuiBooklet gui, ItemStack stack, int x, int y, boolean checkAndTransfer, boolean mouseClick){ List list = stack.getTooltip(gui.mc.thePlayer, gui.mc.gameSettings.advancedItemTooltips); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java index d1307e195..fe9ae2a51 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java @@ -28,31 +28,56 @@ import java.util.ArrayList; public class PageCrafting extends BookletPage{ - private final IRecipe recipe; + private final IRecipe[] recipes; + private int recipePos; - public PageCrafting(int id, IRecipe recipe){ + public PageCrafting(int id, IRecipe... recipes){ super(id); - this.recipe = recipe; + this.recipes = recipes; InitBooklet.pagesWithItemStackData.add(this); } + public PageCrafting(int id, ArrayList recipes){ + this(id, recipes.toArray(new IRecipe[recipes.size()])); + } + @Override public ItemStack[] getItemStacksForPage(){ - return this.recipe == null ? null : new ItemStack[]{this.recipe.getRecipeOutput()}; + ItemStack[] stacks = new ItemStack[this.recipes.length]; + for(int i = 0; i < stacks.length; i++){ + if(this.recipes[i] != null){ + stacks[i] = this.recipes[i].getRecipeOutput(); + } + } + return stacks; } @Override public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){ - if(this.recipe != null){ + if(this.recipes[this.recipePos] != null){ gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc); gui.drawTexturedModalRect(gui.guiLeft+27, gui.guiTop+20, 146, 20, 99, 60); } } + @Override + public void updateScreen(int ticksElapsed){ + if(ticksElapsed%30 == 0){ + if(this.recipePos+1 >= this.recipes.length){ + this.recipePos = 0; + } + else{ + this.recipePos++; + } + } + } + @SuppressWarnings("unchecked") @Override public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){ - if(this.recipe == null){ + IRecipe recipe = this.recipes[this.recipePos]; + + if(recipe == null){ gui.unicodeRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0); } else{ @@ -65,7 +90,7 @@ public class PageCrafting extends BookletPage{ gui.unicodeRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+90, 115, 0); } - if(this.recipe != null){ + if(recipe != null){ ItemStack[] stacks = new ItemStack[9]; int width = 3; diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java index 7bb7add65..01da455c2 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java @@ -39,7 +39,7 @@ public class PageCrusherRecipe extends BookletPage{ @Override public ItemStack[] getItemStacksForPage(){ - return new ItemStack[]{this.recipe == null ? null : this.recipe.firstOutput}; + return this.recipe == null ? new ItemStack[0] : new ItemStack[]{this.recipe.firstOutput}; } @SuppressWarnings("unchecked") diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java index 83acf71c6..ef6675679 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java @@ -38,7 +38,7 @@ public class PageFurnace extends BookletPage{ @Override public ItemStack[] getItemStacksForPage(){ - return new ItemStack[]{this.result}; + return this.result == null ? new ItemStack[0] : new ItemStack[]{this.result}; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageTextOnly.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageTextOnly.java index c352b3111..e0eb71760 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageTextOnly.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageTextOnly.java @@ -32,7 +32,7 @@ public class PageTextOnly extends BookletPage{ @Override public ItemStack[] getItemStacksForPage(){ - return new ItemStack[]{this.stack}; + return this.stack == null ? new ItemStack[0] : new ItemStack[]{this.stack}; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java index af1d37f40..87a99d678 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java @@ -40,7 +40,7 @@ public class ItemCrafting{ public static IRecipe recipeBook; public static IRecipe recipeTinyCoal; public static IRecipe recipeTinyChar; - public static IRecipe recipeMashedFood; + public static ArrayList recipesMashedFood = new ArrayList(); public static IRecipe recipeDrill; public static IRecipe recipeDrillSpeedI; public static IRecipe recipeDrillSpeedII; @@ -478,9 +478,7 @@ public class ItemCrafting{ if(!isBlacklisted(item)){ ItemStack ingredient = new ItemStack((Item)item, 1, Util.WILDCARD); GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.MASHED_FOOD.ordinal()), ingredient, ingredient, ingredient, ingredient, new ItemStack(InitItems.itemKnife, 1, Util.WILDCARD)); - if(recipeMashedFood == null){ - recipeMashedFood = Util.lastIRecipe(); - } + recipesMashedFood.add(Util.lastIRecipe()); } } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index bed6c2ba3..ae48133c6 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -450,7 +450,7 @@ booklet.actuallyadditions.chapter.feeder.text.1=The Feeder is a good al booklet.actuallyadditions.chapter.compost.name=Compost and Fertilizer booklet.actuallyadditions.chapter.compost.text.1=The Compost is used to make Fertilizier from Mashed Food. Fertilizer acts just like Bone Meal, but can be crafted in a much simpler manner just by crafting Mashed Food and then putting of those inside of a Compost and waiting for a bit. When the mashed food is composted, just take it out by right-clicking again. -booklet.actuallyadditions.chapter.compost.text.3=Mashed Food can be crafted from any time of food or plantable item. +booklet.actuallyadditions.chapter.compost.text.3=Mashed Food can be crafted from any type of food or plantable item. booklet.actuallyadditions.chapter.crate.name=Storage Crates booklet.actuallyadditions.chapter.crate.text.1=Storage Crates are big. Really big. They hold tons of items, more than 4 chests worth of them. "F-in' gigantic" -Some Magazine