diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index 213658e37..f8f6ffe66 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -26,8 +26,8 @@ import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.metalists.TheFoods; import ellpeck.actuallyadditions.items.metalists.TheMiscItems; import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops; +import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler; import ellpeck.actuallyadditions.util.Util; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -56,12 +56,12 @@ public class InitBooklet{ //Getting Started chapterIntro = new BookletChapter("intro", entryGettingStarted, new ItemStack(InitItems.itemLexicon), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3)); new BookletChapter("bookTutorial", entryGettingStarted, new ItemStack(InitItems.itemLexicon), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeBook)); - new BookletChapterReconstructor("crystals", entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.RECONSTRUCTOR_BASE_ENERGY_USE.getValue()), new PageTextOnly(2), new PagePicture(3, "pageAtomicReconstructor", 0).setNoText(), new PageTextOnly(4), new PageCrafting(5, BlockCrafting.recipeAtomicReconstructor).setNoText(), new PageCrafting(6, ItemCrafting.recipeLens).setNoText(), new PageReconstructor(7, new ItemStack(InitItems.itemColorLens)).setNoText()).setSpecial(); + new BookletChapterReconstructor("crystals", entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.RECONSTRUCTOR_BASE_ENERGY_USE.getValue()), new PageTextOnly(2), new PagePicture(3, "pageAtomicReconstructor", 0).setNoText(), new PageTextOnly(4), new PageCrafting(5, BlockCrafting.recipeAtomicReconstructor).setNoText(), new PageCrafting(6, ItemCrafting.recipeLens).setNoText(), new PageReconstructor(7, ReconstructorRecipeHandler.recipeColorLens).setNoText()).setSpecial(); new BookletChapter("coalGen", entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageCrafting(1, BlockCrafting.recipeCoalGen).addTextReplacement("", ConfigIntValues.COAL_GEN_ENERGY_PRODUCED.getValue())); new BookletChapter("craftingIngs", entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeStoneCase).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(7, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(8, ItemCrafting.recipeRing).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(11, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(12, ItemCrafting.recipeDough).setNoText(), new PageCrafting(13, ItemCrafting.recipeRiceDough).setNoText(), new PageCrafting(14, BlockCrafting.recipeIronCase).setNoText()).setImportant(); //Miscellaneous - new BookletChapter("miscReconstructor", entryMisc, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), new PageTextOnly(1), new PageReconstructor(2, new ItemStack(Blocks.soul_sand)).setNoText(), new PageReconstructor(3, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)), new PageReconstructor(4, new ItemStack(InitBlocks.blockTestifiBucksGreenWall)).setNoText()).setImportant(); + new BookletChapter("miscReconstructor", entryMisc, new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), new PageTextOnly(1), new PageReconstructor(2, ReconstructorRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(3, ReconstructorRecipeHandler.recipeWhiteWall), new PageReconstructor(4, ReconstructorRecipeHandler.recipeGreenWall).setNoText(), new PageReconstructor(5, ReconstructorRecipeHandler.colorConversionRecipes)).setImportant(); new BookletChapter("bookStand", entryMisc, new ItemStack(InitBlocks.blockBookletStand), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBookStand)); new BookletChapter("quartz", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("", ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue()).addTextReplacement("", ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText()); new BookletChapter("cloud", entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setNoText()).setSpecial(); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/chapter/BookletChapterReconstructor.java b/src/main/java/ellpeck/actuallyadditions/booklet/chapter/BookletChapterReconstructor.java index 1e63aba1d..b7819eed6 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/chapter/BookletChapterReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/chapter/BookletChapterReconstructor.java @@ -45,9 +45,7 @@ public class BookletChapterReconstructor extends BookletChapter{ } }.setNoText()); - for(int i = 0; i < ReconstructorRecipeHandler.RECIPES_FOR_BOOKLET_PAGE; i++){ - allPages.add(new PageReconstructor(allPages.size()+1, ReconstructorRecipeHandler.recipes.get(i).getFirstOutput()).setNoText()); - } + allPages.add(new PageReconstructor(allPages.size()+1, ReconstructorRecipeHandler.mainPageRecipes).setNoText()); return allPages.toArray(new BookletPage[allPages.size()]); } diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java index 78473314c..6bf4c8002 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java @@ -140,7 +140,7 @@ public class PageCrafting extends BookletPage{ @Override public void updateScreen(int ticksElapsed){ - if(ticksElapsed%30 == 0){ + if(ticksElapsed%15 == 0){ if(this.recipePos+1 >= this.recipes.length){ this.recipePos = 0; } @@ -152,18 +152,22 @@ public class PageCrafting extends BookletPage{ @Override public ItemStack[] getItemStacksForPage(){ - if(this.recipes != null && this.recipes.length > 0 && this.recipes[0] != null){ - ItemStack output = this.recipes[0].getRecipeOutput(); - if(output != null){ - if(!this.arePageStacksWildcard){ - return new ItemStack[]{output}; - } - else{ - ItemStack wildcardOutput = output.copy(); - wildcardOutput.setItemDamage(Util.WILDCARD); - return new ItemStack[]{wildcardOutput}; + if(this.recipes != null){ + ItemStack[] stacks = new ItemStack[this.recipes.length]; + for(int i = 0; i < this.recipes.length; i++){ + ItemStack output = this.recipes[i].getRecipeOutput(); + if(output != null){ + if(!this.arePageStacksWildcard){ + stacks[i] = output; + } + else{ + ItemStack wildcardOutput = output.copy(); + wildcardOutput.setItemDamage(Util.WILDCARD); + stacks[i] = wildcardOutput; + } } } + return stacks; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageReconstructor.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageReconstructor.java index 478e55c24..4424ced1b 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageReconstructor.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageReconstructor.java @@ -21,27 +21,39 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.oredict.OreDictionary; +import java.util.ArrayList; import java.util.List; public class PageReconstructor extends BookletPage{ - private final ItemStack result; - private final ItemStack input; + private ReconstructorRecipeHandler.Recipe[] recipes; + private int recipePos; - public PageReconstructor(int id, ItemStack result){ - this(id, null, result); + public PageReconstructor(int id, ReconstructorRecipeHandler.Recipe... recipes){ + super(id); + this.recipes = recipes; + this.addToPagesWithItemStackData(); } - public PageReconstructor(int id, ItemStack input, ItemStack result){ - super(id); - this.result = result; - this.input = input; - this.addToPagesWithItemStackData(); + public PageReconstructor(int id, ArrayList recipes){ + this(id, recipes.toArray(new ReconstructorRecipeHandler.Recipe[recipes.size()])); + } + + @Override + public void updateScreen(int ticksElapsed){ + if(ticksElapsed%15 == 0){ + if(this.recipePos+1 >= this.recipes.length){ + this.recipePos = 0; + } + else{ + this.recipePos++; + } + } } @Override public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){ - if(this.input != null || this.getInputForOutput(this.result) != null){ + if(this.recipes[this.recipePos] != null){ gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc); gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 188, 154, 60, 60); } @@ -50,8 +62,8 @@ public class PageReconstructor extends BookletPage{ @SuppressWarnings("unchecked") @Override public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){ - ItemStack input = this.input != null ? this.input : this.getInputForOutput(this.result); - if(input == null){ + ReconstructorRecipeHandler.Recipe recipe = this.recipes[this.recipePos]; + if(recipe == null){ gui.mc.fontRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0); } else{ @@ -59,7 +71,7 @@ public class PageReconstructor extends BookletPage{ gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0); //Lens - ItemStack lens = this.getRecipeForOutput(this.result).type.lens; + ItemStack lens = recipe.type.lens; strg = lens == null ? StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".noLens") : lens.getItem().getItemStackDisplayName(lens); gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+75, 0); } @@ -69,11 +81,11 @@ public class PageReconstructor extends BookletPage{ gui.mc.fontRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+100, 115, 0); } - if(input != null){ + if(recipe != null){ renderItem(gui, new ItemStack(InitBlocks.blockAtomicReconstructor), gui.guiLeft+37+22, gui.guiTop+20+21, 1.0F); for(int i = 0; i < 2; i++){ for(int x = 0; x < 2; x++){ - ItemStack stack = x == 0 ? input : this.result; + ItemStack stack = x == 0 ? this.getInputForRecipe(recipe) : recipe.getFirstOutput(); if(stack.getItemDamage() == Util.WILDCARD){ stack.setItemDamage(0); } @@ -96,30 +108,22 @@ public class PageReconstructor extends BookletPage{ @Override public ItemStack[] getItemStacksForPage(){ - return this.result == null ? new ItemStack[0] : new ItemStack[]{this.result}; - } - - private ReconstructorRecipeHandler.Recipe getRecipeForOutput(ItemStack output){ - for(ReconstructorRecipeHandler.Recipe recipe : ReconstructorRecipeHandler.recipes){ - List stacks = OreDictionary.getOres(recipe.output, false); - for(ItemStack stack : stacks){ - if(output.isItemEqual(stack)){ - return recipe; - } + if(this.recipes != null){ + ItemStack[] stacks = new ItemStack[this.recipes.length]; + for(int i = 0; i < this.recipes.length; i++){ + stacks[i] = this.recipes[i].getFirstOutput(); } + return stacks; } return null; } - private ItemStack getInputForOutput(ItemStack output){ - ReconstructorRecipeHandler.Recipe recipe = this.getRecipeForOutput(output); - if(recipe != null){ - List inputs = OreDictionary.getOres(recipe.input, false); - if(inputs != null && !inputs.isEmpty() && inputs.get(0) != null){ - ItemStack input = inputs.get(0).copy(); - input.stackSize = 1; - return input; - } + private ItemStack getInputForRecipe(ReconstructorRecipeHandler.Recipe recipe){ + List stacks = OreDictionary.getOres(recipe.input, false); + if(stacks != null && !stacks.isEmpty() && stacks.get(0) != null){ + ItemStack copy = stacks.get(0).copy(); + copy.stackSize = 1; + return copy; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java index c5c36c58b..290b26a2f 100644 --- a/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/recipe/ReconstructorRecipeHandler.java @@ -25,46 +25,76 @@ import java.util.Objects; public class ReconstructorRecipeHandler{ public static ArrayList recipes = new ArrayList(); - public static final int RECIPES_FOR_BOOKLET_PAGE = 12; + + public static ArrayList mainPageRecipes = new ArrayList(); + public static Recipe recipeColorLens; + public static Recipe recipeSoulSand; + public static Recipe recipeGreenWall; + public static Recipe recipeWhiteWall; + public static ArrayList colorConversionRecipes = new ArrayList(); public static void init(){ //Crystal Blocks addRecipe("blockRedstone", "blockCrystalRed", 400); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("blockLapis", "blockCrystalBlue", 400); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("blockDiamond", "blockCrystalLightBlue", 6000); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("blockEmerald", "blockCrystalGreen", 10000); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("blockCoal", "blockCrystalBlack", 600); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("blockIron", "blockCrystalWhite", 800); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); //Crystal Items addRecipe("dustRedstone", "crystalRed", 40); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("gemLapis", "crystalBlue", 40); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("gemDiamond", "crystalLightBlue", 600); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("gemEmerald", "crystalGreen", 1000); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("coal", "crystalBlack", 60); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("ingotIron", "crystalWhite", 80); + mainPageRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); //Lenses addRecipe("itemLens", "itemColorLens", 5000); addRecipe("itemColorLens", "itemLens", 5000); + recipeColorLens = Util.GetRecipes.lastReconstructorRecipe(); //Misc if(ConfigCrafting.RECONSTRUCTOR_MISC.isEnabled()){ addRecipe("sand", "soulSand", 20000); + recipeSoulSand = Util.GetRecipes.lastReconstructorRecipe(); addRecipe("blockQuartz", "blockWhiteBrick", 10); + recipeWhiteWall = Util.GetRecipes.lastReconstructorRecipe(); addRecipe("blockQuartz", "blockGreenBrick", 10, LensType.COLOR); + recipeGreenWall = Util.GetRecipes.lastReconstructorRecipe(); //Colors for(int i = 0; i < TheColoredLampColors.values().length-1; i++){ addRecipe("dye"+TheColoredLampColors.values()[i].name, "dye"+TheColoredLampColors.values()[i+1].name, 2000, LensType.COLOR); + colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("wool"+TheColoredLampColors.values()[i].name, "wool"+TheColoredLampColors.values()[i+1].name, 2000, LensType.COLOR); + colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("clay"+TheColoredLampColors.values()[i].name, "clay"+TheColoredLampColors.values()[i+1].name, 2000, LensType.COLOR); + colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("blockGlass"+TheColoredLampColors.values()[i].name, "blockGlass"+TheColoredLampColors.values()[i+1].name, 2000, LensType.COLOR); + colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); } addRecipe("dye"+TheColoredLampColors.values()[15].name, "dye"+TheColoredLampColors.values()[0].name, 2000, LensType.COLOR); + colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("wool"+TheColoredLampColors.values()[15].name, "wool"+TheColoredLampColors.values()[0].name, 2000, LensType.COLOR); + colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("clay"+TheColoredLampColors.values()[15].name, "clay"+TheColoredLampColors.values()[0].name, 2000, LensType.COLOR); + colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); addRecipe("blockGlass"+TheColoredLampColors.values()[15].name, "blockGlass"+TheColoredLampColors.values()[0].name, 2000, LensType.COLOR); + colorConversionRecipes.add(Util.GetRecipes.lastReconstructorRecipe()); } } @@ -105,8 +135,10 @@ public class ReconstructorRecipeHandler{ public ItemStack getFirstOutput(){ List stacks = OreDictionary.getOres(this.output, false); - if(stacks != null && !stacks.isEmpty()){ - return stacks.get(0); + if(stacks != null && !stacks.isEmpty() && stacks.get(0) != null){ + ItemStack stack = stacks.get(0).copy(); + stack.stackSize = 1; + return stack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/util/Util.java b/src/main/java/ellpeck/actuallyadditions/util/Util.java index 9f0d951e2..1ab24fb39 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/Util.java +++ b/src/main/java/ellpeck/actuallyadditions/util/Util.java @@ -12,6 +12,7 @@ package ellpeck.actuallyadditions.util; import cpw.mods.fml.common.FMLCommonHandler; import ellpeck.actuallyadditions.recipe.CrusherRecipeRegistry; +import ellpeck.actuallyadditions.recipe.ReconstructorRecipeHandler; import net.minecraft.block.BlockDispenser; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.item.Item; @@ -61,6 +62,11 @@ public class Util{ public static class GetRecipes{ + public static ReconstructorRecipeHandler.Recipe lastReconstructorRecipe(){ + ArrayList list = ReconstructorRecipeHandler.recipes; + return list.get(list.size()-1); + } + public static CrusherRecipeRegistry.CrusherRecipe lastCrusherRecipe(){ ArrayList list = CrusherRecipeRegistry.recipes; return list.get(list.size()-1); diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 1caf65410..a88b71f84 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -611,8 +611,9 @@ booklet.actuallyadditions.chapter.bookTutorial.text.2=The Buttons at the to booklet.actuallyadditions.chapter.bookTutorial.text.3=If you, for some reason, want to craft this book again, just take a piece of paper and a canola seed which you can find randomly generated and craft them together! booklet.actuallyadditions.chapter.miscReconstructor.name=Useful Reconstructor Recipes -booklet.actuallyadditions.chapter.miscReconstructor.text.1=There are some additional recipes for the Atomic Reconstructor that could be very useful to you. These include decor blocks and items as well as some useful conversions. Flip through the following pages to see them all. For example, by firing at Wool, Stained Clay, Stained Glass and Dye with a Lens: Color multiple times, you can cycle through all of their colors. +booklet.actuallyadditions.chapter.miscReconstructor.text.1=There are some additional recipes for the Atomic Reconstructor that could be very useful to you. These include decor blocks and items as well as some useful conversions. Flip through the following pages to see them all. booklet.actuallyadditions.chapter.miscReconstructor.text.3=The Ethetic Quartz Blocks are Quartz Blocks spruced up. They can be crafted into stairs, slabs and walls with the same recipes as cobblestone has. No, not misspelled +booklet.actuallyadditions.chapter.miscReconstructor.text.5=By firing at Wool, Stained Clay, Stained Glass and Dye with a Lens: Color multiple times, you can cycle through all of their colors. booklet.actuallyadditions.chapter.bookStand.name=Manual Stand booklet.actuallyadditions.chapter.bookStand.text.1=The Manual Stand is a block that is supposed to mainly be used on Servers. You can, provided you are the person who placed it down, set a page in the GUI that will open when someone else accesses it by pressing the "Set Page"-button while being on the desired page. The Manual Stand does not save pages another player navigated to, meaing re-accessing the Stand will cause it to always end up on the page speficied by the placer.