From 1209aa7d293f95739e6dc357d75e71875dc9e9f7 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 10 Nov 2015 21:26:28 +0100 Subject: [PATCH] Misc Crusher Recipes --- .../booklet/BookletChapterCrusher.java | 39 +++++++++++++++++++ .../booklet/InitBooklet.java | 2 +- .../booklet/page/PageCrusherRecipe.java | 25 ++++-------- .../config/values/ConfigCrafting.java | 1 + .../crafting/CrusherCrafting.java | 39 +++++++++++++++++++ .../actuallyadditions/ore/InitOreDict.java | 19 +++++++++ 6 files changed, 107 insertions(+), 18 deletions(-) create mode 100644 src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterCrusher.java diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterCrusher.java b/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterCrusher.java new file mode 100644 index 000000000..1e5db8aef --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterCrusher.java @@ -0,0 +1,39 @@ +/* + * This file ("BookletChapterCrusher.java") is part of the Actually Additions Mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.booklet; + +import ellpeck.actuallyadditions.booklet.page.BookletPage; +import ellpeck.actuallyadditions.booklet.page.PageCrusherRecipe; +import ellpeck.actuallyadditions.crafting.CrusherCrafting; +import ellpeck.actuallyadditions.recipe.CrusherRecipeRegistry; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.Arrays; + +public class BookletChapterCrusher extends BookletChapter{ + + public BookletChapterCrusher(String unlocalizedName, BookletIndexEntry entry, ItemStack displayStack, BookletPage... pages){ + super(unlocalizedName, entry, displayStack, getPages(pages)); + } + + @SuppressWarnings("unchecked") + private static BookletPage[] getPages(BookletPage... pages){ + ArrayList allPages = new ArrayList(); + allPages.addAll(Arrays.asList(pages)); + + for(CrusherRecipeRegistry.CrusherRecipe recipe : CrusherCrafting.miscRecipes){ + allPages.add(new PageCrusherRecipe(allPages.size()+1, recipe).setNoText()); + } + + return allPages.toArray(new BookletPage[allPages.size()]); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index deba0f12a..93c5a4c8c 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -78,7 +78,7 @@ public class InitBooklet{ //RF Using Blocks new BookletChapter("laserRelays", entryFunctionalRF, new ItemStack(InitBlocks.blockLaserRelay), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.LASER_RELAY_MAX_DISTANCE.getValue()).addTextReplacement("", ConfigIntValues.LASER_RELAY_LOSS.getValue()), new PagePicture(2, "pageLaserRelay", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLaserRelay).setNoText(), new PageCrafting(4, ItemCrafting.recipeLaserWrench).setNoText()).setImportant(); new BookletChapterCoffee("coffeeMachine", entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("", ConfigIntValues.COFFEE_MACHINE_ENERGY_USED.getValue()).addTextReplacement("", ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue()).addTextReplacement("", ConfigIntValues.COFFEE_MACHINE_WATER_USED.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemCoffee)), new PagePicture(3, "pageCoffeeMachine", 115), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setNoText(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()).setImportant(); - new BookletChapter("crusher", entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.GRINDER_ENERGY_USED.getValue()).addTextReplacement("", ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue()), new PageCrafting(2, BlockCrafting.recipeCrusher).setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setNoText(), new PageCrusherRecipe(4, CrusherCrafting.recipeSugar).setNoText(), new PageCrusherRecipe(5, CrusherCrafting.recipeIronHorseArmor).setNoText(), new PageCrusherRecipe(6, CrusherCrafting.recipeGoldHorseArmor).setNoText(), new PageCrusherRecipe(7, CrusherCrafting.recipeDiamondHorseArmor).setNoText()); + new BookletChapterCrusher("crusher", entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.GRINDER_ENERGY_USED.getValue()).addTextReplacement("", ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue()), new PageCrafting(2, BlockCrafting.recipeCrusher).setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setNoText(), new PageCrusherRecipe(4, CrusherCrafting.recipeSugar).setNoText(), new PageCrusherRecipe(5, CrusherCrafting.recipeIronHorseArmor).setNoText(), new PageCrusherRecipe(6, CrusherCrafting.recipeGoldHorseArmor).setNoText(), new PageCrusherRecipe(7, CrusherCrafting.recipeDiamondHorseArmor).setNoText()); new BookletChapter("furnaceDouble", entryFunctionalRF, new ItemStack(InitBlocks.blockFurnaceDouble), new PageCrafting(1, BlockCrafting.recipeFurnace).addTextReplacement("", ConfigIntValues.FURNACE_ENERGY_USED.getValue())); new BookletChapter("lavaFactory", entryFunctionalRF, new ItemStack(InitBlocks.blockLavaFactoryController), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.LAVA_FACTORY_ENERGY_USED.getValue()), new PagePicture(2, "pageLavaFactory", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLavaFactory).setNoText(), new PageCrafting(4, BlockCrafting.recipeCasing).setNoText()); new BookletChapter("energizer", entryFunctionalRF, new ItemStack(InitBlocks.blockEnergizer), new PageCrafting(1, BlockCrafting.recipeEnergizer), new PageCrafting(2, BlockCrafting.recipeEnervator)); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java index 02aad62f3..ef2b6e4ad 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java @@ -26,9 +26,7 @@ public class PageCrusherRecipe extends BookletPage{ public CrusherRecipeRegistry.CrusherRecipe recipe; - private int inputPos; - private int outOnePos; - private int outTwoPos; + private int recipePos; public PageCrusherRecipe(int id, CrusherRecipeRegistry.CrusherRecipe recipe){ super(id); @@ -71,14 +69,14 @@ public class PageCrusherRecipe extends BookletPage{ ItemStack stack; switch(j){ case 0: - stack = this.recipe.getRecipeInputs().get(this.inputPos); + stack = this.recipe.getRecipeInputs().get(Math.min(this.recipe.getRecipeInputs().size()-1, this.recipePos)); break; case 1: - stack = this.recipe.getRecipeOutputOnes().get(this.outOnePos); + stack = this.recipe.getRecipeOutputOnes().get(Math.min(this.recipe.getRecipeOutputOnes().size()-1, this.recipePos)); break; default: ArrayList outputTwos = this.recipe.getRecipeOutputTwos(); - stack = outputTwos == null ? null : outputTwos.get(this.outTwoPos); + stack = outputTwos == null ? null : outputTwos.get(Math.min(outputTwos.size()-1, this.recipePos)); break; } @@ -109,19 +107,12 @@ public class PageCrusherRecipe extends BookletPage{ @Override public void updateScreen(int ticksElapsed){ if(ticksElapsed%10 == 0){ - if(this.inputPos+1 < this.recipe.getRecipeInputs().size()){ - this.inputPos++; - } - else if(this.outOnePos+1 < this.recipe.getRecipeOutputOnes().size()){ - this.outOnePos++; - } - else if(this.recipe.getRecipeOutputTwos() != null && this.outTwoPos+1 < this.recipe.getRecipeOutputTwos().size()){ - this.outTwoPos++; + ArrayList outputTwos = this.recipe.getRecipeOutputTwos(); + if(this.recipePos+1 >= Math.max(this.recipe.getRecipeInputs().size(), Math.max(this.recipe.getRecipeOutputOnes().size(), outputTwos == null ? 0 : outputTwos.size()))){ + this.recipePos = 0; } else{ - this.inputPos = 0; - this.outOnePos = 0; - this.outTwoPos = 0; + this.recipePos++; } } } diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java index b8423fdf9..6828cd565 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java @@ -144,6 +144,7 @@ public enum ConfigCrafting{ NICKEL("Nickel Ore -> Nickel Dust + Platinum Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"), IRON("Iron Ore -> Iron Dust + Gold Dust", ConfigCategories.CRUSHER_RECIPES, "Crusher"), HORSE_ARMORS("Horse Armor -> Raw Materials", ConfigCategories.CRUSHER_RECIPES, "Crusher"), + CRUSHER_MISC("Misc. Crusher Recipes like Bone Meal & Dyes", ConfigCategories.CRUSHER_RECIPES, "Crusher"), TELE_STAFF("Tele Staff", ConfigCategories.ITEMS_CRAFTING), CASING("Casing", ConfigCategories.BLOCKS_CRAFTING), diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java index daec1de77..a03397f69 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/CrusherCrafting.java @@ -15,16 +15,55 @@ import ellpeck.actuallyadditions.recipe.CrusherRecipeRegistry; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; +import java.util.ArrayList; + public class CrusherCrafting{ public static CrusherRecipeRegistry.CrusherRecipe recipeSugar; public static CrusherRecipeRegistry.CrusherRecipe recipeIronHorseArmor; public static CrusherRecipeRegistry.CrusherRecipe recipeGoldHorseArmor; public static CrusherRecipeRegistry.CrusherRecipe recipeDiamondHorseArmor; + public static ArrayList miscRecipes = new ArrayList(); public static void init(){ ModUtil.LOGGER.info("Initializing Crusher Recipes..."); + if(ConfigCrafting.CRUSHER_MISC.isEnabled()){ + CrusherRecipeRegistry.addRecipe("itemBone", "boneMeal", 6); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("sugarCane", "sugar", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + + CrusherRecipeRegistry.addRecipe("flowerDandelion", "dyeYellow", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerPoppy", "dyeRed", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerOrchid", "dyeLightBlue", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerAllium", "dyeMagenta", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerBluet", "dyeLightGray", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerRedTulip", "dyeRed", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerOrangeTulip", "dyeOrange", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerWhiteTulip", "dyeLightGray", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerPinkTulip", "dyePink", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerDaisy", "dyeLightGray", 3); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerSunflower", "dyeYellow", 4); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerLilac", "dyeMagenta", 4); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerRoseBush", "dyeRed", 4); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + CrusherRecipeRegistry.addRecipe("flowerPeony", "dyePink", 4); + miscRecipes.add(Util.GetRecipes.lastCrusherRecipe()); + } + if(ConfigCrafting.REDSTONE.isEnabled()){ CrusherRecipeRegistry.addRecipe("oreRedstone", "dustRedstone", 10); } diff --git a/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java b/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java index dddcd055e..d4255ffd1 100644 --- a/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java +++ b/src/main/java/ellpeck/actuallyadditions/ore/InitOreDict.java @@ -39,6 +39,25 @@ public class InitOreDict{ addOre(Items.diamond_horse_armor, "armorHorseDiamond"); addOre(Items.golden_horse_armor, "armorHorseGold"); addOre(Items.iron_horse_armor, "armorHorseIron"); + addOre(Items.bone, "itemBone"); + addOre(Items.dye, 15, "boneMeal"); + addOre(Items.sugar, "sugar"); + addOre(Items.reeds, "sugarCane"); + + addOre(Blocks.yellow_flower, "flowerDandelion"); + addOre(Blocks.red_flower, "flowerPoppy"); + addOre(Blocks.red_flower, 1, "flowerOrchid"); + addOre(Blocks.red_flower, 2, "flowerAllium"); + addOre(Blocks.red_flower, 3, "flowerBluet"); + addOre(Blocks.red_flower, 4, "flowerRedTulip"); + addOre(Blocks.red_flower, 5, "flowerOrangeTulip"); + addOre(Blocks.red_flower, 6, "flowerWhiteTulip"); + addOre(Blocks.red_flower, 7, "flowerPinkTulip"); + addOre(Blocks.red_flower, 8, "flowerDaisy"); + addOre(Blocks.double_plant, 0, "flowerSunflower"); + addOre(Blocks.double_plant, 1, "flowerLilac"); + addOre(Blocks.double_plant, 4, "flowerRoseBush"); + addOre(Blocks.double_plant, 5, "flowerPeony"); //My Ores addOre(InitItems.itemDust, TheDusts.IRON.ordinal(), "dustIron");