From bdd87c621cfe545d26bad61f785070cffde12941 Mon Sep 17 00:00:00 2001 From: Shadows_of_Fire Date: Fri, 29 Jun 2018 16:32:33 -0400 Subject: [PATCH] Closes #1137 --- .../mod/booklet/InitBooklet.java | 58 +++++++++++++++++-- .../mod/crafting/CrusherCrafting.java | 49 ++++++++++------ 2 files changed, 84 insertions(+), 23 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index 907262b09..ee8efa874 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -10,6 +10,12 @@ package de.ellpeck.actuallyadditions.mod.booklet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; @@ -26,8 +32,21 @@ import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterTrials; import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntry; import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllItems; import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryTrials; -import de.ellpeck.actuallyadditions.mod.booklet.page.*; -import de.ellpeck.actuallyadditions.mod.crafting.*; +import de.ellpeck.actuallyadditions.mod.booklet.page.BookletPage; +import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrafting; +import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe; +import de.ellpeck.actuallyadditions.mod.booklet.page.PageEmpowerer; +import de.ellpeck.actuallyadditions.mod.booklet.page.PageFurnace; +import de.ellpeck.actuallyadditions.mod.booklet.page.PageLinkButton; +import de.ellpeck.actuallyadditions.mod.booklet.page.PagePicture; +import de.ellpeck.actuallyadditions.mod.booklet.page.PageReconstructor; +import de.ellpeck.actuallyadditions.mod.booklet.page.PageTextOnly; +import de.ellpeck.actuallyadditions.mod.crafting.BlockCrafting; +import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; +import de.ellpeck.actuallyadditions.mod.crafting.FoodCrafting; +import de.ellpeck.actuallyadditions.mod.crafting.ItemCrafting; +import de.ellpeck.actuallyadditions.mod.crafting.MiscCrafting; +import de.ellpeck.actuallyadditions.mod.crafting.ToolCrafting; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.gen.OreGen; import de.ellpeck.actuallyadditions.mod.gen.WorldGenLushCaves; @@ -40,7 +59,28 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler; -import de.ellpeck.actuallyadditions.mod.tile.*; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceSolar; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityHeatCollector; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyAdvanced; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyExtreme; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityShockSuppressor; import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.init.Blocks; @@ -51,7 +91,6 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; -import java.util.*; public final class InitBooklet{ @@ -226,7 +265,16 @@ public final class InitBooklet{ new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFarmer), new PageTextOnly(1), new PagePicture(2, "page_farmer_crops", 95).addItemsToPage(new ItemStack(Items.WHEAT_SEEDS)).addItemsToPage(new ItemStack(InitItems.itemCanolaSeed)), new PagePicture(3, "page_farmer_cactus", 105).addItemsToPage(new ItemStack(Blocks.CACTUS)), new PagePicture(4, "page_farmer_wart", 95).addItemsToPage(new ItemStack(Items.NETHER_WART)), new PagePicture(5, "page_farmer_reeds", 105).addItemsToPage(new ItemStack(Items.REEDS)), new PagePicture(6, "page_farmer_melons", 105).addItemsToPage(new ItemStack(Items.MELON), new ItemStack(Blocks.PUMPKIN), new ItemStack(Blocks.MELON_BLOCK)), new PagePicture(7, "page_farmer_enderlilly", 105), new PagePicture(8, "page_farmer_redorchid", 105), new PageCrafting(4, BlockCrafting.recipeFarmer).setWildcard().setNoText()).setImportant(); new BookletChapter("miner", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockMiner), new PageTextOnly(1).addTextReplacement("", TileEntityMiner.ENERGY_USE_PER_BLOCK).addTextReplacement("", TileEntityMiner.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipeMiner)).setSpecial(); new BookletChapterCoffee("coffeeMachine", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("", TileEntityCoffeeMachine.ENERGY_USED).addTextReplacement("", TileEntityCoffeeMachine.CACHE_USE).addTextReplacement("", TileEntityCoffeeMachine.WATER_USE), new PageTextOnly(2).addItemsToPage(new ItemStack(InitItems.itemCoffee)), new PagePicture(3, "page_coffee_machine", 115), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setWildcard().setNoText(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()).setImportant(); - new BookletChapterCrusher("crusher", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("", TileEntityGrinder.ENERGY_USE), new PageCrafting(2, BlockCrafting.recipeCrusher).setWildcard().setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setWildcard().setNoText(), new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText(), new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText(), new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText()); + + List list = new ArrayList<>(); + list.add(new PageTextOnly(1).addTextReplacement("", TileEntityGrinder.ENERGY_USE)); + list.add(new PageCrafting(2, BlockCrafting.recipeCrusher).setWildcard().setNoText()); + list.add(new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setWildcard().setNoText()); + if(CrusherCrafting.recipeIronHorseArmor != null) list.add(new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText()); + if(CrusherCrafting.recipeGoldHorseArmor != null) list.add(new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText()); + if(CrusherCrafting.recipeDiamondHorseArmor != null) list.add(new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText()); + + new BookletChapterCrusher("crusher", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), list.toArray(new IBookletPage[0])); new BookletChapter("furnaceDouble", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFurnaceDouble), new PageCrafting(1, BlockCrafting.recipeFurnace).setWildcard().addTextReplacement("", TileEntityFurnaceDouble.ENERGY_USE)); new BookletChapter("lavaFactory", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockLavaFactoryController), new PageTextOnly(1).addTextReplacement("", TileEntityLavaFactoryController.ENERGY_USE), new PagePicture(2, "page_lava_factory", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLavaFactory).setNoText(), new PageCrafting(4, BlockCrafting.recipeCasing).setNoText()); new BookletChapter("energizer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockEnergizer), new PageCrafting(1, BlockCrafting.recipeEnergizer), new PageCrafting(2, BlockCrafting.recipeEnervator)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java index eda5e00fc..2b7a2ce7a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.crafting; import java.util.ArrayList; +import java.util.List; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; @@ -28,16 +29,16 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreIngredient; -public final class CrusherCrafting{ +public final class CrusherCrafting { public static final ArrayList MISC_RECIPES = new ArrayList<>(); public static CrusherRecipe recipeIronHorseArmor; public static CrusherRecipe recipeGoldHorseArmor; public static CrusherRecipe recipeDiamondHorseArmor; - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing Crusher Recipes..."); - + ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.BONE), new ItemStack(Items.DYE, 6, 15), StackUtil.getEmpty(), 0); MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.REEDS), new ItemStack(Items.SUGAR, 3), StackUtil.getEmpty(), 0); @@ -77,9 +78,9 @@ public final class CrusherCrafting{ ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreRedstone"), new ItemStack(Items.REDSTONE, 10), StackUtil.getEmpty(), 0); ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreLapis"), new ItemStack(Items.DYE, 12, 4), StackUtil.getEmpty(), 0); ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("coal"), new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal()), StackUtil.getEmpty(), 0); - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreCoal"), new ItemStack(Items.COAL,3), StackUtil.getEmpty(), 0); - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("blockCoal"), new ItemStack(Items.COAL,9), StackUtil.getEmpty(), 0); - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreQuartz"), new ItemStack(Items.QUARTZ,3), StackUtil.getEmpty(), 0); + ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreCoal"), new ItemStack(Items.COAL, 3), StackUtil.getEmpty(), 0); + ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("blockCoal"), new ItemStack(Items.COAL, 9), StackUtil.getEmpty(), 0); + ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreQuartz"), new ItemStack(Items.QUARTZ, 3), StackUtil.getEmpty(), 0); ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("cobblestone"), new ItemStack(Blocks.SAND), StackUtil.getEmpty(), 0); ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.GRAVEL), new ItemStack(Items.FLINT), new ItemStack(Items.FLINT), 50); ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("stone", false), OreDictionary.getOres("cobblestone", false), 1, NonNullList.withSize(1, StackUtil.getEmpty()), 0, 0); @@ -93,20 +94,26 @@ public final class CrusherCrafting{ ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreNickel", false), OreDictionary.getOres("dustNickel", false), 2, OreDictionary.getOres("dustPlatinum", false), 1, 15); ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreIron", false), OreDictionary.getOres("dustIron", false), 2, OreDictionary.getOres("dustGold", false), 1, 20); - ItemStack temp = OreDictionary.getOres("dustIron").get(0).copy(); - temp.setCount(6); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.IRON_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); - recipeIronHorseArmor = RecipeUtil.lastCrusherRecipe(); + ItemStack temp = getStack("dustIron"); + if (!temp.isEmpty()) { + temp.setCount(6); + ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.IRON_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); + recipeIronHorseArmor = RecipeUtil.lastCrusherRecipe(); + } - temp = OreDictionary.getOres("dustGold").get(0).copy(); - temp.setCount(6); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.GOLDEN_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); - recipeGoldHorseArmor = RecipeUtil.lastCrusherRecipe(); + temp = getStack("dustGold"); + if (!temp.isEmpty()) { + temp.setCount(6); + ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.GOLDEN_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); + recipeGoldHorseArmor = RecipeUtil.lastCrusherRecipe(); + } - temp = OreDictionary.getOres("dustDiamond").get(0).copy(); - temp.setCount(6); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.DIAMOND_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); - recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe(); + temp = getStack("dustDiamond"); + if (!temp.isEmpty()) { + temp.setCount(6); + ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.DIAMOND_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); + recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe(); + } CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6)); CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("orePoor", 4, "nugget")); @@ -118,4 +125,10 @@ public final class CrusherCrafting{ CrusherRecipeRegistry.registerFinally(); } + + private static ItemStack getStack(String ore) { + List stacks = OreDictionary.getOres(ore); + if (stacks.isEmpty()) return StackUtil.getEmpty(); + return stacks.get(0).copy(); + } }