diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java index 42696ea2b..e20ce714f 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerPetalApothecary.java @@ -4,6 +4,7 @@ import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; @@ -13,6 +14,7 @@ import org.lwjgl.opengl.GL11; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePetals; +import vazkii.botania.client.integration.nei.NEIHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; import codechicken.lib.gui.GuiDraw; @@ -22,117 +24,146 @@ import codechicken.nei.recipe.TemplateRecipeHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; public class RecipeHandlerPetalApothecary extends TemplateRecipeHandler { + private static final ItemStack altarStack = new ItemStack(ModBlocks.altar); - public class CachedPetalApothecaryRecipe extends CachedRecipe { + public abstract class CachedCircleRecipe extends CachedRecipe { - public List inputs = new ArrayList<>(); - public PositionedStack output; + public List inputs = new ArrayList<>(); + public PositionedStack output; + public boolean renderItem; - public CachedPetalApothecaryRecipe(RecipePetals recipe, boolean addCenterItem) { - setIngredients(recipe.getInputs()); - output = new PositionedStack(recipe.getOutput(), 111, 21); - if(addCenterItem) - inputs.add(new PositionedStack(new ItemStack(ModBlocks.altar), 73, 55)); - } + public CachedCircleRecipe(RecipePetals recipe) { + setIngredients(recipe.getInputs()); + output = new PositionedStack(recipe.getOutput(), 111, 21); + renderItem = true; + } - public CachedPetalApothecaryRecipe(RecipePetals recipe) { - this(recipe, true); - } + public void setIngredients(List inputs) { + float degreePerInput = 360F / inputs.size(); + float currentDegree = -90F; - public void setIngredients(List inputs) { - float degreePerInput = 360F / inputs.size(); - float currentDegree = -90F; + for (Object o : inputs) { + int posX = (int) Math.round(73 + Math.cos(currentDegree * Math.PI / 180D) * 32); + int posY = (int) Math.round(55 + Math.sin(currentDegree * Math.PI / 180D) * 32); - for(Object o : inputs) { - int posX = (int) Math.round(73 + Math.cos(currentDegree * Math.PI / 180D) * 32); - int posY = (int) Math.round(55 + Math.sin(currentDegree * Math.PI / 180D) * 32); + if (o instanceof String) { + this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), posX, posY)); + } else { + this.inputs.add(new PositionedStack(o, posX, posY)); + } + currentDegree += degreePerInput; + } + } - if(o instanceof String) - this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), posX, posY)); - else this.inputs.add(new PositionedStack(o, posX, posY)); - currentDegree += degreePerInput; - } - } + @Override + public List getIngredients() { + return inputs; + } - @Override - public List getIngredients() { - return inputs; - } + @Override + public PositionedStack getResult() { + return output; + } + } - @Override - public PositionedStack getResult() { - return output; - } + public class CachedPetalApothecaryRecipe extends CachedCircleRecipe { + ItemStack seedStack = new ItemStack(Items.wheat_seeds); - } + public CachedPetalApothecaryRecipe(RecipePetals recipe) { + super(recipe); + seedStack.setStackDisplayName(StatCollector.translateToLocal("botania.nei.anySeed")); + inputs.add(new PositionedStack(seedStack, 73, 39)); + } - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.petalApothecary"); - } + // Used by the Alfheim addon + @SuppressWarnings("unused") + public CachedPetalApothecaryRecipe(RecipePetals recipe, boolean addCenterItem) { + super(recipe); + renderItem = addCenterItem; + } + } - public String getRecipeID() { - return "botania.petalApothecary"; - } + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.petalApothecary"); + } - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } + @Override + public String getOverlayIdentifier() { + return "botania.petalApothecary"; + } - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(72, 54, 18, 18), getRecipeID())); - } + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - GuiDraw.changeTexture(LibResources.GUI_PETAL_OVERLAY); - GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92); - } + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(73, 56, 16, 16), getOverlayIdentifier())); + } - public List getRecipes() { - return BotaniaAPI.petalRecipes; - } + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + // Background circle graphic + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GuiDraw.changeTexture(LibResources.GUI_PETAL_OVERLAY); + GuiDraw.drawTexturedModalRect(45, 10, 38, 7, 92, 92); + // Item + if (!((CachedCircleRecipe) arecipes.get(recipe)).renderItem) return; + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL11.GL_DEPTH_TEST); + NEIHelper.renderItem.renderItemIntoGUI(NEIHelper.font, NEIHelper.textureManager, getRenderItem(), 73, 55); + GL11.glDisable(GL11.GL_DEPTH_TEST); + RenderHelper.disableStandardItemLighting(); + } - public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { - return new CachedPetalApothecaryRecipe(recipe); - } + protected ItemStack getRenderItem() { + return altarStack; + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals(getRecipeID())) { - for(RecipePetals recipe : getRecipes()) - if(recipe.getOutput().getItem() != Items.skull) - arecipes.add(getCachedRecipe(recipe)); - } else super.loadCraftingRecipes(outputId, results); - } + public List getRecipes() { + return BotaniaAPI.petalRecipes; + } - @Override - public void loadCraftingRecipes(ItemStack result) { - for(RecipePetals recipe : getRecipes()){ - if(recipe == null) - continue; + public CachedCircleRecipe getCachedRecipe(RecipePetals recipe) { + return new CachedPetalApothecaryRecipe(recipe); + } - if(recipe.getOutput().stackTagCompound != null && ItemNBTHelper.areStacksSameTypeWithNBT(recipe.getOutput(), result) || recipe.getOutput().stackTagCompound == null && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result) && recipe.getOutput().getItem() != Items.skull) - arecipes.add(getCachedRecipe(recipe)); - } - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + for (RecipePetals recipe : getRecipes()) + if (recipe.getOutput().getItem() != Items.skull) + arecipes.add(getCachedRecipe(recipe)); + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for(RecipePetals recipe : getRecipes()) { - if(recipe == null) - continue; + @Override + public void loadCraftingRecipes(ItemStack result) { + for (RecipePetals recipe : getRecipes()) { + if (recipe == null) continue; - CachedPetalApothecaryRecipe crecipe = getCachedRecipe(recipe); - if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient) && recipe.getOutput().getItem() != Items.skull) - arecipes.add(crecipe); - } - } + if (recipe.getOutput().stackTagCompound != null && ItemNBTHelper.areStacksSameTypeWithNBT(recipe.getOutput(), result) || recipe.getOutput().stackTagCompound == null && NEIServerUtils.areStacksSameTypeCrafting(recipe.getOutput(), result) && recipe.getOutput().getItem() != Items.skull) { + arecipes.add(getCachedRecipe(recipe)); + } + } + } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (RecipePetals recipe : getRecipes()) { + if (recipe == null) continue; + + CachedCircleRecipe crecipe = getCachedRecipe(recipe); + if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient) && recipe.getOutput().getItem() != Items.skull) { + arecipes.add(crecipe); + } + } + } } diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java index 506ad540d..b1b5fc08d 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerRunicAltar.java @@ -14,44 +14,49 @@ import codechicken.nei.PositionedStack; public class RecipeHandlerRunicAltar extends RecipeHandlerPetalApothecary { - public class CachedRunicAltarRecipe extends CachedPetalApothecaryRecipe { + private static final ItemStack altarStack = new ItemStack(ModBlocks.runeAltar); - public int manaUsage; + public class CachedRunicAltarRecipe extends CachedCircleRecipe { - public CachedRunicAltarRecipe(RecipeRuneAltar recipe) { - super(recipe, false); - if(recipe == null) - return; - manaUsage = recipe.getManaUsage(); - inputs.add(new PositionedStack(new ItemStack(ModBlocks.runeAltar), 73, 55)); - } + public int manaUsage; + private static final PositionedStack livingrock = new PositionedStack(new ItemStack(ModBlocks.livingrock), 73, 39); - } + public CachedRunicAltarRecipe(RecipeRuneAltar recipe) { + super(recipe); + inputs.add(livingrock); + manaUsage = recipe.getManaUsage(); + } + } + + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.runicAltar"); + } + + @Override + public String getOverlayIdentifier() { + return "botania.runicAltar"; + } + + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + HUDHandler.renderManaBar(32, 113, 0x0000FF, 0.75F, ((CachedRunicAltarRecipe) arecipes.get(recipe)).manaUsage, TilePool.MAX_MANA / 10); + } + + @Override + public List getRecipes() { + return BotaniaAPI.runeAltarRecipes; + } + + @Override + public CachedCircleRecipe getCachedRecipe(RecipePetals recipe) { + return new CachedRunicAltarRecipe((RecipeRuneAltar) recipe); + } @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.runicAltar"); - } - - @Override - public String getRecipeID() { - return "botania.runicAltar"; - } - - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - HUDHandler.renderManaBar(32, 113, 0x0000FF, 0.75F, ((CachedRunicAltarRecipe) arecipes.get(recipe)).manaUsage, TilePool.MAX_MANA / 10); - } - - @Override - public List getRecipes() { - return BotaniaAPI.runeAltarRecipes; - } - - @Override - public CachedPetalApothecaryRecipe getCachedRecipe(RecipePetals recipe) { - return new CachedRunicAltarRecipe((RecipeRuneAltar) recipe); - } + protected ItemStack getRenderItem() { + return altarStack; + } } diff --git a/src/main/resources/assets/botania/lang/en_US.lang b/src/main/resources/assets/botania/lang/en_US.lang index f7d6279cc..a951b9d87 100644 --- a/src/main/resources/assets/botania/lang/en_US.lang +++ b/src/main/resources/assets/botania/lang/en_US.lang @@ -184,6 +184,8 @@ botania.nei.pureDaisy=Pure Daisy botania.nei.lexica=Lexica Botania nei.options.keys.gui.botania_corporea_request=Corporea Request +botania.nei.anySeed=Any Seed + botania.nei.lexicaSeparator=Extra Info: botania.nei.lexicaNoInfo=(there's no Extra Info for this entry, sorry!)