From ba2c9e589feae8fc7168c2bf23f5baf320b2db9d Mon Sep 17 00:00:00 2001 From: Jeremy Diamond Date: Sun, 15 Mar 2015 20:48:04 -0700 Subject: [PATCH] Updating Botania API --- .../java/vazkii/botania/api/BotaniaAPI.java | 57 +++- .../vazkii/botania/api/boss/IBotaniaBoss.java | 61 ++++ .../api/boss/IBotaniaBossWithShader.java | 42 +++ .../java/vazkii/botania/api/brew/Brew.java | 113 +++++++ .../botania/api/brew/IBrewContainer.java | 35 +++ .../vazkii/botania/api/brew/IBrewItem.java | 24 ++ .../botania/api/corporea/CorporeaHelper.java | 291 ++++++++++++++++++ .../botania/api/corporea/ICorporeaSpark.java | 87 ++++++ .../api/internal/DummyManaNetwork.java | 5 +- .../api/internal/DummyMethodHandler.java | 39 ++- .../botania/api/internal/DummyPage.java | 5 +- .../botania/api/internal/DummySubTile.java | 5 +- .../api/internal/IGuiLexiconEntry.java | 5 +- .../api/internal/IInternalMethodHandler.java | 23 +- .../botania/api/internal/IManaBurst.java | 7 +- .../botania/api/internal/IManaNetwork.java | 5 +- .../botania/api/internal/ShaderCallback.java | 20 ++ .../api/item/IAncientWillContainer.java | 25 ++ .../botania/api/item/IBaubleRender.java | 77 +++++ .../botania/api/item/IBurstViewerBauble.java | 20 ++ .../botania/api/item/ICosmeticAttachable.java | 33 ++ .../botania/api/item/ICosmeticBauble.java | 20 ++ .../vazkii/botania/api/item/IDyablePool.java | 24 ++ .../botania/api/item/IExoflameHeatable.java | 5 +- .../api/item/IExtendedPlayerController.java | 5 +- .../botania/api/item/IFlowerlessBiome.java | 21 ++ .../botania/api/item/IFlowerlessWorld.java | 24 ++ .../botania/api/item/IGrassHornExcempt.java | 23 ++ .../botania/api/item/IManaDissolvable.java | 29 ++ .../botania/api/item/IPetalApothecary.java | 5 +- .../botania/api/item/IPixieSpawner.java | 5 +- .../botania/api/item/ISortableTool.java | 47 +++ .../botania/api/lexicon/IAddonEntry.java | 5 +- .../botania/api/lexicon/ILexiconable.java | 5 +- .../api/lexicon/IRecipeKeyProvider.java | 5 +- .../botania/api/lexicon/ITwoNamedPage.java | 23 ++ .../botania/api/lexicon/LexiconCategory.java | 40 ++- .../botania/api/lexicon/LexiconEntry.java | 19 +- .../botania/api/lexicon/LexiconPage.java | 5 +- .../api/lexicon/LexiconRecipeMappings.java | 10 +- .../botania/api/mana/BurstProperties.java | 5 +- .../botania/api/mana/IClientManaHandler.java | 5 +- .../api/mana/ICreativeManaProvider.java | 5 +- .../vazkii/botania/api/mana/IKeyLocked.java | 5 +- .../botania/api/mana/ILaputaImmobile.java | 5 +- .../java/vazkii/botania/api/mana/ILens.java | 5 +- .../vazkii/botania/api/mana/ILensEffect.java | 5 +- .../vazkii/botania/api/mana/IManaBlock.java | 5 +- .../botania/api/mana/IManaCollector.java | 5 +- .../botania/api/mana/IManaCollisionGhost.java | 5 +- .../botania/api/mana/IManaDiscountArmor.java | 30 ++ .../vazkii/botania/api/mana/IManaItem.java | 5 +- .../vazkii/botania/api/mana/IManaPool.java | 5 +- .../botania/api/mana/IManaReceiver.java | 5 +- .../vazkii/botania/api/mana/IManaTrigger.java | 5 +- .../botania/api/mana/IManaUsingItem.java | 5 +- .../api/mana/IPoolOverlayProvider.java | 5 +- .../botania/api/mana/ITinyPlanetExcempt.java | 5 +- .../botania/api/mana/ManaItemHandler.java | 48 ++- .../botania/api/mana/ManaNetworkEvent.java | 5 +- .../api/mana/spark/ISparkAttachable.java | 11 +- .../botania/api/mana/spark/ISparkEntity.java | 5 +- .../botania/api/mana/spark/SparkHelper.java | 5 +- .../java/vazkii/botania/api/package-info.java | 2 +- .../botania/api/recipe/IFlowerComponent.java | 5 +- .../vazkii/botania/api/recipe/RecipeBrew.java | 114 +++++++ .../api/recipe/RecipeManaInfusion.java | 15 +- .../botania/api/recipe/RecipePetals.java | 5 +- .../botania/api/recipe/RecipeRuneAltar.java | 7 +- .../botania/api/subtile/ISpecialFlower.java | 5 +- .../api/subtile/ISubTileContainer.java | 5 +- .../botania/api/subtile/SubTileEntity.java | 62 +++- .../api/subtile/SubTileFunctional.java | 12 +- .../api/subtile/SubTileGenerating.java | 17 +- .../api/subtile/signature/BasicSignature.java | 5 +- .../subtile/signature/SubTileSignature.java | 5 +- .../vazkii/botania/api/wand/ITileBound.java | 5 +- .../botania/api/wand/IWandBindable.java | 5 +- .../vazkii/botania/api/wand/IWandHUD.java | 5 +- .../vazkii/botania/api/wand/IWandable.java | 5 +- .../api/wand/IWireframeAABBProvider.java | 5 +- .../botania/api/wiki/IWikiProvider.java | 5 +- .../botania/api/wiki/SimpleWikiProvider.java | 5 +- .../vazkii/botania/api/wiki/WikiHooks.java | 7 +- 84 files changed, 1580 insertions(+), 209 deletions(-) create mode 100644 src/api/java/vazkii/botania/api/boss/IBotaniaBoss.java create mode 100644 src/api/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java create mode 100644 src/api/java/vazkii/botania/api/brew/Brew.java create mode 100644 src/api/java/vazkii/botania/api/brew/IBrewContainer.java create mode 100644 src/api/java/vazkii/botania/api/brew/IBrewItem.java create mode 100644 src/api/java/vazkii/botania/api/corporea/CorporeaHelper.java create mode 100644 src/api/java/vazkii/botania/api/corporea/ICorporeaSpark.java create mode 100644 src/api/java/vazkii/botania/api/internal/ShaderCallback.java create mode 100644 src/api/java/vazkii/botania/api/item/IAncientWillContainer.java create mode 100644 src/api/java/vazkii/botania/api/item/IBaubleRender.java create mode 100644 src/api/java/vazkii/botania/api/item/IBurstViewerBauble.java create mode 100644 src/api/java/vazkii/botania/api/item/ICosmeticAttachable.java create mode 100644 src/api/java/vazkii/botania/api/item/ICosmeticBauble.java create mode 100644 src/api/java/vazkii/botania/api/item/IDyablePool.java create mode 100644 src/api/java/vazkii/botania/api/item/IFlowerlessBiome.java create mode 100644 src/api/java/vazkii/botania/api/item/IFlowerlessWorld.java create mode 100644 src/api/java/vazkii/botania/api/item/IGrassHornExcempt.java create mode 100644 src/api/java/vazkii/botania/api/item/IManaDissolvable.java create mode 100644 src/api/java/vazkii/botania/api/item/ISortableTool.java create mode 100644 src/api/java/vazkii/botania/api/lexicon/ITwoNamedPage.java create mode 100644 src/api/java/vazkii/botania/api/mana/IManaDiscountArmor.java create mode 100644 src/api/java/vazkii/botania/api/recipe/RecipeBrew.java diff --git a/src/api/java/vazkii/botania/api/BotaniaAPI.java b/src/api/java/vazkii/botania/api/BotaniaAPI.java index b858795..f0e0866 100644 --- a/src/api/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/api/java/vazkii/botania/api/BotaniaAPI.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 14, 2014, 6:15:28 PM (GMT)] */ @@ -13,6 +12,7 @@ package vazkii.botania.api; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -29,12 +29,14 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.EnumHelper; +import vazkii.botania.api.brew.Brew; import vazkii.botania.api.internal.DummyMethodHandler; import vazkii.botania.api.internal.DummySubTile; import vazkii.botania.api.internal.IInternalMethodHandler; import vazkii.botania.api.lexicon.KnowledgeType; import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.api.lexicon.LexiconEntry; +import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RecipePetals; @@ -56,10 +58,13 @@ public final class BotaniaAPI { public static Map knowledgeTypes = new HashMap(); + public static Map brewMap = new LinkedHashMap(); + public static List petalRecipes = new ArrayList(); public static List runeAltarRecipes = new ArrayList(); public static List manaInfusionRecipes = new ArrayList(); public static List elvenTradeRecipes = new ArrayList(); + public static List brewRecipes = new ArrayList(); private static BiMap> subTiles = HashBiMap.> create(); private static Map, SubTileSignature> subTileSignatures = new HashMap, SubTileSignature>(); @@ -76,10 +81,24 @@ public final class BotaniaAPI { public static ToolMaterial elementiumToolMaterial = EnumHelper.addToolMaterial("B_ELEMENTIUM", 3, 720, 6.2F, 2F, 20); public static ArmorMaterial terrasteelArmorMaterial = EnumHelper.addArmorMaterial("TERRASTEEL", 34, new int[] {3, 8, 6, 3}, 26); - public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 3, 2300, 9F, 3F, 26); + public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 4, 2300, 9F, 3F, 26); public static KnowledgeType basicKnowledge, elvenKnowledge; + // All of these categories are initialized during botania's PreInit stage. + public static LexiconCategory categoryBasics; + public static LexiconCategory categoryMana; + public static LexiconCategory categoryFunctionalFlowers; + public static LexiconCategory categoryGenerationFlowers; + public static LexiconCategory categoryDevices; + public static LexiconCategory categoryTools; + public static LexiconCategory categoryBaubles; + public static LexiconCategory categoryEnder; + public static LexiconCategory categoryAlfhomancy; + public static LexiconCategory categoryMisc; + + public static Brew fallbackBrew = new Brew("fallback", "botania.brew.fallback", 0, 0); + static { registerSubTile("", DummySubTile.class); @@ -97,6 +116,7 @@ public final class BotaniaAPI { addOreWeight("oreCoal", 46525); // Vanilla addOreWeight("oreCooperite", 5); // GregTech addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc. + addOreWeight("oreDark", 1350); // EvilCraft addOreWeight("oreDarkIron", 1700); // Factorization addOreWeight("oreDiamond", 1265); // Vanilla addOreWeight("oreEmerald", 780); // Vanilla @@ -184,6 +204,24 @@ public final class BotaniaAPI { return type; } + /** + * Registers a Brew and returns it. + */ + public static Brew registerBrew(Brew brew) { + brewMap.put(brew.getKey(), brew); + return brew; + } + + /** + * Gets a brew from the key passed in, returns the fallback if + * it's not in the map. + */ + public static Brew getBrewFromKey(String key) { + if(brewMap.containsKey(key)) + return brewMap.get(key); + return fallbackBrew; + } + /** * Registers a Petal Recipe. * @param output The ItemStack to craft. @@ -258,6 +296,17 @@ public final class BotaniaAPI { return recipe; } + /** + * Registers a Brew Recipe (for the Botanical Brewery). + * @param brew The brew in to be set in this recipe. + * @inputs The items used in the recipe, no more than 6. + */ + public static RecipeBrew registerBrewRecipe(Brew brew, Object... inputs) { + RecipeBrew recipe = new RecipeBrew(brew, inputs); + brewRecipes.add(recipe); + return recipe; + } + /** * Registers a SubTileEntity, a new special flower. Look in the subtile package of the API. */ diff --git a/src/api/java/vazkii/botania/api/boss/IBotaniaBoss.java b/src/api/java/vazkii/botania/api/boss/IBotaniaBoss.java new file mode 100644 index 0000000..bc218f6 --- /dev/null +++ b/src/api/java/vazkii/botania/api/boss/IBotaniaBoss.java @@ -0,0 +1,61 @@ +/** + * This class was created by . 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 @ [Oct 29, 2014, 6:09:48 PM (GMT)] + */ +package vazkii.botania.api.boss; + +import java.awt.Rectangle; + +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * An extension of IBossDisplayData. This counts as a botania boss and as a normal + * minecraft boss since it has IBossDisplayData. Instead of using the typical + * BossStatus.setBossStatus(entity, true) to set the health bar in the render use + * BotaniaAPI.internalMethodHandler.setBossStatus(entity);

