diff --git a/BM_src/joshie/alchemicalWizardy/nei/NEIAlchemyRecipeHandler.java b/BM_src/joshie/alchemicalWizardy/nei/NEIAlchemyRecipeHandler.java index c869c093..4e8750d6 100644 --- a/BM_src/joshie/alchemicalWizardy/nei/NEIAlchemyRecipeHandler.java +++ b/BM_src/joshie/alchemicalWizardy/nei/NEIAlchemyRecipeHandler.java @@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; import WayofTime.alchemicalWizardry.common.alchemy.AlchemyRecipe; import WayofTime.alchemicalWizardry.common.alchemy.AlchemyRecipeRegistry; import codechicken.nei.NEIServerUtils; @@ -120,7 +121,7 @@ public class NEIAlchemyRecipeHandler extends TemplateRecipeHandler { @Override public String getRecipeName() { - return "Alchemic Chemistry Set"; + return StatCollector.translateToLocal("tile.blockWritingTable.name"); } @Override diff --git a/BM_src/joshie/alchemicalWizardy/nei/NEIAltarRecipeHandler.java b/BM_src/joshie/alchemicalWizardy/nei/NEIAltarRecipeHandler.java new file mode 100644 index 00000000..9ca77ec5 --- /dev/null +++ b/BM_src/joshie/alchemicalWizardy/nei/NEIAltarRecipeHandler.java @@ -0,0 +1,161 @@ +package joshie.alchemicalWizardy.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.lang.reflect.Field; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import WayofTime.alchemicalWizardry.common.altarRecipeRegistry.AltarRecipe; +import WayofTime.alchemicalWizardry.common.altarRecipeRegistry.AltarRecipeRegistry; +import codechicken.core.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; + +public class NEIAltarRecipeHandler extends TemplateRecipeHandler { + public class CachedAltarRecipe extends CachedRecipe { + PositionedStack input; + PositionedStack output; + int tier, lp_amount, consumption, drain; + + public CachedAltarRecipe(AltarRecipe recipe) { + input = new PositionedStack(recipe.requiredItem, 38, 2, false); + output = new PositionedStack(recipe.result, 132, 32, false); + tier = recipe.minTier; + lp_amount = recipe.liquidRequired; + consumption = recipe.consumptionRate; + drain = recipe.drainRate; + } + + @Override + public PositionedStack getIngredient() { + return input; + } + + @Override + public PositionedStack getResult() { + return output; + } + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("altarrecipes") && getClass() == NEIAltarRecipeHandler.class) { + for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) { + if(recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe)); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) { + if(NEIServerUtils.areStacksSameTypeCrafting(recipe.result, result)) { + if(recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe)); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for(AltarRecipe recipe: AltarRecipeRegistry.altarRecipes) { + if(NEIServerUtils.areStacksSameTypeCrafting(recipe.requiredItem, ingredient)) { + if(recipe.result != null) arecipes.add(new CachedAltarRecipe(recipe)); + } + } + } + + //Mouse Position helper + public Point getMouse(int width, int height) { + Point mousepos = GuiDraw.getMousePosition(); + int guiLeft = (width - 176) / 2; + int guiTop = (height - 166) / 2; + Point relMouse = new Point(mousepos.x - guiLeft, mousepos.y - guiTop); + return relMouse; + } + + //width helper, getting width normal way hates me on compile + public int getGuiWidth(GuiRecipe gui) { + try { + Field f = gui.getClass().getField("width"); + return (Integer) f.get(gui); + } catch (NoSuchFieldException e) { + try { + Field f = gui.getClass().getField("field_73880_f"); + return (Integer) f.get(gui); + } catch (Exception e2) { + return 0; + } + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + //height helper, getting height normal way hates me on compile + public int getGuiHeight(GuiRecipe gui) { + try { + Field f = gui.getClass().getField("height"); + return (Integer) f.get(gui); + } catch (NoSuchFieldException e) { + try { + Field f = gui.getClass().getField("field_73881_g"); + return (Integer) f.get(gui); + } catch (Exception e2) { + return 0; + } + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + @Override + public void drawExtras(int id) { + CachedAltarRecipe recipe = (CachedAltarRecipe) arecipes.get(id); + Minecraft.getMinecraft().fontRenderer.drawString("\u00a77" + StatCollector.translateToLocal("bm.string.tier") + ": " + recipe.tier, 78, 5, 0); + Minecraft.getMinecraft().fontRenderer.drawString("\u00a77" + "LP: " + recipe.lp_amount, 78, 15, 0); + } + + @Override + public List handleTooltip(GuiRecipe gui, List currenttip, int id) { + currenttip = super.handleTooltip(gui, currenttip, id); + Point mouse = getMouse(getGuiWidth(gui), getGuiHeight(gui)); + CachedAltarRecipe recipe = (CachedAltarRecipe) arecipes.get(id); + int yLow = id % 2 == 0 ? 38 : 102; + int yHigh = id % 2 == 0 ? 72 : 136; + if(mouse.x >= 19 && mouse.x <= 80 && mouse.y >= yLow && mouse.y <= yHigh) { + currenttip.add(StatCollector.translateToLocal("bm.string.consume") + ": " + recipe.consumption + "LP/t"); + currenttip.add(StatCollector.translateToLocal("bm.string.drain") + ": " + recipe.drain + "LP/t"); + } + + return currenttip; + } + + @Override + public String getOverlayIdentifier() { + return "altarrecipes"; + } + + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(90, 32, 22, 16), "altarrecipes")); + } + + @Override + public String getRecipeName() { + return " " + StatCollector.translateToLocal("tile.bloodAltar.name"); + } + + @Override + public String getGuiTexture() { + return new ResourceLocation("alchemicalwizardry", "gui/nei/altar.png").toString(); + } +} diff --git a/BM_src/joshie/alchemicalWizardy/nei/NEIConfig.java b/BM_src/joshie/alchemicalWizardy/nei/NEIConfig.java index 3d2c3726..e4dcdf36 100644 --- a/BM_src/joshie/alchemicalWizardy/nei/NEIConfig.java +++ b/BM_src/joshie/alchemicalWizardy/nei/NEIConfig.java @@ -12,6 +12,8 @@ public class NEIConfig implements IConfigureNEI { public void loadConfig() { API.registerRecipeHandler(new NEIAlchemyRecipeHandler()); API.registerUsageHandler(new NEIAlchemyRecipeHandler()); + API.registerRecipeHandler(new NEIAltarRecipeHandler()); + API.registerUsageHandler(new NEIAltarRecipeHandler()); NEIAlchemyRecipeHandler.bloodOrbs = new ArrayList(); NEIAlchemyRecipeHandler.bloodOrbs.add(ModItems.weakBloodOrb); @@ -28,6 +30,6 @@ public class NEIConfig implements IConfigureNEI { @Override public String getVersion() { - return "1.0"; + return "1.1"; } } diff --git a/resources/assets/alchemicalwizardry/gui/nei/altar.png b/resources/assets/alchemicalwizardry/gui/nei/altar.png new file mode 100644 index 00000000..b1de616a Binary files /dev/null and b/resources/assets/alchemicalwizardry/gui/nei/altar.png differ diff --git a/resources/assets/alchemicalwizardry/lang/en_US.lang b/resources/assets/alchemicalwizardry/lang/en_US.lang index df2c8853..fbb84e90 100644 --- a/resources/assets/alchemicalwizardry/lang/en_US.lang +++ b/resources/assets/alchemicalwizardry/lang/en_US.lang @@ -129,4 +129,9 @@ item.bloodLightSigil.name=Sigil of the Blood Lamp item.itemComplexSpellCrystal.name=[WIP] Complex Spell Crystal #Creative Tab -itemGroup.tabBloodMagic=Blood Magic \ No newline at end of file +itemGroup.tabBloodMagic=Blood Magic + +#Extra Strings +bm.string.consume=Usage +bm.string.drain=Drain +bm.string.tier=Tier