mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Added support for Petal and Rune recipes to the Lexicon.
This commit is contained in:
1 parent
18edc3a42d
commit
bdcc8ff3ff
9 files changed
+107
-24
No files matched your search
@@ -55,7 +55,7 @@ public final class BotaniaAPI {
|
||||
* Registers a Petal Recipe.
|
||||
* @param output The ItemStack to craft.
|
||||
* @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper
|
||||
* or String (case for Ore Dictionary)
|
||||
* or String (case for Ore Dictionary). The array can't be larger than 16.
|
||||
* @return The recipe created.
|
||||
*/
|
||||
public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) {
|
||||
@@ -69,7 +69,7 @@ public final class BotaniaAPI {
|
||||
* @param output The ItemStack to craft.
|
||||
* @param mana The amount of mana required. Don't go over 100000!
|
||||
* @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper
|
||||
* or String (case for Ore Dictionary)
|
||||
* or String (case for Ore Dictionary). The array can't be larger than 16.
|
||||
* @return The recipe created.
|
||||
*/
|
||||
public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) {
|
||||
|
||||
@@ -61,6 +61,10 @@ public class RecipePetals {
|
||||
|
||||
return inputsMissing.isEmpty();
|
||||
}
|
||||
|
||||
public List<Object> getInputs() {
|
||||
return new ArrayList(inputs);
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
|
||||
@@ -28,6 +28,7 @@ public final class LibResources {
|
||||
public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png";
|
||||
public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png";
|
||||
public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png";
|
||||
public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png";
|
||||
|
||||
public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png";
|
||||
public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png";
|
||||
|
||||
@@ -17,9 +17,13 @@ import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.crafting.ModCrafingRecipes;
|
||||
import vazkii.botania.common.crafting.ModManaInfusionRecipes;
|
||||
import vazkii.botania.common.crafting.ModPetalRecipes;
|
||||
import vazkii.botania.common.crafting.ModRuneRecipes;
|
||||
import vazkii.botania.common.lexicon.page.PageCraftingRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PageImage;
|
||||
import vazkii.botania.common.lexicon.page.PageManaInfusionRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PagePetalRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PageRuneRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PageText;
|
||||
import vazkii.botania.common.lib.LibLexicon;
|
||||
|
||||
@@ -64,7 +68,7 @@ public final class LexiconData {
|
||||
|
||||
// MANA ENTRIES
|
||||
pool = new BLexiconEntry(LibLexicon.MANA_POOL, categoryMana);
|
||||
pool.setPriority().setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", ModManaInfusionRecipes.manaPetalRecipes));
|
||||
pool.setPriority().setLexiconPages(new PageText("0"), new PageManaInfusionRecipe("1", ModManaInfusionRecipes.manaPetalRecipes), new PagePetalRecipe("2", ModPetalRecipes.testRecipe), new PageRuneRecipe("3", ModRuneRecipes.recipeDebug));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,42 +15,75 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public class PagePetalRecipe extends PageRecipe {
|
||||
public class PagePetalRecipe<T extends RecipePetals> extends PageRecipe {
|
||||
|
||||
List<RecipePetals> recipes;
|
||||
private static final ResourceLocation petalOverlay = new ResourceLocation(LibResources.GUI_PETAL_OVERLAY);
|
||||
|
||||
List<T> recipes;
|
||||
int ticksElapsed = 0;
|
||||
int recipeAt = 0;
|
||||
|
||||
public PagePetalRecipe(String unlocalizedName, List<RecipePetals> recipes) {
|
||||
public PagePetalRecipe(String unlocalizedName, List<T> recipes) {
|
||||
super(unlocalizedName);
|
||||
this.recipes = recipes;
|
||||
}
|
||||
|
||||
public PagePetalRecipe(String unlocalizedName, RecipePetals recipe) {
|
||||
public PagePetalRecipe(String unlocalizedName, T recipe) {
|
||||
this(unlocalizedName, Arrays.asList(recipe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRecipe(IGuiLexiconEntry gui, int mx, int my) {
|
||||
RecipePetals recipe = recipes.get(recipeAt);
|
||||
T recipe = recipes.get(recipeAt);
|
||||
TextureManager render = Minecraft.getMinecraft().renderEngine;
|
||||
|
||||
renderItemAtGridPos(gui, 2, 0, recipe.getOutput(), false);
|
||||
renderItemAtGridPos(gui, 2, 1, new ItemStack(ModBlocks.altar), false);
|
||||
renderItemAtGridPos(gui, 3, 0, recipe.getOutput(), false);
|
||||
renderItemAtGridPos(gui, 2, 1, getMiddleStack(), false);
|
||||
|
||||
// GL11.glEnable(GL11.GL_BLEND);
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
// String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage");
|
||||
// font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 105, 0x66000000);
|
||||
//
|
||||
// HUDHandler.renderManaBar(gui.getLeft() + gui.getWidth() / 2 - 50, gui.getTop() + 115, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / 10);
|
||||
// GL11.glDisable(GL11.GL_BLEND);
|
||||
List<Object> inputs = recipe.getInputs();
|
||||
int degreePerInput = (int) (360F / (float) inputs.size());
|
||||
int currentDegree = 0;
|
||||
|
||||
for(Object obj : inputs) {
|
||||
Object input = obj;
|
||||
if(input instanceof String)
|
||||
input = OreDictionary.getOres((String) input).get(0);
|
||||
|
||||
renderItemAtAngle(gui, currentDegree, (ItemStack) input);
|
||||
|
||||
currentDegree += degreePerInput;
|
||||
}
|
||||
|
||||
renderManaBar(gui, recipe, mx, my);
|
||||
|
||||
render.bindTexture(petalOverlay);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight());
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
ItemStack getMiddleStack() {
|
||||
return new ItemStack(ModBlocks.altar);
|
||||
}
|
||||
|
||||
public void renderManaBar(IGuiLexiconEntry gui, T recipe, int mx, int my) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,13 +78,14 @@ public class PageRecipe extends LexiconPage {
|
||||
stack.setItemDamage(0);
|
||||
|
||||
angle -= 90;
|
||||
int xPos = gui.getLeft() + (int) (Math.cos(angle) * 12) + gui.getWidth() / 2;
|
||||
int yPos = gui.getTop() + (int) (Math.sin(angle) * 12) + 25;
|
||||
int radius = 32;
|
||||
double xPos = gui.getLeft() + Math.cos(angle * Math.PI / 180D) * radius + gui.getWidth() / 2 - 8;
|
||||
double yPos = gui.getTop() + Math.sin(angle * Math.PI / 180D) * radius + 53;
|
||||
ItemStack stack1 = stack.copy();
|
||||
if(stack1.getItemDamage() == -1)
|
||||
stack1.setItemDamage(0);
|
||||
|
||||
renderItem(gui, xPos, yPos, stack1, false);
|
||||
renderItem(gui, (int) xPos, (int) yPos, stack1, false);
|
||||
}
|
||||
|
||||
public void renderItemAtGridPos(IGuiLexiconEntry gui, int x, int y, ItemStack stack, boolean accountForContainer) {
|
||||
@@ -95,7 +96,7 @@ public class PageRecipe extends LexiconPage {
|
||||
if(stack.getItemDamage() == Short.MAX_VALUE)
|
||||
stack.setItemDamage(0);
|
||||
|
||||
int xPos = gui.getLeft() + x * 29 + 7;
|
||||
int xPos = gui.getLeft() + x * 29 + 7 + (y == 0 && x == 3 ? 10 : 0);
|
||||
int yPos = gui.getTop() + y * 29 + 24 - (y == 0 ? 7 : 0);
|
||||
ItemStack stack1 = stack.copy();
|
||||
if(stack1.getItemDamage() == -1)
|
||||
|
||||
@@ -11,6 +11,46 @@
|
||||
*/
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
public class PageRuneRecipe {
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TilePool;
|
||||
|
||||
public class PageRuneRecipe extends PagePetalRecipe<RecipeRuneAltar> {
|
||||
|
||||
public PageRuneRecipe(String unlocalizedName, List<RecipeRuneAltar> recipes) {
|
||||
super(unlocalizedName, recipes);
|
||||
}
|
||||
|
||||
public PageRuneRecipe(String unlocalizedName, RecipeRuneAltar recipes) {
|
||||
super(unlocalizedName, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
ItemStack getMiddleStack() {
|
||||
return new ItemStack(ModBlocks.runeAltar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderManaBar(IGuiLexiconEntry gui, RecipeRuneAltar recipe, int mx, int my) {
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage");
|
||||
font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 120, 0x66000000);
|
||||
|
||||
HUDHandler.renderManaBar(gui.getLeft() + gui.getWidth() / 2 - 50, gui.getTop() + 130, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / 10);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@@ -9,7 +9,7 @@
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
"authors": ["Vazkii"],
|
||||
"credits": "Azanor, dylan4ever, MegaManki, mDiyo, Mikeemoo, ChickenBones",
|
||||
"credits": "Azanor, dylan4ever, MegaManki, mDiyo, Mikeemoo, ChickenBones, cpw",
|
||||
"parent": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
|
||||
Reference in new issue
Block a user