Updating Botania API

This commit is contained in:
Jeremy Diamond committed 2015-03-15 20:48:04 -07:00
1 parent fc925b637e
commit ba2c9e589f
84 files changed
+1580 -209

No files matched your search

@@ -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<String, KnowledgeType> knowledgeTypes = new HashMap<String, KnowledgeType>();
public static Map<String, Brew> brewMap = new LinkedHashMap<String, Brew>();
public static List<RecipePetals> petalRecipes = new ArrayList<RecipePetals>();
public static List<RecipeRuneAltar> runeAltarRecipes = new ArrayList<RecipeRuneAltar>();
public static List<RecipeManaInfusion> manaInfusionRecipes = new ArrayList<RecipeManaInfusion>();
public static List<RecipeElvenTrade> elvenTradeRecipes = new ArrayList<RecipeElvenTrade>();
public static List<RecipeBrew> brewRecipes = new ArrayList<RecipeBrew>();
private static BiMap<String, Class<? extends SubTileEntity>> subTiles = HashBiMap.<String, Class<? extends SubTileEntity>> create();
private static Map<Class<? extends SubTileEntity>, SubTileSignature> subTileSignatures = new HashMap<Class<? extends SubTileEntity>, 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.
*/
@@ -0,0 +1,61 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);<br><br>
* 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();
}
@@ -0,0 +1,42 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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:
* <li><b><i>int</i> time</b> - The amount of total ticks elapsed.</li>
* <li><b><i>int</i> startX</b> - The U coordinate passed in for the render of this bar's texture.</li>
* <li><b><i>int</i> startY</b> - The V coordinate passed in for the render of this bar's texture.</li>
*/
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);
}
@@ -0,0 +1,113 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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<PotionEffect> 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<PotionEffect> getPotionEffects(ItemStack stack) {
return effects;
}
}
@@ -0,0 +1,35 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -0,0 +1,24 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -0,0 +1,291 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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<IInventory> empty = Collections.unmodifiableList(new ArrayList());
private static final WeakHashMap<List<ICorporeaSpark>, List<IInventory>> 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<IInventory> getInventoriesOnNetwork(ICorporeaSpark spark) {
ICorporeaSpark master = spark.getMaster();
if(master == null)
return empty;
List<ICorporeaSpark> network = master.getConnections();
if(cachedNetworks.containsKey(network)) {
List<IInventory> cache = cachedNetworks.get(network);
if(cache != null)
return cache;
}
List<IInventory> 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<IInventory> 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<IInventory> inventories, boolean checkNBT) {
Map<IInventory, Integer> 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<IInventory, Integer> 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<IInventory, Integer> getInventoriesWithItemInNetwork(ItemStack stack, ICorporeaSpark spark, boolean checkNBT) {
List<IInventory> 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<IInventory, Integer> getInventoriesWithItemInNetwork(ItemStack stack, List<IInventory> inventories, boolean checkNBT) {
Map<IInventory, Integer> 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<ItemStack> 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<ItemStack> 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.
* <br><br>
* 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<ItemStack> requestItem(Object matcher, int itemCount, ICorporeaSpark spark, boolean checkNBT, boolean doit) {
List<IInventory> inventories = getInventoriesOnNetwork(spark);
List<ItemStack> 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<ICorporeaSpark> 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);
}
}
@@ -0,0 +1,87 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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.
* <br><br>
* 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<ICorporeaSpark> 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<ICorporeaSpark> 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<ICorporeaSpark> 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<ItemStack> 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();
}
@@ -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)]
*/
@@ -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;
}
}
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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<IRecipe> 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);
}
@@ -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();
}
@@ -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)]
*/
@@ -0,0 +1,20 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -0,0 +1,25 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -0,0 +1,77 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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;
}
}
@@ -0,0 +1,20 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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 {
}
@@ -0,0 +1,33 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -0,0 +1,20 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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 {
}
@@ -0,0 +1,24 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -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)]
*/
@@ -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)]
*/
@@ -0,0 +1,21 @@
/**
* This class was created by <SpitefulFox>. 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);
}
@@ -0,0 +1,24 @@
/**
* This class was created by <TheLoneDevil>. 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);
}
@@ -0,0 +1,23 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -0,0 +1,29 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -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)]
*/
@@ -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)]
*/
@@ -0,0 +1,47 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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).
* <br><br>
* For example, a <b>Manasteel Pickaxe</b> is tool-level 10 and it doesn't have
* modifiers. Assuming Efficiency 4, the priority should be 10 * 100 + 4 = <b>1004</b>.
* This will rate higher than a similar pickaxe with Efficiency 3.<br>
* A <b>Terra Shatterer</b> 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 = <b>2025</b>.
* <br><br>
* 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 <b>Vitreous Pickaxe</b> 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
}
}
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -0,0 +1,23 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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();
}
@@ -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<LexiconCategory> {
private static int count = 0;
public final String unlocalizedName;
public final List<LexiconEntry> entries = new ArrayList<LexiconEntry>();
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 <b>not</b> 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;
}
}
@@ -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<LexiconEntry> {
public List<LexiconPage> pages = new ArrayList<LexiconPage>();
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<LexiconEntry> {
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;
}
@@ -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)]
*/
@@ -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));
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -0,0 +1,30 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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);
}
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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;
}
}
@@ -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)]
*/
@@ -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:
@@ -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)]
*/
@@ -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)]
*/
@@ -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;
@@ -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)]
*/
@@ -0,0 +1,114 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [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<Object> inputs;
public RecipeBrew(Brew brew, Object... inputs) {
this.brew = brew;
List<Object> 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<Object> 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<ItemStack> 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<Object> 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);
}
}
@@ -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<ItemStack> validStacks = OreDictionary.getOres((String) input);
@@ -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)]
*/
@@ -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;
}
@@ -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)]
*/
@@ -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)]
*/
@@ -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<ItemStack> getDrops(ArrayList<ItemStack> list) {
return list;
}
/**
* Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon.
*/
@@ -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);
}
@@ -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);
}
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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)]
*/
@@ -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) {