+ * Alternatively, you can check if botania is loaded and use the vanilla one + * if that's not the case. + */ +public interface IBotaniaBoss extends IBossDisplayData { + + /** + * The ResourceLocation to bind for this boss's boss bar. + * You can use BotaniaAPI.internalMethodHandler.getDefaultBossBarTexture() to get + * the one used by botania bosses. + */ + @SideOnly(Side.CLIENT) + public ResourceLocation getBossBarTexture(); + + /** + * A Rectangle instance delimiting the uv, width and height of this boss's + * boss bar texture. This is for the background, not the bar that shows + * the HP. + */ + @SideOnly(Side.CLIENT) + public Rectangle getBossBarTextureRect(); + + /** + * A Rectangle instance delimiting the uv, width and height of this boss's + * boss bar HP texture. This is for the foreground that shows how much + * HP the boss has. The width of the rectangle will be multiplied by the + * faction of the boss's current HP by max HP. + */ + @SideOnly(Side.CLIENT) + public Rectangle getBossBarHPTextureRect(); + + /** + * A callback for when this boss's boss bar renders, you can do aditional rendering + * here if needed. + */ + @SideOnly(Side.CLIENT) + public void bossBarRenderCallback(); +} diff --git a/src/api/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java b/src/api/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java new file mode 100644 index 0000000..82221d3 --- /dev/null +++ b/src/api/java/vazkii/botania/api/boss/IBotaniaBossWithShader.java @@ -0,0 +1,42 @@ +/** + * This class was created by . 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 @ [Oct 29, 2014, 6:13:21 PM (GMT)] + */ +package vazkii.botania.api.boss; + +import vazkii.botania.api.internal.ShaderCallback; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * A Botania boss whose HP bar makes use of shaders. Shaders + * used through this have a few uniforms available: + *
  • int time - The amount of total ticks elapsed.
  • + *
  • int startX - The U coordinate passed in for the render of this bar's texture.
  • + *
  • int startY - The V coordinate passed in for the render of this bar's texture.
  • + */ +public interface IBotaniaBossWithShader extends IBotaniaBoss { + + /** + * The Shader Program to use for this boss bar. Return 0 case + * you don't want a shader to be used. You can use separate shaders + * for the background and foreground. + * @param background True if rendering the background of the boss bar, + * false if rendering the bar itself that shows the HP. + */ + @SideOnly(Side.CLIENT) + public int getBossBarShaderProgram(boolean background); + + /** + * A callback for the shader, used to pass in uniforms. Return null for no callback. + */ + @SideOnly(Side.CLIENT) + public ShaderCallback getBossBarShaderCallback(boolean background, int shader); + +} diff --git a/src/api/java/vazkii/botania/api/brew/Brew.java b/src/api/java/vazkii/botania/api/brew/Brew.java new file mode 100644 index 0000000..5b1948d --- /dev/null +++ b/src/api/java/vazkii/botania/api/brew/Brew.java @@ -0,0 +1,113 @@ +/** + * This class was created by . 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 @ [Nov 1, 2014, 6:22:54 PM (GMT)] + */ +package vazkii.botania.api.brew; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; + +/** + * The class for a Brew definition, each one is a singleton. + */ +public class Brew { + + String key; + String name; + int color; + int cost; + List effects; + boolean canInfuseBloodPendant = true; + + /** + * @param name The unlocalized name of this potion. + * @param color The color for the potion to be rendered in the bottle, note that it will get + * changed a bit when it renders (for more or less brightness) to give a fancy effect. + * @param cost The cost, in Mana for this brew. + * @param effects A list of effects to apply to the player when they drink it. + */ + public Brew(String key, String name, int color, int cost, PotionEffect... effects) { + this.key = key; + this.name = name; + this.color = color; + this.cost = cost; + this.effects = new ArrayList(Arrays.asList(effects)); + } + + /** + * Sets this brew to not be able to be infused onto the Tainted Blood Pendant. + */ + public Brew setNotBloodPendantInfusable() { + canInfuseBloodPendant = false; + return this; + } + + public boolean canInfuseBloodPendant() { + return canInfuseBloodPendant; + } + + /** + * Returns the key for this brew, for it to be found in the map in the API. + * This should ALWAYS return the same result. + */ + public String getKey() { + return key; + } + + /** + * Gets the insensitive unlocalized name. This is used for the lexicon. + */ + public String getUnlocalizedName() { + return name; + } + + /** + * Gets the unlocalized name for the ItemStack passed in. + */ + public String getUnlocalizedName(ItemStack stack) { + return getUnlocalizedName(); + } + + /** + * Gets the display color for the ItemStack passed in. Note that for + * the lexicon, this passes in a botania Managlass Vial or an + * Alfglass Flask at all times. + */ + public int getColor(ItemStack stack) { + return color; + } + + /** + * Gets the insensitive unlocalized mana cost. This is used for the lexicon. + */ + public int getManaCost() { + return cost; + } + + /** + * Gets the mana cost for the ItemStack passed in. + */ + public int getManaCost(ItemStack stack) { + return getManaCost(); + } + + /** + * Gets the list of potion effects for the ItemStack passed in. + * Note that for the lexicon, this passes in a botania Managlass + * Vial or an Alfglass Flask at all times. + */ + public List getPotionEffects(ItemStack stack) { + return effects; + } + +} diff --git a/src/api/java/vazkii/botania/api/brew/IBrewContainer.java b/src/api/java/vazkii/botania/api/brew/IBrewContainer.java new file mode 100644 index 0000000..0d155ec --- /dev/null +++ b/src/api/java/vazkii/botania/api/brew/IBrewContainer.java @@ -0,0 +1,35 @@ +/** + * This class was created by . 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 @ [Nov 1, 2014, 6:26:40 PM (GMT)] + */ +package vazkii.botania.api.brew; + +import net.minecraft.item.ItemStack; + +/** + * An Item that implements this counts as a Brew Container, by which + * it can be used a center item for brew recipes and can contain + * a brew. + */ +public interface IBrewContainer { + + /** + * Returs an ItemStack that should be an item that has the brew + * passed in. + */ + public ItemStack getItemForBrew(Brew brew, ItemStack stack); + + /** + * Gets the cost to add this brew onto this container. Return -1 + * to not allow for the brew to be added. Normally you'd + * use brew.getManaCost(stack); + */ + public int getManaCost(Brew brew, ItemStack stack); + +} diff --git a/src/api/java/vazkii/botania/api/brew/IBrewItem.java b/src/api/java/vazkii/botania/api/brew/IBrewItem.java new file mode 100644 index 0000000..d51c9fa --- /dev/null +++ b/src/api/java/vazkii/botania/api/brew/IBrewItem.java @@ -0,0 +1,24 @@ +/** + * This class was created by . 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 @ [Nov 1, 2014, 9:20:33 PM (GMT)] + */ +package vazkii.botania.api.brew; + +import net.minecraft.item.ItemStack; + +/** + * An Item that implements this is a Brew item, by which it contains + * a brew. This is only used in vanilla to prevent the brew item + * from going back into the brewery but other mods might use it for whatever. + */ +public interface IBrewItem { + + public Brew getBrew(ItemStack brew); + +} diff --git a/src/api/java/vazkii/botania/api/corporea/CorporeaHelper.java b/src/api/java/vazkii/botania/api/corporea/CorporeaHelper.java new file mode 100644 index 0000000..87e4862 --- /dev/null +++ b/src/api/java/vazkii/botania/api/corporea/CorporeaHelper.java @@ -0,0 +1,291 @@ +/** + * This class was created by . 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 @ [Feb 14, 2015, 3:28:54 PM (GMT)] + */ +package vazkii.botania.api.corporea; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public final class CorporeaHelper { + + private static final List empty = Collections.unmodifiableList(new ArrayList()); + private static final WeakHashMap, List> cachedNetworks = new WeakHashMap(); + + /** + * How many items were matched in the last request. If java had "out" params like C# this wouldn't be needed :V + */ + public static int lastRequestMatches = 0; + /** + * How many items were extracted in the last request. + */ + public static int lastRequestExtractions = 0; + + /** + * Gets a list of all the inventories on this spark network. This list is cached for use once every tick, + * and if something changes during that tick it'll still have the first result. + */ + public static List getInventoriesOnNetwork(ICorporeaSpark spark) { + ICorporeaSpark master = spark.getMaster(); + if(master == null) + return empty; + List network = master.getConnections(); + + if(cachedNetworks.containsKey(network)) { + List cache = cachedNetworks.get(network); + if(cache != null) + return cache; + } + + List inventories = new ArrayList(); + if(network != null) + for(ICorporeaSpark otherSpark : network) + if(otherSpark != null) { + IInventory inv = otherSpark.getInventory(); + if(inv != null) + inventories.add(inv); + } + + cachedNetworks.put(network, inventories); + return inventories; + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + * The higher level functions that use a List< IInventory > or a Map< IInventory, Integer > should be + * called instead if the context for those exists to avoid having to get the values again. + */ + public static int getCountInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { + List inventories = getInventoriesOnNetwork(spark); + return getCountInNetwork(stack, inventories, checkNBT); + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + * The higher level function that use a Map< IInventory, Integer > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static int getCountInNetwork(ItemStack stack, List inventories, boolean checkNBT) { + Map map = getInventoriesWithItemInNetwork(stack, inventories, checkNBT); + return getCountInNetwork(stack, map, checkNBT); + } + + /** + * Gets the amount of available items in the network of the type passed in, checking NBT or not. + */ + public static int getCountInNetwork(ItemStack stack, Map inventories, boolean checkNBT) { + int count = 0; + + for(IInventory inv : inventories.keySet()) + count += inventories.get(inv); + + return count; + } + + /** + * Gets a Map mapping IInventories to the amount of items of the type passed in that exist + * The higher level function that use a List< IInventory > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static Map getInventoriesWithItemInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) { + List inventories = getInventoriesOnNetwork(spark); + return getInventoriesWithItemInNetwork(stack, inventories, checkNBT); + } + + /** + * Gets a Map mapping IInventories to the amount of items of the type passed in that exist + * The deeper level function that use a List< IInventory > should be + * called instead if the context for this exists to avoid having to get the value again. + */ + public static Map getInventoriesWithItemInNetwork(ItemStack stack, List inventories, boolean checkNBT) { + Map countMap = new HashMap(); + + for(IInventory inv : inventories) { + int count = 0; + for(int i = 0; i < inv.getSizeInventory(); i++) { + if(!isValidSlot(inv, i)) + continue; + + ItemStack stackAt = inv.getStackInSlot(i); + if(stacksMatch(stack, stackAt, checkNBT)) + count += stackAt.stackSize; + } + + if(count > 0) + countMap.put(inv, count); + } + + return countMap; + } + + /** + * Bridge for requestItem() using an ItemStack. + */ + public static List requestItem(ItemStack stack, ICorporeaSpark spark, boolean checkNBT, boolean doit) { + return requestItem(stack, stack.stackSize, spark, checkNBT, doit); + } + + /** + * Bridge for requestItem() using a String and an item count. + */ + public static List requestItem(String name, int count, ICorporeaSpark spark, boolean doit) { + return requestItem(name, count, spark, false, doit); + } + + /** + * Requests list of ItemStacks of the type passed in from the network, or tries to, checking NBT or not. + * This will remove the items from the adequate inventories unless the "doit" parameter is false. + * Returns a new list of ItemStacks of the items acquired or an empty list if none was found. + *

    + * The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the + * two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item + * equals or matches (case a regex is passed in) the matcher string. + */ + public static List requestItem(Object matcher, int itemCount, ICorporeaSpark spark, boolean checkNBT, boolean doit) { + List inventories = getInventoriesOnNetwork(spark); + List stacks = new ArrayList(); + + lastRequestMatches = 0; + lastRequestExtractions = 0; + + int count = itemCount; + for(IInventory inv : inventories) { + ICorporeaSpark invSpark = getSparkForInventory(inv); + for(int i = inv.getSizeInventory() - 1; i >= 0; i--) { + if(!isValidSlot(inv, i)) + continue; + + ItemStack stackAt = inv.getStackInSlot(i); + if(matcher instanceof ItemStack ? stacksMatch((ItemStack) matcher, stackAt, checkNBT) : matcher instanceof String ? stacksMatch(stackAt, (String) matcher) : false) { + int rem = Math.min(stackAt.stackSize, count); + + if(rem > 0) { + ItemStack copy = stackAt.copy(); + if(rem < copy.stackSize) + copy.stackSize = rem; + stacks.add(copy); + } + + lastRequestMatches += stackAt.stackSize; + lastRequestExtractions += rem; + if(doit && rem > 0) { + stackAt.stackSize -= rem; + if(stackAt.stackSize == 0) + inv.setInventorySlotContents(i, null); + if(invSpark != null) + invSpark.onItemExtracted(stackAt); + } + count -= rem; + } + } + } + + return stacks; + } + + /** + * Gets the spark attached to the inventory passed case it's a TileEntity. + */ + public static ICorporeaSpark getSparkForInventory(IInventory inv) { + if(!(inv instanceof TileEntity)) + return null; + + TileEntity tile = (TileEntity) inv; + return getSparkForBlock(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); + } + + /** + * Gets the spark attached to the block in the coords passed in. Note that the coords passed + * in are for the block that the spark will be on, not the coords of the spark itself. + */ + public static ICorporeaSpark getSparkForBlock(World world, int x, int y, int z) { + List sparks = world.getEntitiesWithinAABB(ICorporeaSpark.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)); + return sparks.isEmpty() ? null : sparks.get(0); + } + + /** + * Gets if the block in the coords passed in has a spark attached. Note that the coords passed + * in are for the block that the spark will be on, not the coords of the spark itself. + */ + public static boolean doesBlockHaveSpark(World world, int x, int y, int z) { + return getSparkForBlock(world, x, y, z) != null; + } + + /** + * Gets if the slot passed in can be extracted from by a spark. + */ + public static boolean isValidSlot(IInventory inv, int slot) { + return !(inv instanceof ISidedInventory) || arrayHas(((ISidedInventory) inv).getAccessibleSlotsFromSide(ForgeDirection.UP.ordinal()), slot); + } + + /** + * Gets if two stacks match. + */ + public static boolean stacksMatch(ItemStack stack1, ItemStack stack2, boolean checkNBT) { + return stack1 != null && stack2 != null && stack1.isItemEqual(stack2) && (!checkNBT || ItemStack.areItemStackTagsEqual(stack1, stack2)); + } + + /** + * Gets if the name of a stack matches the string passed in. + */ + public static boolean stacksMatch(ItemStack stack, String s) { + if(stack == null) + return false; + + boolean contains = false; + if(s.endsWith("...")) { + contains = true; + s = s.substring(0, s.length() - 3); + } + if(s.startsWith("...")) { + contains = true; + s = s.substring(3); + } + + String name = stack.getDisplayName().toLowerCase().trim(); + return equalOrContain(name, s, contains) || equalOrContain(name + "s", s, contains) || equalOrContain(name + "es", s, contains) || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies", s, contains); + } + + /** + * Clears the cached networks, called once per tick, should not be called outside + * of the botania code. + */ + public static void clearCache() { + cachedNetworks.clear(); + } + + /** + * Helper method to check if an int array contains an int. + */ + public static boolean arrayHas(int[] arr, int val) { + for (int element : arr) + if(element == val) + return true; + + return false; + } + + /** + * Helper method to make stacksMatch() less messy. + */ + public static boolean equalOrContain(String s1, String s2, boolean contain) { + return contain ? s1.contains(s2) : s1.equals(s2); + } +} diff --git a/src/api/java/vazkii/botania/api/corporea/ICorporeaSpark.java b/src/api/java/vazkii/botania/api/corporea/ICorporeaSpark.java new file mode 100644 index 0000000..943e29e --- /dev/null +++ b/src/api/java/vazkii/botania/api/corporea/ICorporeaSpark.java @@ -0,0 +1,87 @@ +/** + * This class was created by . 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 @ [Feb 13, 2015, 10:53:05 PM (GMT)] + */ +package vazkii.botania.api.corporea; + +import java.util.List; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +/** + * An interface for a Corporea Spark. Includes functions for handling + * connections. + */ +public interface ICorporeaSpark { + + /** + * Called to register the connections for the spark network passed in. Parameters include the master spark, + * which is the one that initiated the chain call, the referrer which passed the call to this instance + * and the List of sparks connected. Normal behavior should be to find any sparks around that are not + * already present in the list of connections and add them to it, passing the function call to them. + *

    + * The connections List and the master Spark should be kept in this instance as pointers for use in + * getConnections() and getMaster() and passed in to any subsequent registerConnections calls on sparks + * found nearby. This is only called whenever a new spark is added or removed from and to the network, + * at that point the connection list in the master spark would be cleared out, also clearing out the one + * in this instance, as it should be a pointer. + */ + public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections); + + /** + * Gets the inventory this spark is bound to, generally the one right below it. + */ + public IInventory getInventory(); + + /** + * Gets the list of sparks this spark is connected to, see registerConnections(). This list + * should also include itself. This list must be checked against on a regular basis to verify + * that the spark is still in the network, if that's not the case, the pointer should be + * eliminated. + */ + public List getConnections(); + + /** + * Gets the list of sparks that this spark added to the list of connections during registerConnections(), this + * is mainly used to create a non messy chain of particles to display the network when a spark is right + * clicked with a wand. + */ + public List getRelatives(); + + /** + * Gets the master spark in this network, see registerConnections(). The value this returns + * should be null and the pointer should be eliminated if the spark is no longer present + * in the network. + */ + public ICorporeaSpark getMaster(); + + /** + * Called when an item is extracted from the inventory this spark is attached to through this + * spark. + */ + public void onItemExtracted(ItemStack stack); + + /** + * Called when this spark requests items, passes in the result of the request and not the actual requested stack(s). + */ + public void onItemsRequested(List stacks); + + /** + * Gets if this spark is considered a master spark. + */ + public boolean isMaster(); + + /** + * Gets the network that this spark is on, or the color it's displaying. Sparks may only connect to others + * of the same network, and on changing network should trigger a re-cache of the previous network. + */ + public int getNetwork(); + +} diff --git a/src/api/java/vazkii/botania/api/internal/DummyManaNetwork.java b/src/api/java/vazkii/botania/api/internal/DummyManaNetwork.java index 53a8e42..f74d0ca 100644 --- a/src/api/java/vazkii/botania/api/internal/DummyManaNetwork.java +++ b/src/api/java/vazkii/botania/api/internal/DummyManaNetwork.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Mar 7, 2014, 3:47:43 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/internal/DummyMethodHandler.java b/src/api/java/vazkii/botania/api/internal/DummyMethodHandler.java index 22e9da4..b5bc59f 100644 --- a/src/api/java/vazkii/botania/api/internal/DummyMethodHandler.java +++ b/src/api/java/vazkii/botania/api/internal/DummyMethodHandler.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 14, 2014, 6:43:03 PM (GMT)] */ @@ -20,9 +19,13 @@ import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.lexicon.LexiconPage; +import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RecipePetals; @@ -35,6 +38,11 @@ public class DummyMethodHandler implements IInternalMethodHandler { return dummyPage(key); } + @Override + public LexiconPage elfPaperTextPage(String key) { + return dummyPage(key); + } + @Override public LexiconPage imagePage(String key, String resource) { return dummyPage(key); @@ -90,6 +98,11 @@ public class DummyMethodHandler implements IInternalMethodHandler { return dummyPage(key); } + @Override + public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe) { + return dummyPage(key); + } + private LexiconPage dummyPage(String key) { return new DummyPage(key); } @@ -99,6 +112,11 @@ public class DummyMethodHandler implements IInternalMethodHandler { return new ItemStack(Blocks.stone, 0, 0); } + @Override + public ItemStack getSubTileAsFloatingFlowerStack(String subTile) { + return getSubTileAsStack(subTile); + } + @Override public IIcon getSubTileIconForName(String name) { return Blocks.red_flower.getIcon(0, 0); @@ -144,4 +162,19 @@ public class DummyMethodHandler implements IInternalMethodHandler { return 0; } + @Override + public ResourceLocation getDefaultBossBarTexture() { + return null; + } + + @Override + public void setBossStatus(IBotaniaBoss status) { + // NO-OP + } + + @Override + public boolean isBuildcraftPipe(TileEntity tile) { + return false; + } + } diff --git a/src/api/java/vazkii/botania/api/internal/DummyPage.java b/src/api/java/vazkii/botania/api/internal/DummyPage.java index 33cbcf8..843198c 100644 --- a/src/api/java/vazkii/botania/api/internal/DummyPage.java +++ b/src/api/java/vazkii/botania/api/internal/DummyPage.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 14, 2014, 6:41:23 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/internal/DummySubTile.java b/src/api/java/vazkii/botania/api/internal/DummySubTile.java index d23adce..d8ac6ab 100644 --- a/src/api/java/vazkii/botania/api/internal/DummySubTile.java +++ b/src/api/java/vazkii/botania/api/internal/DummySubTile.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 24, 2014, 4:17:33 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/internal/IGuiLexiconEntry.java b/src/api/java/vazkii/botania/api/internal/IGuiLexiconEntry.java index 6e3fa38..b0d4d6e 100644 --- a/src/api/java/vazkii/botania/api/internal/IGuiLexiconEntry.java +++ b/src/api/java/vazkii/botania/api/internal/IGuiLexiconEntry.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 14, 2014, 6:48:41 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/internal/IInternalMethodHandler.java b/src/api/java/vazkii/botania/api/internal/IInternalMethodHandler.java index f75f208..a5892b6 100644 --- a/src/api/java/vazkii/botania/api/internal/IInternalMethodHandler.java +++ b/src/api/java/vazkii/botania/api/internal/IInternalMethodHandler.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 14, 2014, 6:34:34 PM (GMT)] */ @@ -19,9 +18,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.lexicon.LexiconPage; +import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RecipePetals; @@ -40,6 +43,8 @@ public interface IInternalMethodHandler { public LexiconPage textPage(String key); + public LexiconPage elfPaperTextPage(String key); + public LexiconPage imagePage(String key, String resource); public LexiconPage craftingRecipesPage(String key, List recipes); @@ -62,10 +67,14 @@ public interface IInternalMethodHandler { public LexiconPage elvenTradesPage(String key, RecipeElvenTrade recipe); + public LexiconPage brewPage(String key, String bottomText, RecipeBrew recipe); + public IManaNetwork getManaNetworkInstance(); public ItemStack getSubTileAsStack(String subTile); + public ItemStack getSubTileAsFloatingFlowerStack(String subTile); + public IIcon getSubTileIconForName(String name); public void registerBasicSignatureIcons(String name, IIconRegister register); @@ -82,6 +91,14 @@ public interface IInternalMethodHandler { @SideOnly(Side.CLIENT) public void renderLexiconText(int x, int y, int width, int height, String unlocalizedText); + @SideOnly(Side.CLIENT) + public ResourceLocation getDefaultBossBarTexture(); + + @SideOnly(Side.CLIENT) + public void setBossStatus(IBotaniaBoss status); + + public boolean isBuildcraftPipe(TileEntity tile); + public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m); } diff --git a/src/api/java/vazkii/botania/api/internal/IManaBurst.java b/src/api/java/vazkii/botania/api/internal/IManaBurst.java index 38c5fd8..343c7a0 100644 --- a/src/api/java/vazkii/botania/api/internal/IManaBurst.java +++ b/src/api/java/vazkii/botania/api/internal/IManaBurst.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 31, 2014, 4:36:13 PM (GMT)] */ @@ -57,6 +56,8 @@ public interface IManaBurst { public boolean hasAlreadyCollidedAt(int x, int y, int z); + public void setCollidedAt(int x, int y, int z); + public int getTicksExisted(); } diff --git a/src/api/java/vazkii/botania/api/internal/IManaNetwork.java b/src/api/java/vazkii/botania/api/internal/IManaNetwork.java index 38e9419..fc4553e 100644 --- a/src/api/java/vazkii/botania/api/internal/IManaNetwork.java +++ b/src/api/java/vazkii/botania/api/internal/IManaNetwork.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Mar 7, 2014, 3:39:48 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/internal/ShaderCallback.java b/src/api/java/vazkii/botania/api/internal/ShaderCallback.java new file mode 100644 index 0000000..12186a2 --- /dev/null +++ b/src/api/java/vazkii/botania/api/internal/ShaderCallback.java @@ -0,0 +1,20 @@ +/** + * This class was created by . 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 @ [Oct 29, 2014, 6:31:35 PM (GMT)] + */ +package vazkii.botania.api.internal; + +/** + * A Callback for when a shader is called. Used to define shader uniforms. + */ +public abstract class ShaderCallback { + + public abstract void call(int shader); + +} diff --git a/src/api/java/vazkii/botania/api/item/IAncientWillContainer.java b/src/api/java/vazkii/botania/api/item/IAncientWillContainer.java new file mode 100644 index 0000000..2d2abe2 --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IAncientWillContainer.java @@ -0,0 +1,25 @@ +/** + * This class was created by . 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 @ [Jan 30, 2015, 11:24:54 PM (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.item.ItemStack; + +/** + * An item that implements this can have Ancient Wills + * crafted onto it. + */ +public interface IAncientWillContainer { + + public void addAncientWill(ItemStack stack, int will); + + public boolean hasAncientWill(ItemStack stack, int will); + +} diff --git a/src/api/java/vazkii/botania/api/item/IBaubleRender.java b/src/api/java/vazkii/botania/api/item/IBaubleRender.java new file mode 100644 index 0000000..7cc492a --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IBaubleRender.java @@ -0,0 +1,77 @@ +/** + * This class was created by . 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 @ [Dec 4, 2014, 3:28:43 PM (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.event.RenderPlayerEvent; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * A Bauble Item that implements this will be have hooks to render something on + * the player while its equipped. + * This class doesn't extend IBauble to make the API not depend on the Baubles + * API, but the item in question still needs to implement IBauble. + */ +public interface IBaubleRender { + + /** + * Called for the rendering of the bauble on the player. The player instance can be + * acquired through the event parameter. Transformations are already applied for + * the RenderType passed in. Make sure to check against the type parameter for + * rendering. Will not be called if the item is a ICosmeticAttachable and + * has a cosmetic bauble attached to it. + */ + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type); + + /** + * A few helper methods for the render. + */ + public static class Helper { + + public static void rotateIfSneaking(EntityPlayer player) { + if(player.isSneaking()) + applySneakingRotation(); + } + + public static void applySneakingRotation() { + GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); + } + + public static void translateToHeadLevel(EntityPlayer player) { + GL11.glTranslated(0, (player != Minecraft.getMinecraft().thePlayer ? 1.62F : 0F) - player.getDefaultEyeHeight() + (player.isSneaking() ? 0.0625 : 0), 0); + } + + } + + public static enum RenderType { + /** + * Render Type for the player's body, translations apply on the player's rotation. + * Sneaking is not handled and should be done during the render. + * @see IBaubleRender.Helper + */ + BODY, + + /** + * Render Type for the player's body, translations apply on the player's head rotations. + * Sneaking is not handled and should be done during the render.~ + * @see IBaubleRender.Helper + */ + HEAD; + } + +} diff --git a/src/api/java/vazkii/botania/api/item/IBurstViewerBauble.java b/src/api/java/vazkii/botania/api/item/IBurstViewerBauble.java new file mode 100644 index 0000000..7e37c84 --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IBurstViewerBauble.java @@ -0,0 +1,20 @@ +/** + * This class was created by . 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 @ [Jan 24, 2015, 3:08:40 PM (GMT)] + */ +package vazkii.botania.api.item; + +/** + * Base Interface for the Manaseer Monocle and items of the sort. + * Having a IBauble of this type equipped on the 0th slot (amulet) + * will draw bursts without depth testing. + */ +public interface IBurstViewerBauble { + +} diff --git a/src/api/java/vazkii/botania/api/item/ICosmeticAttachable.java b/src/api/java/vazkii/botania/api/item/ICosmeticAttachable.java new file mode 100644 index 0000000..4fbee0e --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/ICosmeticAttachable.java @@ -0,0 +1,33 @@ +/** + * This class was created by . 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 @ [Feb 22, 2015, 8:31:39 PM (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.item.ItemStack; + +/** + * An Item that implements this interface can have cosmetic items attached to it. + * The item does not have to be a bauble, but it is the render is automatically + * handled by botania internally. Recipes to add and remove the cosmetic items will be + * handled internally, but the cosmetic item has to be set as a container item. + */ +public interface ICosmeticAttachable { + + /** + * Gets the cosmetic item stored in the stack passed in. + */ + public ItemStack getCosmeticItem(ItemStack stack); + + /** + * Sets the stack's cosmetic item to the one passed in. + */ + public void setCosmeticItem(ItemStack stack, ItemStack cosmetic); + +} diff --git a/src/api/java/vazkii/botania/api/item/ICosmeticBauble.java b/src/api/java/vazkii/botania/api/item/ICosmeticBauble.java new file mode 100644 index 0000000..d488ad4 --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/ICosmeticBauble.java @@ -0,0 +1,20 @@ +/** + * This class was created by . 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 @ [Feb 22, 2015, 2:02:02 PM (GMT)] + */ +package vazkii.botania.api.item; + +/** + * A bauble that counts as a cosmetic only item. These can be added to + * other baubles to add the render to them. Other cosmetic baubles + * can't be stacked on this. + */ +public interface ICosmeticBauble extends IBaubleRender { + +} diff --git a/src/api/java/vazkii/botania/api/item/IDyablePool.java b/src/api/java/vazkii/botania/api/item/IDyablePool.java new file mode 100644 index 0000000..8bb8e94 --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IDyablePool.java @@ -0,0 +1,24 @@ +/** + * This class was created by . 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 @ [Jan 18, 2015, 12:20:44 AM (GMT)] + */ +package vazkii.botania.api.item; + + +/** + * Used to define a Mana Pool that can be dyed through floral powder. + */ +public interface IDyablePool { + + public int getColor(); + + public void setColor(int color); + + +} diff --git a/src/api/java/vazkii/botania/api/item/IExoflameHeatable.java b/src/api/java/vazkii/botania/api/item/IExoflameHeatable.java index eb4815c..bd00734 100644 --- a/src/api/java/vazkii/botania/api/item/IExoflameHeatable.java +++ b/src/api/java/vazkii/botania/api/item/IExoflameHeatable.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Aug 30, 2014, 4:28:29 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/item/IExtendedPlayerController.java b/src/api/java/vazkii/botania/api/item/IExtendedPlayerController.java index 67db3e6..e07d076 100644 --- a/src/api/java/vazkii/botania/api/item/IExtendedPlayerController.java +++ b/src/api/java/vazkii/botania/api/item/IExtendedPlayerController.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Aug 6, 2014, 6:02:29 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/item/IFlowerlessBiome.java b/src/api/java/vazkii/botania/api/item/IFlowerlessBiome.java new file mode 100644 index 0000000..16543e4 --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IFlowerlessBiome.java @@ -0,0 +1,21 @@ +/** + * This class was created by . 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 @ [? (GMT)] + */ +package vazkii.botania.api.item; +import net.minecraft.world.World; +/** + * A BiomeGenBase that implements this will not have Botania flowers generated. + */ +public interface IFlowerlessBiome { + /** + * @return Should this world be allowed to generate flowers? + */ + public boolean canGenerateFlowers(World world, int x, int z); +} \ No newline at end of file diff --git a/src/api/java/vazkii/botania/api/item/IFlowerlessWorld.java b/src/api/java/vazkii/botania/api/item/IFlowerlessWorld.java new file mode 100644 index 0000000..5d25d79 --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IFlowerlessWorld.java @@ -0,0 +1,24 @@ +/** + * This class was created by . 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 @ [? (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.world.World; + +/** + * A WorldProvider that implements this will not have Botania flowers generated. + */ +public interface IFlowerlessWorld { + + /** + * @return Should this world be allowed to generate flowers? + */ + public boolean generateFlowers(World world); +} diff --git a/src/api/java/vazkii/botania/api/item/IGrassHornExcempt.java b/src/api/java/vazkii/botania/api/item/IGrassHornExcempt.java new file mode 100644 index 0000000..b23774c --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IGrassHornExcempt.java @@ -0,0 +1,23 @@ +/** + * This class was created by . 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 @ [Oct 29, 2014, 4:52:04 PM (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.world.World; + +/** + * A BlockBush can implement this to check if it can be broken + * by a Horn/Drum of the Wild or not. + */ +public interface IGrassHornExcempt { + + public boolean canUproot(World world, int x, int y, int z); + +} diff --git a/src/api/java/vazkii/botania/api/item/IManaDissolvable.java b/src/api/java/vazkii/botania/api/item/IManaDissolvable.java new file mode 100644 index 0000000..0d9ad5d --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/IManaDissolvable.java @@ -0,0 +1,29 @@ +/** + * This class was created by . 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 @ [Jan 18, 2015, 12:10:00 AM (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import vazkii.botania.api.mana.IManaPool; + +/** + * An item that implements this will have a function called when its standing atop + * a mana pool. + */ +public interface IManaDissolvable { + + /** + * Called for every tick the item is on a mana pool. If the stack has stack + * size 0 the item is killed. This is called in both the server and client. + */ + public void onDissolveTick(IManaPool pool, ItemStack stack, EntityItem item); + +} diff --git a/src/api/java/vazkii/botania/api/item/IPetalApothecary.java b/src/api/java/vazkii/botania/api/item/IPetalApothecary.java index d96f73f..15ae69c 100644 --- a/src/api/java/vazkii/botania/api/item/IPetalApothecary.java +++ b/src/api/java/vazkii/botania/api/item/IPetalApothecary.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Aug 30, 2014, 4:22:15 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/item/IPixieSpawner.java b/src/api/java/vazkii/botania/api/item/IPixieSpawner.java index c0d47f8..de8c973 100644 --- a/src/api/java/vazkii/botania/api/item/IPixieSpawner.java +++ b/src/api/java/vazkii/botania/api/item/IPixieSpawner.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Aug 6, 2014, 6:06:27 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/item/ISortableTool.java b/src/api/java/vazkii/botania/api/item/ISortableTool.java new file mode 100644 index 0000000..af450bc --- /dev/null +++ b/src/api/java/vazkii/botania/api/item/ISortableTool.java @@ -0,0 +1,47 @@ +/** + * This class was created by . 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 @ [Feb 23, 2015, 7:03:48 PM (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.item.ItemStack; + +/** + * This interface describes a tool that can be sorted by the Ring of + * Correction. + */ +public interface ISortableTool { + + /** + * Gets the type of tool that this is. A pick, axe or shovel. + */ + public ToolType getSortingType(ItemStack stack); + + /** + * Gets the priority that this tool should have when being sorted. The + * tool with the highest priority will be picked. The way this is specified + * should be (tool-level) * 100 + (tool-modifier) * 10 + (efficiency-level). + *

    + * For example, a Manasteel Pickaxe is tool-level 10 and it doesn't have + * modifiers. Assuming Efficiency 4, the priority should be 10 * 100 + 4 = 1004. + * This will rate higher than a similar pickaxe with Efficiency 3.
    + * A Terra Shatterer has a modifier, its rank and is tool-level 20. With Efficiency + * 5 and rank B (2) the priority should be 20 * 100 + 2 * 10 + 5 = 2025. + *

    + * All intermediate tool levels are there for other mod tools that wish to occupy the spots inbetween. + * Of course, you don't have to always adhere to this. Tools like the Vitreous Pickaxe don't, + * that one in particular is priority 0 so it's never picked. + */ + public int getSortingPriority(ItemStack stack); + + public static enum ToolType { + PICK, AXE, SHOVEL + } + +} \ No newline at end of file diff --git a/src/api/java/vazkii/botania/api/lexicon/IAddonEntry.java b/src/api/java/vazkii/botania/api/lexicon/IAddonEntry.java index fe2167b..a92e608 100644 --- a/src/api/java/vazkii/botania/api/lexicon/IAddonEntry.java +++ b/src/api/java/vazkii/botania/api/lexicon/IAddonEntry.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jun 8, 2014, 7:02:48 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/lexicon/ILexiconable.java b/src/api/java/vazkii/botania/api/lexicon/ILexiconable.java index e8777db..5baff9f 100644 --- a/src/api/java/vazkii/botania/api/lexicon/ILexiconable.java +++ b/src/api/java/vazkii/botania/api/lexicon/ILexiconable.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 20, 2014, 7:05:44 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java b/src/api/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java index d07c032..5b0c063 100644 --- a/src/api/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java +++ b/src/api/java/vazkii/botania/api/lexicon/IRecipeKeyProvider.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Mar 20, 2014, 6:08:48 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/lexicon/ITwoNamedPage.java b/src/api/java/vazkii/botania/api/lexicon/ITwoNamedPage.java new file mode 100644 index 0000000..073b870 --- /dev/null +++ b/src/api/java/vazkii/botania/api/lexicon/ITwoNamedPage.java @@ -0,0 +1,23 @@ +/** + * This class was created by . 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 @ [Nov 3, 2014, 2:59:55 PM (GMT)] + */ +package vazkii.botania.api.lexicon; + +/** + * A LexiconPage that implements this has two unlocalized names + * rather than one. (See brew pages) + */ +public interface ITwoNamedPage { + + public void setSecondUnlocalizedName(String name); + + public String getSecondUnlocalizedName(); + +} diff --git a/src/api/java/vazkii/botania/api/lexicon/LexiconCategory.java b/src/api/java/vazkii/botania/api/lexicon/LexiconCategory.java index b92d1f4..06f678d 100644 --- a/src/api/java/vazkii/botania/api/lexicon/LexiconCategory.java +++ b/src/api/java/vazkii/botania/api/lexicon/LexiconCategory.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 14, 2014, 6:23:47 PM (GMT)] */ @@ -16,23 +15,51 @@ import java.util.List; import net.minecraft.util.ResourceLocation; -public class LexiconCategory { +public class LexiconCategory implements Comparable { + + private static int count = 0; public final String unlocalizedName; public final List entries = new ArrayList(); + private final int sortingId; private ResourceLocation icon; + private int priority = 5; /** * @param unlocalizedName The unlocalized name of this category. This will be localized by the client display. */ public LexiconCategory(String unlocalizedName) { this.unlocalizedName = unlocalizedName; + sortingId = count; + count++; } public String getUnlocalizedName() { return unlocalizedName; } + /** + * Sets the priority for this category for sorting. Higher numbers + * means they'll appear first in the book. The basics category + * is 9, the miscellaneous category is 0, other vanilla botania categories + * are 5. Using 9 and 0 is not recommended, since having your + * categories before basics or after miscellaneous is a bad idea. + * If two categories have the same priority they'll be sorted + * by insertion order. + */ + public LexiconCategory setPriority(int priority) { + this.priority = priority; + return this; + } + + public int getSortingPriority() { + return priority; + } + + public final int getSortingId() { + return sortingId; + } + public LexiconCategory setIcon(ResourceLocation icon) { this.icon = icon; return this; @@ -41,4 +68,9 @@ public class LexiconCategory { public ResourceLocation getIcon() { return icon; } + + @Override + public int compareTo(LexiconCategory category) { + return priority == category.priority ? sortingId - category.sortingId : category.priority - priority; + } } diff --git a/src/api/java/vazkii/botania/api/lexicon/LexiconEntry.java b/src/api/java/vazkii/botania/api/lexicon/LexiconEntry.java index bbc475c..3151e62 100644 --- a/src/api/java/vazkii/botania/api/lexicon/LexiconEntry.java +++ b/src/api/java/vazkii/botania/api/lexicon/LexiconEntry.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 14, 2014, 6:17:06 PM (GMT)] */ @@ -15,6 +14,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import vazkii.botania.api.BotaniaAPI; @@ -27,6 +27,7 @@ public class LexiconEntry implements Comparable { public List pages = new ArrayList(); private boolean priority = false; + private ItemStack icon = null; /** * @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display. @@ -56,6 +57,18 @@ public class LexiconEntry implements Comparable { return type; } + /** + * Sets the display icon for this entry. Overriding the one already there. When adding recipe pages to the + * entry, this will be called once for the result of the first found recipe. + */ + public void setIcon(ItemStack stack) { + icon = stack; + } + + public ItemStack getIcon() { + return icon; + } + public boolean isPriority() { return priority; } diff --git a/src/api/java/vazkii/botania/api/lexicon/LexiconPage.java b/src/api/java/vazkii/botania/api/lexicon/LexiconPage.java index 08f089f..e0982e7 100644 --- a/src/api/java/vazkii/botania/api/lexicon/LexiconPage.java +++ b/src/api/java/vazkii/botania/api/lexicon/LexiconPage.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 14, 2014, 6:17:24 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java b/src/api/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java index 49b2a13..f4456b9 100644 --- a/src/api/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java +++ b/src/api/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Mar 6, 2014, 3:54:12 PM (GMT)] */ @@ -34,12 +33,17 @@ public final class LexiconRecipeMappings { if(force || !mappings.containsKey(str)) mappings.put(str, data); + if(entry.getIcon() == null) + entry.setIcon(stack.copy()); } public static void map(ItemStack stack, LexiconEntry entry, int page) { map(stack, entry, page, false); } + public static void remove(ItemStack stack) { + mappings.remove(stackToString(stack)); + } public static EntryData getDataForStack(ItemStack stack) { return mappings.get(stackToString(stack)); diff --git a/src/api/java/vazkii/botania/api/mana/BurstProperties.java b/src/api/java/vazkii/botania/api/mana/BurstProperties.java index eed7480..75ff0f8 100644 --- a/src/api/java/vazkii/botania/api/mana/BurstProperties.java +++ b/src/api/java/vazkii/botania/api/mana/BurstProperties.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 31, 2014, 3:49:30 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IClientManaHandler.java b/src/api/java/vazkii/botania/api/mana/IClientManaHandler.java index 889cfb5..aea14b9 100644 --- a/src/api/java/vazkii/botania/api/mana/IClientManaHandler.java +++ b/src/api/java/vazkii/botania/api/mana/IClientManaHandler.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jul 2, 2014, 5:26:02 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/ICreativeManaProvider.java b/src/api/java/vazkii/botania/api/mana/ICreativeManaProvider.java index 51f3cce..2556663 100644 --- a/src/api/java/vazkii/botania/api/mana/ICreativeManaProvider.java +++ b/src/api/java/vazkii/botania/api/mana/ICreativeManaProvider.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [May 25, 2014, 7:34:00 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IKeyLocked.java b/src/api/java/vazkii/botania/api/mana/IKeyLocked.java index a7870e6..ce71694 100644 --- a/src/api/java/vazkii/botania/api/mana/IKeyLocked.java +++ b/src/api/java/vazkii/botania/api/mana/IKeyLocked.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jul 11, 2014, 4:29:32 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/ILaputaImmobile.java b/src/api/java/vazkii/botania/api/mana/ILaputaImmobile.java index 91cb0b9..dfa2945 100644 --- a/src/api/java/vazkii/botania/api/mana/ILaputaImmobile.java +++ b/src/api/java/vazkii/botania/api/mana/ILaputaImmobile.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jul 26, 2014, 9:51:58 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/ILens.java b/src/api/java/vazkii/botania/api/mana/ILens.java index 628d102..d125e57 100644 --- a/src/api/java/vazkii/botania/api/mana/ILens.java +++ b/src/api/java/vazkii/botania/api/mana/ILens.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 31, 2014, 3:03:04 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/ILensEffect.java b/src/api/java/vazkii/botania/api/mana/ILensEffect.java index d97095b..4c88f55 100644 --- a/src/api/java/vazkii/botania/api/mana/ILensEffect.java +++ b/src/api/java/vazkii/botania/api/mana/ILensEffect.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Apr 14, 2014, 7:30:00 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IManaBlock.java b/src/api/java/vazkii/botania/api/mana/IManaBlock.java index 6896f05..56aa037 100644 --- a/src/api/java/vazkii/botania/api/mana/IManaBlock.java +++ b/src/api/java/vazkii/botania/api/mana/IManaBlock.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 22, 2014, 4:59:05 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IManaCollector.java b/src/api/java/vazkii/botania/api/mana/IManaCollector.java index a54d8c9..280e460 100644 --- a/src/api/java/vazkii/botania/api/mana/IManaCollector.java +++ b/src/api/java/vazkii/botania/api/mana/IManaCollector.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 22, 2014, 5:01:19 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IManaCollisionGhost.java b/src/api/java/vazkii/botania/api/mana/IManaCollisionGhost.java index 420f683..76b537e 100644 --- a/src/api/java/vazkii/botania/api/mana/IManaCollisionGhost.java +++ b/src/api/java/vazkii/botania/api/mana/IManaCollisionGhost.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Mar 10, 2014, 7:49:19 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IManaDiscountArmor.java b/src/api/java/vazkii/botania/api/mana/IManaDiscountArmor.java new file mode 100644 index 0000000..e580939 --- /dev/null +++ b/src/api/java/vazkii/botania/api/mana/IManaDiscountArmor.java @@ -0,0 +1,30 @@ +/** + * This class was created by . 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 @ [Jan 28, 2015, 9:22:53 PM (GMT)] + */ +package vazkii.botania.api.mana; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * An armor item that implements this can provide a mana discount for mana tools. + * Mana tools are the ones on the main toolset (Pick, Shovel, Axe, Sword and Shovel). + */ +public interface IManaDiscountArmor { + + /** + * Gets the mana discount that this piece of armor provides. This is added + * together to create the full discount. + * Value is to be from 0.0 to 1.0. 0.1 is 10% discount, as an example. + * You can also return negative values to make tools cost more. + */ + public float getDiscount(ItemStack stack, int slot, EntityPlayer player); + +} diff --git a/src/api/java/vazkii/botania/api/mana/IManaItem.java b/src/api/java/vazkii/botania/api/mana/IManaItem.java index 42dfef1..f4463fb 100644 --- a/src/api/java/vazkii/botania/api/mana/IManaItem.java +++ b/src/api/java/vazkii/botania/api/mana/IManaItem.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Mar 6, 2014, 9:07:40 AM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IManaPool.java b/src/api/java/vazkii/botania/api/mana/IManaPool.java index b93bf6e..df523a6 100644 --- a/src/api/java/vazkii/botania/api/mana/IManaPool.java +++ b/src/api/java/vazkii/botania/api/mana/IManaPool.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 22, 2014, 5:03:09 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IManaReceiver.java b/src/api/java/vazkii/botania/api/mana/IManaReceiver.java index 2838c7b..178856f 100644 --- a/src/api/java/vazkii/botania/api/mana/IManaReceiver.java +++ b/src/api/java/vazkii/botania/api/mana/IManaReceiver.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 22, 2014, 4:55:00 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IManaTrigger.java b/src/api/java/vazkii/botania/api/mana/IManaTrigger.java index 684a2c1..61aadfc 100644 --- a/src/api/java/vazkii/botania/api/mana/IManaTrigger.java +++ b/src/api/java/vazkii/botania/api/mana/IManaTrigger.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [May 16, 2014, 7:52:53 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IManaUsingItem.java b/src/api/java/vazkii/botania/api/mana/IManaUsingItem.java index d06cf74..9fe55fc 100644 --- a/src/api/java/vazkii/botania/api/mana/IManaUsingItem.java +++ b/src/api/java/vazkii/botania/api/mana/IManaUsingItem.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [May 25, 2014, 7:32:10 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/IPoolOverlayProvider.java b/src/api/java/vazkii/botania/api/mana/IPoolOverlayProvider.java index f677c3e..e443e2c 100644 --- a/src/api/java/vazkii/botania/api/mana/IPoolOverlayProvider.java +++ b/src/api/java/vazkii/botania/api/mana/IPoolOverlayProvider.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jul 2, 2014, 6:36:54 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java b/src/api/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java index 004c52e..a82114c 100644 --- a/src/api/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java +++ b/src/api/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jul 22, 2014, 2:26:14 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/ManaItemHandler.java b/src/api/java/vazkii/botania/api/mana/ManaItemHandler.java index 74fb005..e05be50 100644 --- a/src/api/java/vazkii/botania/api/mana/ManaItemHandler.java +++ b/src/api/java/vazkii/botania/api/mana/ManaItemHandler.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Mar 13, 2014, 5:32:24 PM (GMT)] */ @@ -198,4 +197,47 @@ public final class ManaItemHandler { return false; } + + /** + * Requests mana from items in a given player's inventory. This version also + * checks for IManaDiscountArmor items equipped to lower the cost. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return The amount of mana received from the request. + */ + public static int requestManaForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); + int cost = (int) (manaToGet * multiplier); + return (int) (requestMana(stack, player, cost, remove) / multiplier); + } + + /** + * Requests an exact amount of mana from items in a given player's inventory. This version also + * checks for IManaDiscountArmor items equipped to lower the cost. + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * false will be returned instead, and nothing will happen. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return If the request was succesful. + */ + public static boolean requestManaExactForTool(ItemStack stack, EntityPlayer player, int manaToGet, boolean remove) { + float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player)); + int cost = (int) (manaToGet * multiplier); + return requestManaExact(stack, player, cost, remove); + } + + /** + * Gets the sum of all the discounts on IManaDiscountArmor items equipped + * on the player passed in. + */ + public static float getFullDiscountForTools(EntityPlayer player) { + float discount = 0F; + for(int i = 0; i < player.inventory.armorInventory.length; i++) { + ItemStack armor = player.inventory.armorInventory[i]; + if(armor != null && armor.getItem() instanceof IManaDiscountArmor) + discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player); + } + + return discount; + } } diff --git a/src/api/java/vazkii/botania/api/mana/ManaNetworkEvent.java b/src/api/java/vazkii/botania/api/mana/ManaNetworkEvent.java index e04253a..9116602 100644 --- a/src/api/java/vazkii/botania/api/mana/ManaNetworkEvent.java +++ b/src/api/java/vazkii/botania/api/mana/ManaNetworkEvent.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 22, 2014, 5:04:30 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/spark/ISparkAttachable.java b/src/api/java/vazkii/botania/api/mana/spark/ISparkAttachable.java index 4353f01..880e169 100644 --- a/src/api/java/vazkii/botania/api/mana/spark/ISparkAttachable.java +++ b/src/api/java/vazkii/botania/api/mana/spark/ISparkAttachable.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Aug 21, 2014, 5:44:13 PM (GMT)] */ @@ -31,6 +30,12 @@ public interface ISparkAttachable extends IManaReceiver { */ public void attachSpark(ISparkEntity entity); + /** + * Returns how much space for mana is available in this block, normally the total - the current. + * Should NEVER return negative values. Make sure to check against that. + */ + public int getAvailableSpaceForMana(); + /** * Gets the Spark that is attached to this block. A common implementation is * to check for Spark entities above: diff --git a/src/api/java/vazkii/botania/api/mana/spark/ISparkEntity.java b/src/api/java/vazkii/botania/api/mana/spark/ISparkEntity.java index 084b827..e35076c 100644 --- a/src/api/java/vazkii/botania/api/mana/spark/ISparkEntity.java +++ b/src/api/java/vazkii/botania/api/mana/spark/ISparkEntity.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Aug 21, 2014, 5:44:07 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/mana/spark/SparkHelper.java b/src/api/java/vazkii/botania/api/mana/spark/SparkHelper.java index 6bb3196..7351036 100644 --- a/src/api/java/vazkii/botania/api/mana/spark/SparkHelper.java +++ b/src/api/java/vazkii/botania/api/mana/spark/SparkHelper.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Aug 21, 2014, 7:16:11 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/package-info.java b/src/api/java/vazkii/botania/api/package-info.java index 30df733..9424a03 100644 --- a/src/api/java/vazkii/botania/api/package-info.java +++ b/src/api/java/vazkii/botania/api/package-info.java @@ -1,4 +1,4 @@ -@API(owner = "Botania", apiVersion = "19", provides = "BotaniaAPI") +@API(owner = "Botania", apiVersion = "35", provides = "BotaniaAPI") package vazkii.botania.api; import cpw.mods.fml.common.API; diff --git a/src/api/java/vazkii/botania/api/recipe/IFlowerComponent.java b/src/api/java/vazkii/botania/api/recipe/IFlowerComponent.java index fe5bf3c..ca46124 100644 --- a/src/api/java/vazkii/botania/api/recipe/IFlowerComponent.java +++ b/src/api/java/vazkii/botania/api/recipe/IFlowerComponent.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Feb 15, 2014, 2:36:35 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/recipe/RecipeBrew.java b/src/api/java/vazkii/botania/api/recipe/RecipeBrew.java new file mode 100644 index 0000000..9557778 --- /dev/null +++ b/src/api/java/vazkii/botania/api/recipe/RecipeBrew.java @@ -0,0 +1,114 @@ +/** + * This class was created by . 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 @ [Nov 1, 2014, 8:52:00 PM (GMT)] + */ +package vazkii.botania.api.recipe; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import vazkii.botania.api.brew.Brew; +import vazkii.botania.api.brew.IBrewContainer; + +public class RecipeBrew { + + Brew brew; + List inputs; + + public RecipeBrew(Brew brew, Object... inputs) { + this.brew = brew; + + List inputsToSet = new ArrayList(); + for(Object obj : inputs) { + if(obj instanceof String || obj instanceof ItemStack) + inputsToSet.add(obj); + else throw new IllegalArgumentException("Invalid input"); + } + + this.inputs = inputsToSet; + } + + public boolean matches(IInventory inv) { + List inputsMissing = new ArrayList(inputs); + + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack == null) + break; + + if(stack.getItem() instanceof IBrewContainer) + continue; + + int stackIndex = -1, oredictIndex = -1; + + for(int j = 0; j < inputsMissing.size(); j++) { + Object input = inputsMissing.get(j); + if(input instanceof String) { + List validStacks = OreDictionary.getOres((String) input); + boolean found = false; + for(ItemStack ostack : validStacks) { + ItemStack cstack = ostack.copy(); + if(cstack.getItemDamage() == Short.MAX_VALUE) + cstack.setItemDamage(stack.getItemDamage()); + + if(stack.isItemEqual(cstack)) { + oredictIndex = j; + found = true; + break; + } + } + + + if(found) + break; + } else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) { + stackIndex = j; + break; + } + } + + if(stackIndex != -1) + inputsMissing.remove(stackIndex); + else if(oredictIndex != -1) + inputsMissing.remove(oredictIndex); + else return false; + } + + return inputsMissing.isEmpty(); + } + + boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) { + return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage(); + } + + public List getInputs() { + return new ArrayList(inputs); + } + + public Brew getBrew() { + return brew; + } + + public int getManaUsage() { + return brew.getManaCost(); + } + + public ItemStack getOutput(ItemStack stack) { + if(stack == null || !(stack.getItem() instanceof IBrewContainer)) + return new ItemStack(Items.glass_bottle); // Fallback... + IBrewContainer container = (IBrewContainer) stack.getItem(); + + return container.getItemForBrew(brew, stack); + } + +} diff --git a/src/api/java/vazkii/botania/api/recipe/RecipeManaInfusion.java b/src/api/java/vazkii/botania/api/recipe/RecipeManaInfusion.java index e87b002..1f88c82 100644 --- a/src/api/java/vazkii/botania/api/recipe/RecipeManaInfusion.java +++ b/src/api/java/vazkii/botania/api/recipe/RecipeManaInfusion.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 30, 2014, 5:57:07 PM (GMT)] */ @@ -31,8 +30,14 @@ public class RecipeManaInfusion { } public boolean matches(ItemStack stack) { - if(input instanceof ItemStack) - return stack.isItemEqual((ItemStack) input); + + if(input instanceof ItemStack) { + ItemStack inputCopy = ((ItemStack) input).copy(); + if(inputCopy.getItemDamage() == Short.MAX_VALUE) + inputCopy.setItemDamage(stack.getItemDamage()); + + return stack.isItemEqual(inputCopy); + } if(input instanceof String) { List validStacks = OreDictionary.getOres((String) input); diff --git a/src/api/java/vazkii/botania/api/recipe/RecipePetals.java b/src/api/java/vazkii/botania/api/recipe/RecipePetals.java index 0dba51a..60e4635 100644 --- a/src/api/java/vazkii/botania/api/recipe/RecipePetals.java +++ b/src/api/java/vazkii/botania/api/recipe/RecipePetals.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 22, 2014, 2:02:44 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/recipe/RecipeRuneAltar.java b/src/api/java/vazkii/botania/api/recipe/RecipeRuneAltar.java index 745c957..f8bb211 100644 --- a/src/api/java/vazkii/botania/api/recipe/RecipeRuneAltar.java +++ b/src/api/java/vazkii/botania/api/recipe/RecipeRuneAltar.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Feb 5, 2014, 1:41:14 PM (GMT)] */ @@ -15,12 +14,10 @@ import net.minecraft.item.ItemStack; public class RecipeRuneAltar extends RecipePetals { - ItemStack output; int mana; public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) { super(output, inputs); - this.output = output; this.mana = mana; } diff --git a/src/api/java/vazkii/botania/api/subtile/ISpecialFlower.java b/src/api/java/vazkii/botania/api/subtile/ISpecialFlower.java index 0ef3149..3bca431 100644 --- a/src/api/java/vazkii/botania/api/subtile/ISpecialFlower.java +++ b/src/api/java/vazkii/botania/api/subtile/ISpecialFlower.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 22, 2014, 7:12:28 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/subtile/ISubTileContainer.java b/src/api/java/vazkii/botania/api/subtile/ISubTileContainer.java index ddfaee7..3a99d6d 100644 --- a/src/api/java/vazkii/botania/api/subtile/ISubTileContainer.java +++ b/src/api/java/vazkii/botania/api/subtile/ISubTileContainer.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Aug 26, 2014, 5:42:16 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/subtile/SubTileEntity.java b/src/api/java/vazkii/botania/api/subtile/SubTileEntity.java index 366614a..23a4a5c 100644 --- a/src/api/java/vazkii/botania/api/subtile/SubTileEntity.java +++ b/src/api/java/vazkii/botania/api/subtile/SubTileEntity.java @@ -3,22 +3,25 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 24, 2014, 3:59:06 PM (GMT)] */ package vazkii.botania.api.subtile; +import java.util.ArrayList; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.IIcon; +import net.minecraft.world.World; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.wand.IWandBindable; @@ -34,18 +37,34 @@ public class SubTileEntity { protected TileEntity supertile; + public int ticksExisted = 0; + /** The Tag items should use to store which sub tile they are. **/ public static final String TAG_TYPE = "type"; + public static final String TAG_TICKS_EXISTED = "ticksExisted"; public void setSupertile(TileEntity tile) { supertile = tile; } public boolean canUpdate() { - return false; + return true; } - public void onUpdate() { } + public void onUpdate() { + ticksExisted++; + } + + public final void writeToPacketNBTInternal(NBTTagCompound cmp) { + cmp.setInteger(TAG_TICKS_EXISTED, ticksExisted); + writeToPacketNBT(cmp); + } + + public final void readFromPacketNBTInternal(NBTTagCompound cmp) { + if(cmp.hasKey(TAG_TICKS_EXISTED)) + ticksExisted = cmp.getInteger(TAG_TICKS_EXISTED); + readFromPacketNBT(cmp); + } /** * Writes some extra data to a network packet. This data is read @@ -85,6 +104,39 @@ public class SubTileEntity { return false; } + /** + * Called when this sub tile is placed in the world (by an entity). + */ + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + // NO-OP + } + + /** + * Called when a player right clicks this sub tile. + */ + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { return false; } + + /** + * Called when this sub tile is added to the world. + */ + public void onBlockAdded(World world, int x, int y, int z) { + //NO-OP + } + + /** + * Called when this sub tile is harvested + */ + public void onBlockHarvested(World world, int x, int y, int z, int side, EntityPlayer player) { + //NO-OP + } + + /** + * Allows additional processing of sub tile drops + */ + public ArrayList getDrops(ArrayList list) { + return list; + } + /** * Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon. */ diff --git a/src/api/java/vazkii/botania/api/subtile/SubTileFunctional.java b/src/api/java/vazkii/botania/api/subtile/SubTileFunctional.java index 7d95afe..c1f0698 100644 --- a/src/api/java/vazkii/botania/api/subtile/SubTileFunctional.java +++ b/src/api/java/vazkii/botania/api/subtile/SubTileFunctional.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 24, 2014, 8:03:44 PM (GMT)] */ @@ -47,11 +46,6 @@ public class SubTileFunctional extends SubTileEntity { ChunkCoordinates cachedPoolCoordinates = null; - @Override - public boolean canUpdate() { - return true; - } - /** * If set to true, redstoneSignal will be updated every tick. */ @@ -205,7 +199,7 @@ public class SubTileFunctional extends SubTileEntity { @Override public void renderHUD(Minecraft mc, ScaledResolution res) { String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); - int color = 0x66000000 | getColor(); + int color = getColor(); BotaniaAPI.internalHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); } diff --git a/src/api/java/vazkii/botania/api/subtile/SubTileGenerating.java b/src/api/java/vazkii/botania/api/subtile/SubTileGenerating.java index edfeabe..913c221 100644 --- a/src/api/java/vazkii/botania/api/subtile/SubTileGenerating.java +++ b/src/api/java/vazkii/botania/api/subtile/SubTileGenerating.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 24, 2014, 8:03:36 PM (GMT)] */ @@ -32,7 +31,6 @@ import vazkii.botania.api.mana.IManaCollector; public class SubTileGenerating extends SubTileEntity { private static final String TAG_MANA = "mana"; - private static final String TAG_TICKS_EXISTED = "ticksExisted"; private static final String TAG_COLLECTOR_X = "collectorX"; private static final String TAG_COLLECTOR_Y = "collectorY"; @@ -40,18 +38,12 @@ public class SubTileGenerating extends SubTileEntity { protected int mana; - int ticksExisted = 0; int sizeLastCheck = -1; protected TileEntity linkedCollector = null; public int knownMana = -1; ChunkCoordinates cachedCollectorCoordinates = null; - @Override - public boolean canUpdate() { - return true; - } - @Override public void onUpdate() { super.onUpdate(); @@ -60,7 +52,7 @@ public class SubTileGenerating extends SubTileEntity { if(canGeneratePassively()) { int delay = getDelayBetweenPassiveGeneration(); - if(delay > 0 && supertile.getWorldObj().getWorldTime() % delay == 0) { + if(delay > 0 && ticksExisted % delay == 0 && !supertile.getWorldObj().isRemote) { if(shouldSyncPassiveGeneration()) sync(); addMana(getValueForPassiveGeneration()); @@ -76,7 +68,6 @@ public class SubTileGenerating extends SubTileEntity { } if(!supertile.getWorldObj().isRemote) { - ++ticksExisted; int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay(); if(isPassiveFlower() && muhBalance > 0 && ticksExisted > muhBalance) { @@ -238,7 +229,7 @@ public class SubTileGenerating extends SubTileEntity { @Override public void renderHUD(Minecraft mc, ScaledResolution res) { String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name"); - int color = 0x66000000 | getColor(); + int color = getColor(); BotaniaAPI.internalHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); } diff --git a/src/api/java/vazkii/botania/api/subtile/signature/BasicSignature.java b/src/api/java/vazkii/botania/api/subtile/signature/BasicSignature.java index 0848030..a179387 100644 --- a/src/api/java/vazkii/botania/api/subtile/signature/BasicSignature.java +++ b/src/api/java/vazkii/botania/api/subtile/signature/BasicSignature.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Oct 17, 2014, 5:34:35 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/subtile/signature/SubTileSignature.java b/src/api/java/vazkii/botania/api/subtile/signature/SubTileSignature.java index dcd280e..c0834da 100644 --- a/src/api/java/vazkii/botania/api/subtile/signature/SubTileSignature.java +++ b/src/api/java/vazkii/botania/api/subtile/signature/SubTileSignature.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Oct 17, 2014, 5:29:26 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/wand/ITileBound.java b/src/api/java/vazkii/botania/api/wand/ITileBound.java index 25a8683..199390b 100644 --- a/src/api/java/vazkii/botania/api/wand/ITileBound.java +++ b/src/api/java/vazkii/botania/api/wand/ITileBound.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Mar 24, 2014, 6:47:53 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/wand/IWandBindable.java b/src/api/java/vazkii/botania/api/wand/IWandBindable.java index d1737a9..0c5786c 100644 --- a/src/api/java/vazkii/botania/api/wand/IWandBindable.java +++ b/src/api/java/vazkii/botania/api/wand/IWandBindable.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Oct 9, 2014, 3:01:58 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/wand/IWandHUD.java b/src/api/java/vazkii/botania/api/wand/IWandHUD.java index 57c7e31..a75e44a 100644 --- a/src/api/java/vazkii/botania/api/wand/IWandHUD.java +++ b/src/api/java/vazkii/botania/api/wand/IWandHUD.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Feb 5, 2014, 1:34:44 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/wand/IWandable.java b/src/api/java/vazkii/botania/api/wand/IWandable.java index 0cdcf1f..52349fa 100644 --- a/src/api/java/vazkii/botania/api/wand/IWandable.java +++ b/src/api/java/vazkii/botania/api/wand/IWandable.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Jan 22, 2014, 5:12:53 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/wand/IWireframeAABBProvider.java b/src/api/java/vazkii/botania/api/wand/IWireframeAABBProvider.java index d20b666..3b6e807 100644 --- a/src/api/java/vazkii/botania/api/wand/IWireframeAABBProvider.java +++ b/src/api/java/vazkii/botania/api/wand/IWireframeAABBProvider.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Apr 19, 2014, 7:23:59 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/wiki/IWikiProvider.java b/src/api/java/vazkii/botania/api/wiki/IWikiProvider.java index 42e6114..285c154 100644 --- a/src/api/java/vazkii/botania/api/wiki/IWikiProvider.java +++ b/src/api/java/vazkii/botania/api/wiki/IWikiProvider.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Sep 2, 2014, 5:57:35 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/wiki/SimpleWikiProvider.java b/src/api/java/vazkii/botania/api/wiki/SimpleWikiProvider.java index 6eb949b..9e0fa81 100644 --- a/src/api/java/vazkii/botania/api/wiki/SimpleWikiProvider.java +++ b/src/api/java/vazkii/botania/api/wiki/SimpleWikiProvider.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Sep 2, 2014, 5:58:39 PM (GMT)] */ diff --git a/src/api/java/vazkii/botania/api/wiki/WikiHooks.java b/src/api/java/vazkii/botania/api/wiki/WikiHooks.java index 40f586e..9ab7c49 100644 --- a/src/api/java/vazkii/botania/api/wiki/WikiHooks.java +++ b/src/api/java/vazkii/botania/api/wiki/WikiHooks.java @@ -3,9 +3,8 @@ * part of the Botania Mod. Get the Source Code in github: * https://github.com/Vazkii/Botania * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php * * File Created @ [Sep 2, 2014, 6:05:03 PM (GMT)] */ @@ -26,7 +25,7 @@ public class WikiHooks { public static IWikiProvider getWikiFor(Block block) { UniqueIdentifier mod = GameRegistry.findUniqueIdentifierFor(block); - return getWikiFor(mod.modId.toLowerCase()); + return getWikiFor(mod == null ? "" : mod.modId.toLowerCase()); } public static IWikiProvider getWikiFor(String mod) {