mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Added NEI Lexica Botania integration
This commit is contained in:
1 parent
3edde413df
commit
88ec0dec28
10 files changed
+217
-9
No files matched your search
@@ -30,6 +30,8 @@ public class LexiconEntry implements Comparable<LexiconEntry> {
|
||||
public List<LexiconPage> pages = new ArrayList<LexiconPage>();
|
||||
private boolean priority = false;
|
||||
private ItemStack icon = null;
|
||||
|
||||
private List<ItemStack> extraDisplayedRecipes = new ArrayList();
|
||||
|
||||
/**
|
||||
* @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display.
|
||||
@@ -146,9 +148,15 @@ public class LexiconEntry implements Comparable<LexiconEntry> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list.addAll(extraDisplayedRecipes);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void addExtraDisplayedRecipe(ItemStack stack) {
|
||||
extraDisplayedRecipes.add(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LexiconEntry o) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class LexiconRecipeMappings {
|
||||
public static EntryData getDataForStack(ItemStack stack) {
|
||||
return mappings.get(stackToString(stack));
|
||||
}
|
||||
|
||||
|
||||
public static String stackToString(ItemStack stack) {
|
||||
if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider)
|
||||
return ((IRecipeKeyProvider) stack.getItem()).getKey(stack);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@API(owner = "Botania", apiVersion = "72", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "73", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -38,6 +38,9 @@ public class NEIBotaniaConfig implements IConfigureNEI {
|
||||
|
||||
API.registerRecipeHandler(new RecipeHandlerPureDaisy());
|
||||
API.registerUsageHandler(new RecipeHandlerPureDaisy());
|
||||
|
||||
API.registerRecipeHandler(new RecipeHandlerLexicaBotania());
|
||||
API.registerUsageHandler(new RecipeHandlerLexicaBotania());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class RecipeHandlerElvenTrade extends TemplateRecipeHandler {
|
||||
}
|
||||
|
||||
private static boolean hasElvenKnowledge() {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
/*EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null) {
|
||||
for (ItemStack stack : player.inventory.mainInventory) {
|
||||
if (stack != null && stack.getItem() instanceof ILexicon) {
|
||||
@@ -106,7 +106,8 @@ public class RecipeHandlerElvenTrade extends TemplateRecipeHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [12/12/2015, 23:25:47 (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.integration.nei;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.KnowledgeType;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
|
||||
import vazkii.botania.api.recipe.RecipeManaInfusion;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.client.integration.nei.RecipeHandlerManaPool.CachedManaPoolRecipe;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.client.render.tile.RenderTilePool;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lexicon.page.PageRecipe;
|
||||
import vazkii.botania.common.lexicon.page.PageText;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect;
|
||||
|
||||
public class RecipeHandlerLexicaBotania extends TemplateRecipeHandler {
|
||||
|
||||
public class CachedLexicaBotaniaRecipe extends CachedRecipe {
|
||||
|
||||
public LexiconEntry entry;
|
||||
public PositionedStack item;
|
||||
public List<PositionedStack> otherStacks = new ArrayList<PositionedStack>();
|
||||
|
||||
public CachedLexicaBotaniaRecipe(ItemStack stack, LexiconEntry entry) {
|
||||
otherStacks.add(new PositionedStack(new ItemStack(ModItems.lexicon), 51, 5));
|
||||
item = new PositionedStack(stack, 91, 5);
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return otherStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks() {
|
||||
return otherStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Collection<PositionedStack> ingredients, ItemStack ingredient) {
|
||||
return ingredient.getItem() == ModItems.lexicon;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("botania.nei.lexica");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return LibResources.GUI_NEI_BLANK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
transferRects.add(new RecipeTransferRect(new Rectangle(50, 4, 18, 18), "botania.lexica"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
super.drawBackground(recipe);
|
||||
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
CachedLexicaBotaniaRecipe recipeObj = ((CachedLexicaBotaniaRecipe) arecipes.get(recipe));
|
||||
|
||||
String s = EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal(recipeObj.entry.getUnlocalizedName());
|
||||
font.drawString(s, 82 - font.getStringWidth(s) / 2, 30, 4210752);
|
||||
|
||||
KnowledgeType type = recipeObj.entry.getKnowledgeType();
|
||||
s = type.color + StatCollector.translateToLocal(type.getUnlocalizedName()).replaceAll("\\&.", "");
|
||||
font.drawString(s, 82 - font.getStringWidth(s) / 2, 42, 4210752);
|
||||
|
||||
s = "\"" + StatCollector.translateToLocal(recipeObj.entry.getTagline()) + "\"";
|
||||
PageText.renderText(5, 42, 160, 200, s);
|
||||
|
||||
String key = LexiconRecipeMappings.stackToString(recipeObj.item.item);
|
||||
String quickInfo = "botania.nei.quickInfo:" + key;
|
||||
String quickInfoLocal = StatCollector.translateToLocal(quickInfo);
|
||||
|
||||
if(GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown() && Minecraft.getMinecraft().gameSettings.advancedItemTooltips)
|
||||
s = "name: " + key;
|
||||
else if(quickInfo.equals(quickInfoLocal))
|
||||
s = StatCollector.translateToLocal("botania.nei.lexicaNoInfo");
|
||||
else {
|
||||
s = StatCollector.translateToLocal("botania.nei.lexicaSeparator");
|
||||
font.drawString(s, 82 - font.getStringWidth(s) / 2, 80, 4210752);
|
||||
s = quickInfoLocal;
|
||||
}
|
||||
|
||||
PageText.renderText(5, 80, 160, 200, s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if(outputId.equals("botania.lexica")) {
|
||||
for(LexiconEntry entry : BotaniaAPI.getAllEntries()) {
|
||||
List<ItemStack> stacks = entry.getDisplayedRecipes();
|
||||
for(ItemStack stack : stacks)
|
||||
arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry));
|
||||
}
|
||||
} else super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for(LexiconEntry entry : BotaniaAPI.getAllEntries()) {
|
||||
List<ItemStack> stacks = entry.getDisplayedRecipes();
|
||||
for(ItemStack stack : stacks) {
|
||||
String key1 = LexiconRecipeMappings.stackToString(stack);
|
||||
String key2 = LexiconRecipeMappings.stackToString(result);
|
||||
if(key1.equals(key2))
|
||||
arecipes.add(new CachedLexicaBotaniaRecipe(stack, entry));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class ItemBlockSpecialFlower extends ItemBlockMod implements IRecipeKeyPr
|
||||
|
||||
@Override
|
||||
public String getKey(ItemStack stack) {
|
||||
return getType(stack);
|
||||
return "flower." + getType(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -334,6 +334,8 @@ public final class LexiconData {
|
||||
|
||||
pureDaisy = new BLexiconEntry(LibLexicon.BASICS_PURE_DAISY, categoryBasics);
|
||||
pureDaisy.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_PURE_DAISY), new PageCraftingRecipe("2", ModCraftingRecipes.recipeLivingwoodTwig), new PageText("4"), new PagePetalRecipe("3", ModPetalRecipes.pureDaisyRecipe)).setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY));
|
||||
pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingwood));
|
||||
pureDaisy.addExtraDisplayedRecipe(new ItemStack(ModBlocks.livingrock));
|
||||
LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingwood), pureDaisy, 1);
|
||||
LexiconRecipeMappings.map(new ItemStack(ModBlocks.livingrock), pureDaisy, 1);
|
||||
|
||||
@@ -347,7 +349,8 @@ public final class LexiconData {
|
||||
|
||||
blackLotus = new BLexiconEntry(LibLexicon.BASICS_BLACK_LOTUS, categoryBasics);
|
||||
blackLotus.setLexiconPages(new PageText("0")).setIcon(new ItemStack(ModItems.blackLotus));
|
||||
|
||||
blackLotus.addExtraDisplayedRecipe(new ItemStack(ModItems.blackLotus));
|
||||
|
||||
flowerBag = new BLexiconEntry(LibLexicon.BASICS_FLOWER_BAG, categoryBasics);
|
||||
flowerBag.setLexiconPages(new PageText("0"), new PageText("2"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlowerBag));
|
||||
|
||||
@@ -536,7 +539,9 @@ public final class LexiconData {
|
||||
primusLoci = new BLexiconEntry(LibLexicon.GFLOWER_PRIMUS_LOCI, categoryGenerationFlowers);
|
||||
primusLoci.setPriority().setLexiconPages(new PageText("0"), new PageText("1"));
|
||||
primusLoci.setIcon(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME));
|
||||
|
||||
primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_DAYBLOOM_PRIME));
|
||||
primusLoci.addExtraDisplayedRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_NIGHTSHADE_PRIME));
|
||||
|
||||
daybloom = new BLexiconEntry(LibLexicon.GFLOWER_DAYBLOOM, categoryGenerationFlowers);
|
||||
daybloom.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PagePetalRecipe("2", ModPetalRecipes.daybloomRecipe));
|
||||
|
||||
@@ -776,7 +781,9 @@ public final class LexiconData {
|
||||
|
||||
overgrowthSeed = new BLexiconEntry(LibLexicon.TOOL_OVERGROWTH_SEED, categoryTools);
|
||||
overgrowthSeed.setPriority().setLexiconPages(new PageText("0"), new PageText("1")).setIcon(new ItemStack(ModItems.overgrowthSeed));
|
||||
|
||||
overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModItems.overgrowthSeed));
|
||||
overgrowthSeed.addExtraDisplayedRecipe(new ItemStack(ModBlocks.enchantedSoil));
|
||||
|
||||
livingwoodBow = new BLexiconEntry(LibLexicon.TOOL_LIVINGWOOD_BOW, categoryTools);
|
||||
livingwoodBow.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeLivingwoodBow));
|
||||
|
||||
@@ -810,6 +817,7 @@ public final class LexiconData {
|
||||
// ENDER ENTRIES
|
||||
enderAir = new BLexiconEntry(LibLexicon.ENDER_AIR, categoryEnder);
|
||||
enderAir.setPriority().setLexiconPages(new PageText("0"));
|
||||
enderAir.addExtraDisplayedRecipe(new ItemStack(ModItems.manaResource, 1, 15));
|
||||
LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 15), enderAir, 0);
|
||||
|
||||
enderEyeBlock = new BLexiconEntry(LibLexicon.ENDER_ENDER_EYE_BLOCK, categoryEnder);
|
||||
|
||||
@@ -92,7 +92,7 @@ public class PageTerrasteel extends PageRecipe {
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
list.add(new ItemStack(ModItems.manaResource, 1, 4));
|
||||
return super.getDisplayedRecipes();
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -159,7 +159,24 @@ botania.nei.manaPool=Mana Infusion
|
||||
botania.nei.petalApothecary=Petal Apothecary
|
||||
botania.nei.runicAltar=Runic Altar
|
||||
botania.nei.pureDaisy=Pure Daisy
|
||||
botania.nei.lexica=Lexica Botania
|
||||
|
||||
botania.nei.lexicaSeparator=Extra Info:
|
||||
botania.nei.lexicaNoInfo=(there's no Extra Info for this entry, sorry!)
|
||||
|
||||
# NEI QUICK LOOKS
|
||||
botania.nei.quickInfo:tile.livingwood0~0=You can create Livingwood by placing Wood next to a Pure Daisy
|
||||
botania.nei.quickInfo:tile.livingrock0~0=You can create Livingrock by placing Stone next to a Pure Daisy
|
||||
|
||||
botania.nei.quickInfo:flower.daybloom=In this world, it's kill or be killed
|
||||
botania.nei.quickInfo:flower.daybloomPrimus=This flower can not be harvested, but can be found rarely in the world
|
||||
botania.nei.quickInfo:flower.nightshadePrimus=This flower can not be harvested, but can be found rarely in the world
|
||||
|
||||
botania.nei.quickInfo:item.bone~0=You're gonna have a bad time
|
||||
botania.nei.quickInfo:item.lexicon~0=What exactly did you expect?
|
||||
botania.nei.quickInfo:item.terrasteel~4=You can get Terrasteel by tossing the right materials on a Terrestrial Agglomeration Plate
|
||||
botania.nei.quickInfo:item.enderAirBottle~15=You can get this by right clicking with a Glass Bottle while in the End
|
||||
primus
|
||||
# BUILDCRAFT INTEGRATION
|
||||
botania.triggers.manaDetector=Mana Burst
|
||||
botania.triggers.manaEmpty=Mana Empty
|
||||
|
||||
Reference in new issue
Block a user