From 833324e150d3dc0fe742528e7616f18315ba8516 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Sun, 9 Jul 2017 12:18:20 -0500 Subject: [PATCH] Some recipes displaying in lexicon again --- .../client/gui/lexicon/GuiLexicon.java | 9 ++-- .../lexicon/button/GuiButtonAchievement.java | 2 +- .../java/vazkii/botania/common/Botania.java | 2 + .../common/crafting/ModCraftingRecipes.java | 51 ++++++++++++++----- .../botania/common/lexicon/LexiconData.java | 8 +-- .../lexicon/page/PageCraftingRecipe.java | 47 +++++------------ 6 files changed, 65 insertions(+), 54 deletions(-) diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java index a5c8eba6d..4784149b6 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java @@ -433,9 +433,12 @@ public class GuiLexicon extends GuiScreen { mc.displayGuiScreen(new GuiBotaniaConfig(this)); break; case -2 : - // todo 1.12 switch to botania tab - if(mc.player != null) - this.mc.displayGuiScreen(new GuiScreenAdvancements(this.mc.player.connection.getAdvancementManager())); + if(mc.player != null) { + GuiScreenAdvancements gui = new GuiScreenAdvancements(this.mc.player.connection.getAdvancementManager()); + this.mc.displayGuiScreen(gui); + ResourceLocation tab = new ResourceLocation(LibMisc.MOD_ID, "main/root"); + gui.setSelectedTab(mc.player.connection.getAdvancementManager().getAdvancementList().getAdvancement(tab)); + } break; case -3 : mc.displayGuiScreen(new GuiLexiconChallengesList()); diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java index e14e47cf7..fb710dab3 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonAchievement.java @@ -37,7 +37,7 @@ public class GuiButtonAchievement extends GuiButtonLexicon { drawTexturedModalRect(x, y, k == 2 ? 109 : 98, 191, 11, 11); List tooltip = new ArrayList<>(); - tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.achievements")); + tooltip.add(TextFormatting.GREEN + I18n.format("botaniamisc.advancements")); int tooltipY = (tooltip.size() - 1) * 10; if(k == 2) diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index 7ac923211..dc3be3763 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -65,6 +65,7 @@ import vazkii.botania.common.core.handler.SheddingHandler; import vazkii.botania.common.core.loot.LootHandler; import vazkii.botania.common.core.proxy.IProxy; import vazkii.botania.common.crafting.ModBrewRecipes; +import vazkii.botania.common.crafting.ModCraftingRecipes; import vazkii.botania.common.crafting.ModElvenTradeRecipes; import vazkii.botania.common.crafting.ModManaAlchemyRecipes; import vazkii.botania.common.crafting.ModManaConjurationRecipes; @@ -147,6 +148,7 @@ public class Botania { ModManaInfusionRecipes.init(); ModElvenTradeRecipes.init(); ModBrewRecipes.init(); + ModCraftingRecipes.init(); LexiconData.init(); NetworkRegistry.INSTANCE.registerGuiHandler(Botania.instance, new GuiHandler()); diff --git a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java index 03e41c45f..a48fb4fd6 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java @@ -20,6 +20,7 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.registries.IForgeRegistry; +import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.crafting.recipe.AesirRingRecipe; import vazkii.botania.common.crafting.recipe.AncientWillRecipe; @@ -44,9 +45,9 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.LibOreDict; -import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Mod.EventBusSubscriber public final class ModCraftingRecipes { @@ -64,7 +65,7 @@ public final class ModCraftingRecipes { public static ResourceLocation recipePool; public static ResourceLocation recipePoolDiluted; public static ResourceLocation recipePoolFabulous; - public static List recipesRuneAltar; + public static ResourceLocation recipeRuneAltar; public static ResourceLocation recipeLensVelocity; public static ResourceLocation recipeLensPotency; public static ResourceLocation recipeLensResistance; @@ -449,28 +450,52 @@ public final class ModCraftingRecipes { addShapelessRecipe(new ItemStack(ModItems.elementiumHelmRevealing), new ItemStack(ModItems.elementiumHelm), goggles); } */ - - recipeLexicon = path("lexicon"); + } + + public static void init() { + // Can't do this in RegistryEvent.Register event handler since it seems JSON recipes aren't loaded yet recipesPetals = allOfGroup("petal"); + recipePestleAndMortar = path("pestleandmortar"); recipesDyes = allOfGroup("dye"); + recipeFertilizerPowder = gogPath("fertilizer_powder"); + recipeFerilizerDye = path("fertilizer_dye"); + recipesPetalsDouble = allOfGroup("petal_double"); recipesPetalBlocks = allOfGroup("petalblock"); recipesReversePetalBlocks = allOfGroup("petal_block_deconstruct"); + + recipesApothecary = allOfGroup("petal_apothecary"); + + recipeLexicon = path("lexicon"); + + // todo 1.12 wands + + recipeLivingwoodTwig = path("manaresource_3"); + + recipeRuneAltar = path("runealtar"); + + recipeTerraPlate = path("terraplate"); + + recipeFlowerBag = path("flowerbag"); } - + + private static ResourceLocation gogPath(String path) { + if(Botania.gardenOfGlassLoaded) { + return new ResourceLocation(LibMisc.MOD_ID, "garden_of_glass/" + path); + } else { + return path(path); + } + } + private static ResourceLocation path(String path) { return new ResourceLocation(LibMisc.MOD_ID, path); } private static List allOfGroup(String group) { String jsonGroup = LibMisc.MOD_ID + ":" + group; - List result = new ArrayList<>(); - for (Map.Entry e : ForgeRegistries.RECIPES.getEntries()) { - if (jsonGroup.equals(e.getValue().getGroup())) { - result.add(e.getKey()); - } - } - - return result; + return ForgeRegistries.RECIPES.getEntries().stream() + .filter(e -> jsonGroup.equals(e.getValue().getGroup())) + .map(Map.Entry::getKey) + .collect(Collectors.toList()); } } diff --git a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java index 743522f9b..e3e3070d8 100644 --- a/src/main/java/vazkii/botania/common/lexicon/LexiconData.java +++ b/src/main/java/vazkii/botania/common/lexicon/LexiconData.java @@ -344,9 +344,9 @@ public final class LexiconData { lexicon.setPriority().setLexiconPages(new PageText("0"), new PageText("3"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeLexicon), new PageText("2")); - wand = new BasicLexiconEntry(LibLexicon.BASICS_WAND, categoryBasics); + /*wand = new BasicLexiconEntry(LibLexicon.BASICS_WAND, categoryBasics); wand.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), - new PageCraftingRecipe("3", ModCraftingRecipes.recipesTwigWand)); + new PageCraftingRecipe("3", ModCraftingRecipes.recipesTwigWand));*/ pureDaisy = new BasicLexiconEntry(LibLexicon.BASICS_PURE_DAISY, categoryBasics); pureDaisy.setPriority() @@ -361,7 +361,7 @@ public final class LexiconData { runicAltar = new BasicLexiconEntry(LibLexicon.BASICS_RUNE_ALTAR, categoryBasics); runicAltar.setPriority().setLexiconPages(new PageText("21"), new PageText("0"), new PageText("1"), - new PageCraftingRecipe("2", ModCraftingRecipes.recipesRuneAltar), new PageText("3"), new PageText("20"), + new PageCraftingRecipe("2", ModCraftingRecipes.recipeRuneAltar), new PageText("3"), new PageText("20"), new PageText("22"), new PageRuneRecipe("4", ModRuneRecipes.recipeWaterRune), new PageRuneRecipe("5", ModRuneRecipes.recipesEarthRune), new PageRuneRecipe("6", ModRuneRecipes.recipesAirRune), @@ -392,6 +392,8 @@ public final class LexiconData { flowerBag.setLexiconPages(new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlowerBag)); + if(true) return; + if (Botania.gardenOfGlassLoaded) { gardenOfGlass = new BasicLexiconEntry(LibLexicon.BASICS_GARDEN_OF_GLASS, categoryBasics); gardenOfGlass.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"), diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java index 8855f145b..9837fb55f 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageCraftingRecipe.java @@ -128,60 +128,39 @@ public class PageCraftingRecipe extends PageRecipe { @SideOnly(Side.CLIENT) public void renderCraftingRecipe(IGuiLexiconEntry gui, IRecipe recipe) { - if(recipe instanceof ShapedRecipes) { - ShapedRecipes shaped = (ShapedRecipes)recipe; + if(recipe instanceof ShapedRecipes || recipe instanceof ShapedOreRecipe) { + oreDictRecipe = recipe instanceof ShapedOreRecipe; - for(int y = 0; y < shaped.recipeHeight; y++) - for(int x = 0; x < shaped.recipeWidth; x++) - renderItemAtGridPos(gui, 1 + x, 1 + y, shaped.recipeItems.get(y * shaped.recipeWidth + x).getMatchingStacks()[0], true); - } else if(recipe instanceof ShapedOreRecipe) { - ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; - int width = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4); - int height = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5); + int width = oreDictRecipe + ? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, "width") + : ((ShapedRecipes) recipe).getWidth(); + int height = oreDictRecipe + ? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, "height") + : ((ShapedRecipes) recipe).getHeight(); for(int y = 0; y < height; y++) for(int x = 0; x < width; x++) { - Ingredient input = shaped.getIngredients().get(y * width + x); + Ingredient input = recipe.getIngredients().get(y * width + x); if(input != Ingredient.EMPTY) renderItemAtGridPos(gui, 1 + x, 1 + y, input.getMatchingStacks()[0], true); } - - oreDictRecipe = true; - } else if(recipe instanceof ShapelessRecipes) { - ShapelessRecipes shapeless = (ShapelessRecipes) recipe; - - drawGrid : { - for(int y = 0; y < 3; y++) - for(int x = 0; x < 3; x++) { - int index = y * 3 + x; - - if(index >= shapeless.recipeItems.size()) - break drawGrid; - - renderItemAtGridPos(gui, 1 + x, 1 + y, shapeless.recipeItems.get(index).getMatchingStacks()[0], true); - } - } - + } else if(recipe instanceof ShapelessRecipes || recipe instanceof ShapelessOreRecipe) { shapelessRecipe = true; - } else if(recipe instanceof ShapelessOreRecipe) { - ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; + oreDictRecipe = recipe instanceof ShapelessOreRecipe; drawGrid : { for(int y = 0; y < 3; y++) for(int x = 0; x < 3; x++) { int index = y * 3 + x; - if(index >= shapeless.getIngredients().size()) + if(index >= recipe.getIngredients().size()) break drawGrid; - Ingredient input = shapeless.getIngredients().get(index); + Ingredient input = recipe.getIngredients().get(index); if(input != Ingredient.EMPTY) renderItemAtGridPos(gui, 1 + x, 1 + y, input.getMatchingStacks()[0], true); } } - - shapelessRecipe = true; - oreDictRecipe = true; } renderItemAtGridPos(gui, 2, 0, recipe.getRecipeOutput(), false);