From d8f6e6d2ae2ea91af55894db738e9690e4574f0c Mon Sep 17 00:00:00 2001 From: Amnet Date: Sun, 6 Oct 2013 22:38:49 +0200 Subject: [PATCH] Updating Thaumcraft API to the newest version. --- .../{IVisRepairable.java => IRepairable.java} | 2 +- apis/thaumcraft/api/IRepairableExtended.java | 17 ++ apis/thaumcraft/api/ItemApi.java | 22 +- apis/thaumcraft/api/MaterialTaint.java | 58 ----- apis/thaumcraft/api/ThaumcraftApi.java | 78 +++++-- apis/thaumcraft/api/ThaumcraftApiHelper.java | 25 ++ apis/thaumcraft/api/TileThaumcraft.java | 63 ----- apis/thaumcraft/api/aspects/Aspect.java | 9 +- apis/thaumcraft/api/aspects/AspectList.java | 14 +- .../api/aspects/IAspectContainer.java | 64 +++++ .../thaumcraft/api/aspects/IAspectSource.java | 54 +---- ...rItem.java => IEssentiaContainerItem.java} | 3 +- ...ecipeCrucible.java => CrucibleRecipe.java} | 13 +- .../api/crafting/InfusionRecipe.java | 108 +++++++++ .../api/crafting/ShapedArcaneRecipe.java | 1 + apis/thaumcraft/api/nodes/INode.java | 49 ++++ apis/thaumcraft/api/nodes/IRevealer.java | 12 + apis/thaumcraft/api/nodes/NodeModifier.java | 6 + apis/thaumcraft/api/nodes/NodeType.java | 6 + apis/thaumcraft/api/nodes/TileNodeBase.java | 218 ------------------ .../thaumcraft/api/research/ResearchPage.java | 38 ++- apis/thaumcraft/api/wands/IWandFocus.java | 12 + apis/thaumcraft/api/wands/ItemFocusBasic.java | 33 ++- .../api/wands/WandTriggerRegistry.java | 4 +- 24 files changed, 469 insertions(+), 440 deletions(-) rename apis/thaumcraft/api/{IVisRepairable.java => IRepairable.java} (81%) mode change 100755 => 100644 create mode 100644 apis/thaumcraft/api/IRepairableExtended.java delete mode 100755 apis/thaumcraft/api/MaterialTaint.java delete mode 100755 apis/thaumcraft/api/TileThaumcraft.java create mode 100644 apis/thaumcraft/api/aspects/IAspectContainer.java rename apis/thaumcraft/api/aspects/{IAspectContainerItem.java => IEssentiaContainerItem.java} (88%) mode change 100755 => 100644 rename apis/thaumcraft/api/crafting/{RecipeCrucible.java => CrucibleRecipe.java} (72%) mode change 100755 => 100644 create mode 100644 apis/thaumcraft/api/crafting/InfusionRecipe.java create mode 100644 apis/thaumcraft/api/nodes/INode.java create mode 100644 apis/thaumcraft/api/nodes/IRevealer.java create mode 100644 apis/thaumcraft/api/nodes/NodeModifier.java create mode 100644 apis/thaumcraft/api/nodes/NodeType.java delete mode 100755 apis/thaumcraft/api/nodes/TileNodeBase.java diff --git a/apis/thaumcraft/api/IVisRepairable.java b/apis/thaumcraft/api/IRepairable.java old mode 100755 new mode 100644 similarity index 81% rename from apis/thaumcraft/api/IVisRepairable.java rename to apis/thaumcraft/api/IRepairable.java index 00e277682..4913b1623 --- a/apis/thaumcraft/api/IVisRepairable.java +++ b/apis/thaumcraft/api/IRepairable.java @@ -7,7 +7,7 @@ package thaumcraft.api; * Items, armor and tools with this interface can receive the Repair enchantment. * Repairs 1 point of durability every 10 seconds (2 for repair II) */ -public interface IVisRepairable { +public interface IRepairable { } diff --git a/apis/thaumcraft/api/IRepairableExtended.java b/apis/thaumcraft/api/IRepairableExtended.java new file mode 100644 index 000000000..ece71dc78 --- /dev/null +++ b/apis/thaumcraft/api/IRepairableExtended.java @@ -0,0 +1,17 @@ +package thaumcraft.api; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + + + +/** + * @author Azanor + * Items, armor and tools with this interface can receive the Repair enchantment. + * Repairs 1 point of durability every 10 seconds (2 for repair II) + */ +public interface IRepairableExtended extends IRepairable { + + public boolean doRepair(ItemStack stack, EntityPlayer player, int enchantlevel); + +} diff --git a/apis/thaumcraft/api/ItemApi.java b/apis/thaumcraft/api/ItemApi.java index 7d68f0d44..09149abfe 100755 --- a/apis/thaumcraft/api/ItemApi.java +++ b/apis/thaumcraft/api/ItemApi.java @@ -19,17 +19,33 @@ public class ItemApi { ItemStack item = null; try { - String itemClass = "thaumcraft.common.Config"; + String itemClass = "thaumcraft.common.config.ConfigItems"; Object obj = Class.forName(itemClass).getField(itemString).get(null); if (obj instanceof Item) { item = new ItemStack((Item) obj,1,meta); - } else if (obj instanceof Block) { + } else if (obj instanceof ItemStack) { + item = (ItemStack) obj; + } + } catch (Exception ex) { + FMLLog.warning("[Thaumcraft] Could not retrieve item identified by: " + itemString); + } + + return item; + } + + public static ItemStack getBlock(String itemString, int meta) { + ItemStack item = null; + + try { + String itemClass = "thaumcraft.common.config.ConfigBlocks"; + Object obj = Class.forName(itemClass).getField(itemString).get(null); + if (obj instanceof Block) { item = new ItemStack((Block) obj,1,meta); } else if (obj instanceof ItemStack) { item = (ItemStack) obj; } } catch (Exception ex) { - FMLLog.warning("[Thaumcraft] Could not retrieve item or block identified by: " + itemString); + FMLLog.warning("[Thaumcraft] Could not retrieve block identified by: " + itemString); } return item; diff --git a/apis/thaumcraft/api/MaterialTaint.java b/apis/thaumcraft/api/MaterialTaint.java deleted file mode 100755 index 4c06696ac..000000000 --- a/apis/thaumcraft/api/MaterialTaint.java +++ /dev/null @@ -1,58 +0,0 @@ -package thaumcraft.api; - -import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; - -public class MaterialTaint extends Material -{ - public MaterialTaint(MapColor par1MapColor) - { - super(par1MapColor); - this.setNoPushMobility(); - this.setRequiresTool(); - } - - @Override - public boolean isSolid() - { - return false; - } - - @Override - public boolean isReplaceable() - { - return false; - } - - /** - * Will prevent grass from growing on dirt underneath and kill any grass below it if it returns true - */ - @Override - public boolean getCanBlockGrass() - { - return false; - } - - /** - * Returns if this material is considered solid or not - */ - @Override - public boolean blocksMovement() - { - return true; - } - - @Override - protected Material setRequiresTool() { - // TODO Auto-generated method stub - return super.setRequiresTool(); - } - - @Override - public int getMaterialMobility() { - // TODO Auto-generated method stub - return super.getMaterialMobility(); - } - - -} diff --git a/apis/thaumcraft/api/ThaumcraftApi.java b/apis/thaumcraft/api/ThaumcraftApi.java index d01bb463b..0d672e13a 100755 --- a/apis/thaumcraft/api/ThaumcraftApi.java +++ b/apis/thaumcraft/api/ThaumcraftApi.java @@ -6,8 +6,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.EnumToolMaterial; @@ -17,7 +15,8 @@ import net.minecraftforge.common.EnumHelper; import net.minecraftforge.oredict.OreDictionary; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; -import thaumcraft.api.crafting.RecipeCrucible; +import thaumcraft.api.crafting.CrucibleRecipe; +import thaumcraft.api.crafting.InfusionRecipe; import thaumcraft.api.crafting.ShapedArcaneRecipe; import thaumcraft.api.crafting.ShapelessArcaneRecipe; import thaumcraft.api.research.IScanEventHandler; @@ -41,8 +40,13 @@ public class ThaumcraftApi { public static EnumToolMaterial toolMatElemental = EnumHelper.addToolMaterial("THAUMIUM_ELEMENTAL", 3, 1500, 10F, 3, 18); public static EnumArmorMaterial armorMatThaumium = EnumHelper.addArmorMaterial("THAUMIUM", 25, new int[] { 2, 6, 5, 2 }, 25); public static EnumArmorMaterial armorMatSpecial = EnumHelper.addArmorMaterial("SPECIAL", 25, new int[] { 1, 3, 2, 1 }, 25); - public static final Material fluxGoomaterial = (new MaterialTaint(MapColor.grassColor)); - public static final Material taintMaterial = (new MaterialTaint(MapColor.grassColor)); + + //Enchantment references + public static int enchantFrugal; + public static int enchantPotency; + public static int enchantWandFortune; + public static int enchantHaste; + public static int enchantRepair; //Miscellaneous /** @@ -164,6 +168,41 @@ public class ThaumcraftApi { craftingRecipes.add(r); return r; } + + /** + * @param research the research key required for this recipe to work. Leave blank if it will work without research + * @param result the recipe output. It can either be an itemstack or an nbt compound tag that will be added to the central item + * @param instability a number that represents the N in 1000 chance for the infusion altar to spawn an + * instability effect each second while the crafting is in progress + * @param aspects the essentia cost per aspect. + * @param aspects input the central item to be infused + * @param recipe An array of items required to craft this. Input itemstacks are NBT sensitive. + * Infusion crafting components are automatically "fuzzy" and the oredict will be checked for possible matches. + * + */ + public static InfusionRecipe addInfusionCraftingRecipe(String research, Object result, int instability, AspectList aspects, ItemStack input,ItemStack[] recipe) + { + if (!(result instanceof ItemStack || result instanceof NBTBase)) return null; + InfusionRecipe r= new InfusionRecipe(research, result, instability, aspects, input, recipe); + craftingRecipes.add(r); + return r; + } + + /** + * @param stack the recipe result + * @return the recipe + */ + public static InfusionRecipe getInfusionRecipe(ItemStack res) { + for (Object r:getCraftingRecipes()) { + if (r instanceof InfusionRecipe) { + if (((InfusionRecipe)r).recipeOutput instanceof ItemStack) { + if (((ItemStack) ((InfusionRecipe)r).recipeOutput).isItemEqual(res)) + return (InfusionRecipe)r; + } + } + } + return null; + } /** @@ -172,8 +211,8 @@ public class ThaumcraftApi { * @param cost the vis cost * @param tags the aspects required to craft this */ - public static RecipeCrucible addCrucibleRecipe(String key, ItemStack result, Object catalyst, AspectList tags) { - RecipeCrucible rc = new RecipeCrucible(key, result, catalyst, tags); + public static CrucibleRecipe addCrucibleRecipe(String key, ItemStack result, Object catalyst, AspectList tags) { + CrucibleRecipe rc = new CrucibleRecipe(key, result, catalyst, tags); getCraftingRecipes().add(rc); return rc; } @@ -183,11 +222,11 @@ public class ThaumcraftApi { * @param stack the recipe result * @return the recipe */ - public static RecipeCrucible getCrucibleRecipe(ItemStack stack) { + public static CrucibleRecipe getCrucibleRecipe(ItemStack stack) { for (Object r:getCraftingRecipes()) { - if (r instanceof RecipeCrucible) { - if (((RecipeCrucible)r).recipeOutput.isItemEqual(stack)) - return (RecipeCrucible)r; + if (r instanceof CrucibleRecipe) { + if (((CrucibleRecipe)r).recipeOutput.isItemEqual(stack)) + return (CrucibleRecipe)r; } } return null; @@ -198,12 +237,13 @@ public class ThaumcraftApi { * @param stack the item * @return the thaumcraft recipe key that produces that item. */ - private static HashMap keyCache = new HashMap(); + private static HashMap keyCache = new HashMap(); public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) { - if (keyCache.containsKey(stack)) { - if (keyCache.get(stack)==null) return null; - if (ThaumcraftApiHelper.isResearchComplete(player.username, (String)(keyCache.get(stack))[0])) - return keyCache.get(stack); + int[] key = new int[] {stack.itemID,stack.getItemDamage()}; + if (keyCache.containsKey(key)) { + if (keyCache.get(key)==null) return null; + if (ThaumcraftApiHelper.isResearchComplete(player.username, (String)(keyCache.get(key))[0])) + return keyCache.get(key); else return null; } @@ -212,8 +252,8 @@ public class ThaumcraftApi { if (ri.getPages()==null) continue; for (int a=0;a aspects = new LinkedHashMap(); @@ -146,7 +147,7 @@ public class Aspect { public static final Aspect ENTROPY = new Aspect("perditio",0x404040,"8",771); //SECONDARY TODO - public static final Aspect VOID = new Aspect("vacuos",0x888888, new Aspect[] {ORDER, ENTROPY},771); + public static final Aspect VOID = new Aspect("vacuos",0x888888, new Aspect[] {AIR, ENTROPY},771); public static final Aspect LIGHT = new Aspect("lux",0xfff663, new Aspect[] {AIR, FIRE}); public static final Aspect ENERGY = new Aspect("potentia",0xc0ffff, new Aspect[] {ORDER, FIRE}); public static final Aspect MOTION = new Aspect("motus",0xcdccf4, new Aspect[] {AIR, ORDER}); @@ -162,7 +163,7 @@ public class Aspect { public static final Aspect FLIGHT = new Aspect("volatus",0xe7e7d7, new Aspect[] {AIR, MOTION}); public static final Aspect DARKNESS = new Aspect("tenebrae",0x222222, new Aspect[] {VOID, LIGHT}); public static final Aspect SOUL = new Aspect("spiritus",0xebebfb, new Aspect[] {LIFE, DEATH}); - public static final Aspect HEAL = new Aspect("sano",0xff2f34, new Aspect[] {ORDER, LIFE}); + public static final Aspect HEAL = new Aspect("sano",0xff2f34, new Aspect[] {LIFE, LIFE}); public static final Aspect TRAVEL = new Aspect("iter",0xe0585b, new Aspect[] {MOTION, EARTH}); public static final Aspect POISON = new Aspect("venenum",0x89f000, new Aspect[] {WATER, DEATH}); @@ -190,7 +191,7 @@ public class Aspect { public static final Aspect MINE = new Aspect("perfodio",0xdcd2d8, new Aspect[] {MAN, STONE}); public static final Aspect TOOL = new Aspect("instrumentum",0x4040ee, new Aspect[] {MAN, METAL}); public static final Aspect WEAPON = new Aspect("telum",0xc05050, new Aspect[] {TOOL, ENTROPY}); - public static final Aspect ARMOR = new Aspect("tutamen",0x00c0c0, new Aspect[] {TOOL, ORDER}); + public static final Aspect ARMOR = new Aspect("tutamen",0x00c0c0, new Aspect[] {TOOL, EARTH}); public static final Aspect HUNGER = new Aspect("fames",0x9a0305, new Aspect[] {LIFE, VOID}); public static final Aspect GREED = new Aspect("lucrum",0xe6be44, new Aspect[] {MAN, HUNGER}); public static final Aspect CRAFT = new Aspect("fabrico",0x809d80, new Aspect[] {MAN,TOOL}); @@ -198,7 +199,7 @@ public class Aspect { public static final Aspect CLOTH = new Aspect("pannus",0xeaeac2, new Aspect[] {TOOL, BEAST}); public static final Aspect MECHANISM = new Aspect("machina",0x8080a0, new Aspect[] {MOTION, TOOL}); public static final Aspect TRAP = new Aspect("vinculum",0x9a8080, new Aspect[] {MOTION, ENTROPY}); - public static final Aspect EXCHANGE = new Aspect("permutatio",0x578357, new Aspect[] {MOTION, ORDER}); + public static final Aspect EXCHANGE = new Aspect("permutatio",0x578357, new Aspect[] {MOTION, WATER}); diff --git a/apis/thaumcraft/api/aspects/AspectList.java b/apis/thaumcraft/api/aspects/AspectList.java index 38a18ccfc..b4c703c57 100755 --- a/apis/thaumcraft/api/aspects/AspectList.java +++ b/apis/thaumcraft/api/aspects/AspectList.java @@ -151,20 +151,15 @@ public class AspectList implements Serializable { /** * Reduces the amount of an aspect in this collection by the given amount. - * If reduced below 0 the aspect will be removed completely. - * If the aspect does not exist then a negative value will be added. + * If reduced to 0 or less the aspect will be removed completely. * @param key * @param amount * @return */ public AspectList remove(Aspect key, int amount) { - if (getAmount(key)>=amount) { - int am = getAmount(key)-amount; - if (am<=0) aspects.remove(key); else - this.aspects.put(key, am); - } else if (getAmount(key)==0) { - this.aspects.put(key, -amount); - } + int am = getAmount(key)-amount; + if (am<=0) aspects.remove(key); else + this.aspects.put(key, am); return this; } @@ -207,6 +202,7 @@ public class AspectList implements Serializable { if (this.aspects.containsKey(aspect)) { int oldamount = this.aspects.get(aspect); if (amount)catalyst).size()>0) { - //if (!OreDictionary.containsMatch(true, ((ArrayList)catalyst).toArray(new ItemStack[]{}), cat)) return false; + if (!ThaumcraftApiHelper.containsMatch(true, ((ArrayList)catalyst).toArray(new ItemStack[]{}), cat)) return false; } if (itags==null) return false; for (Aspect tag:aspects.getAspects()) { diff --git a/apis/thaumcraft/api/crafting/InfusionRecipe.java b/apis/thaumcraft/api/crafting/InfusionRecipe.java new file mode 100644 index 000000000..596b1b799 --- /dev/null +++ b/apis/thaumcraft/api/crafting/InfusionRecipe.java @@ -0,0 +1,108 @@ +package thaumcraft.api.crafting; + +import java.util.ArrayList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; +import thaumcraft.api.ThaumcraftApiHelper; +import thaumcraft.api.aspects.AspectList; + +public class InfusionRecipe +{ + + public AspectList aspects; + public String research; + public ItemStack[] components; + public ItemStack recipeInput; + public Object recipeOutput; + public int instability; + + public InfusionRecipe(String research, Object output, int inst, + AspectList aspects2, ItemStack input, ItemStack[] recipe) { + this.research = research; + this.recipeOutput = output; + this.recipeInput = input; + this.aspects = aspects2; + this.components = recipe; + this.instability = inst; + } + + /** + * Used to check if a recipe matches current crafting inventory + * @param player + */ + public boolean matches(ArrayList input, ItemStack central, World world, EntityPlayer player) { + if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.username, research)) { + return false; + } + + ItemStack i2 = central.copy(); + if (recipeInput.getItemDamage()==OreDictionary.WILDCARD_VALUE) { + i2.setItemDamage(OreDictionary.WILDCARD_VALUE); + } + + if (!areItemStacksEqual(i2, recipeInput, true)) return false; + + ArrayList ii = new ArrayList(); + for (ItemStack is:input) { + ii.add(is.copy()); + } + + for (ItemStack comp:components) { + boolean b=false; + for (int a=0;a stack0.getMaxStackSize() ? false : t1)); + } + + + public Object getRecipeOutput() { + return recipeOutput; + + } + + public AspectList getAspects() { + return aspects; + + } + + public String getResearch() { + return research; + + } + +} diff --git a/apis/thaumcraft/api/crafting/ShapedArcaneRecipe.java b/apis/thaumcraft/api/crafting/ShapedArcaneRecipe.java index 91da6559a..4496365b7 100755 --- a/apis/thaumcraft/api/crafting/ShapedArcaneRecipe.java +++ b/apis/thaumcraft/api/crafting/ShapedArcaneRecipe.java @@ -6,6 +6,7 @@ import java.util.HashMap; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; diff --git a/apis/thaumcraft/api/nodes/INode.java b/apis/thaumcraft/api/nodes/INode.java new file mode 100644 index 000000000..98c717977 --- /dev/null +++ b/apis/thaumcraft/api/nodes/INode.java @@ -0,0 +1,49 @@ +package thaumcraft.api.nodes; + +import thaumcraft.api.aspects.IAspectContainer; + +public interface INode extends IAspectContainer { + + /** + * Unique identifier to distinguish nodes. Normal node id's are based on world id and coordinates + * @return + */ + public String getId(); + + /** + * Return the type of node + * @return + */ + public NodeType getNodeType(); + + /** + * Set the type of node + * @return + */ + public void setNodeType(NodeType nodeType); + + /** + * Return the node modifier + * @return + */ + public void setNodeModifier(NodeModifier nodeModifier); + + /** + * Set the node modifier + * @return + */ + public NodeModifier getNodeModifier(); + + /** + * Return the maximum capacity of each aspect the node can hold + * @return + */ + public int getNodeVisBase(); + + /** + * Set the maximum capacity of each aspect the node can hold + * @return + */ + public void setNodeVisBase(short nodeVisBase); + +} diff --git a/apis/thaumcraft/api/nodes/IRevealer.java b/apis/thaumcraft/api/nodes/IRevealer.java new file mode 100644 index 000000000..a0895bbfa --- /dev/null +++ b/apis/thaumcraft/api/nodes/IRevealer.java @@ -0,0 +1,12 @@ +package thaumcraft.api.nodes; + +/** + * + * @author Azanor + * + * Equipped head slot items that extend this class will make nodes visible in world. + * + */ +public interface IRevealer { + +} diff --git a/apis/thaumcraft/api/nodes/NodeModifier.java b/apis/thaumcraft/api/nodes/NodeModifier.java new file mode 100644 index 000000000..b0e721c72 --- /dev/null +++ b/apis/thaumcraft/api/nodes/NodeModifier.java @@ -0,0 +1,6 @@ +package thaumcraft.api.nodes; + +public enum NodeModifier +{ + BRIGHT, PALE, FADING +} \ No newline at end of file diff --git a/apis/thaumcraft/api/nodes/NodeType.java b/apis/thaumcraft/api/nodes/NodeType.java new file mode 100644 index 000000000..cac8cad01 --- /dev/null +++ b/apis/thaumcraft/api/nodes/NodeType.java @@ -0,0 +1,6 @@ +package thaumcraft.api.nodes; + +public enum NodeType +{ + NORMAL, UNSTABLE, DARK, TAINTED, HUNGRY, PURE +} \ No newline at end of file diff --git a/apis/thaumcraft/api/nodes/TileNodeBase.java b/apis/thaumcraft/api/nodes/TileNodeBase.java deleted file mode 100755 index 6325181df..000000000 --- a/apis/thaumcraft/api/nodes/TileNodeBase.java +++ /dev/null @@ -1,218 +0,0 @@ -package thaumcraft.api.nodes; - -import java.util.ArrayList; -import java.util.HashMap; - -import net.minecraft.nbt.NBTTagCompound; -import thaumcraft.api.TileThaumcraft; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; - -/** - * - * @author azanor - * - * Used as a base for all node tile entities. All the work actually gets done in a non-api TE - * that extends this class. - * - */ -public class TileNodeBase extends TileThaumcraft { - - public static enum NodeType - { - NORMAL, UNSTABLE, DARK, TAINTED, HUNGRY, PURE - } - - public static enum NodeModifier - { - BRIGHT, PALE, FADING - } - - short nodeVisBase = 0; - - AspectList aspects = new AspectList(); - - public static HashMap> locations = new HashMap>(); - - private NodeType nodeType=NodeType.NORMAL; - private NodeModifier nodeModifier=null; - - - - protected String id; - - public String getId() { - if (id==null) { - id = generateIdentifier(); - } - return id; - } - - public String generateIdentifier() { - id = worldObj.provider.dimensionId + ":" + xCoord + ":" + yCoord+ ":" + zCoord; - - if (worldObj!=null && locations!=null) { - ArrayList t = new ArrayList(); - t.add(worldObj.provider.dimensionId); - t.add(xCoord); - t.add(yCoord); - t.add(zCoord); - locations.put(id, t); - } - - return id; - } - - @Override - public void onChunkUnload() { - if (locations!=null) locations.remove(id); - super.onChunkUnload(); - } - - @Override - public void validate() { - super.validate(); - if (id==null) generateIdentifier(); - } - - /** - * Returns all the aspects and their amounts that this node contains - * @return - */ - public AspectList getAspects() { - return aspects; - } - - /** - * Sets the aspects contained within this node - * @return - */ - public void setAspects(AspectList aspects) { - this.aspects = aspects; - short highest=0; - for (Aspect aspect:aspects.getAspects()) { - if (aspects.getAmount(aspect)>highest) - highest=(short) aspects.getAmount(aspect); - } - nodeVisBase = highest; - } - - /** - * This method is used to add a certain amount of an aspect to the node. - * @param tag - * @param amount - * @return the amount of aspect left over that could not be added. - */ - public int addToSource(Aspect aspect, int amount) { - int left = (amount+aspects.getAmount(aspect))-nodeVisBase; - left = left>0?left:0; - aspects.add(aspect, amount-left); - return left; - } - - /** - * Removes a certain amount of a specific aspect from the node - * @param tag - * @param amount - * @return true if that amount of aspect was available and was removed - */ - public boolean takeFromSource(Aspect aspect, int amount) { - return aspects.reduce(aspect, amount); - } - - /** - * Removes a single random aspect from the source - * @return the aspect that was retrieved (it is assumed that only 1 of that aspect has been removed). - * Should return null if there are not enough aspects. - */ - public Aspect takeRandomPrimalFromSource() { - Aspect[] primals = aspects.getPrimalAspects(); - Aspect asp = primals[worldObj.rand.nextInt(primals.length)]; - if (asp !=null && aspects.reduce(asp,1)) { - return asp; - } else { - return null; - } - } - - public Aspect chooseRandomFilteredFromSource(AspectList filter) { - ArrayList validaspects = new ArrayList(); - for (Aspect prim:aspects.getAspects()) { - if (filter.getAmount(prim)>0 && aspects.getAmount(prim)>0) validaspects.add(prim); - } - if (validaspects.size()==0) return null; - Aspect asp = validaspects.get(worldObj.rand.nextInt(validaspects.size())); - if (asp !=null && aspects.getAmount(asp)>0) { - return asp; - } else { - return null; - } - } - - @Override - public void readCustomNBT(NBTTagCompound nbttagcompound) - { - this.id = nbttagcompound.getString("nodeId"); - this.nodeVisBase = nbttagcompound.getShort("nodeVisBase"); - - if (worldObj!=null && locations!=null) { - ArrayList t = new ArrayList(); - t.add(worldObj.provider.dimensionId); - t.add(xCoord); - t.add(yCoord); - t.add(zCoord); - locations.put(id, t); - } - - this.setNodeType(NodeType.values()[nbttagcompound.getByte("type")]); - byte mod = nbttagcompound.getByte("modifier"); - if (mod>=0) - this.setNodeModifier(NodeModifier.values()[mod]); - else - this.setNodeModifier(null); - - aspects.readFromNBT(nbttagcompound); - - } - - @Override - public void writeCustomNBT(NBTTagCompound nbttagcompound) - { - if (id==null) id = generateIdentifier(); - nbttagcompound.setString("nodeId", id); - nbttagcompound.setShort("nodeVisBase", nodeVisBase); - nbttagcompound.setByte("type", (byte) this.getNodeType().ordinal()); - nbttagcompound.setByte("modifier", getNodeModifier()==null?-1:(byte) this.getNodeModifier().ordinal()); - aspects.writeToNBT(nbttagcompound); - - } - - public NodeType getNodeType() { - return nodeType; - } - - public void setNodeType(NodeType nodeType) { - this.nodeType = nodeType; - } - - public void setNodeModifier(NodeModifier nodeModifier) { - this.nodeModifier = nodeModifier; - } - - public NodeModifier getNodeModifier() { - return nodeModifier; - } - - public int getNodeVisBase() { - return nodeVisBase; - } - - public void setNodeVisBase(short nodeVisBase) { - this.nodeVisBase = nodeVisBase; - } - - public void nodeChange() { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - -} diff --git a/apis/thaumcraft/api/research/ResearchPage.java b/apis/thaumcraft/api/research/ResearchPage.java index 3cc00cd65..3aacb0d4c 100755 --- a/apis/thaumcraft/api/research/ResearchPage.java +++ b/apis/thaumcraft/api/research/ResearchPage.java @@ -7,8 +7,9 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.crafting.CrucibleRecipe; import thaumcraft.api.crafting.IArcaneRecipe; -import thaumcraft.api.crafting.RecipeCrucible; +import thaumcraft.api.crafting.InfusionRecipe; public class ResearchPage { public static enum PageType @@ -20,6 +21,7 @@ public class ResearchPage { ARCANE_CRAFTING, ASPECTS, NORMAL_CRAFTING, + INFUSION_CRAFTING, COMPOUND_CRAFTING } @@ -60,12 +62,27 @@ public class ResearchPage { } /** - * @param recipe a vanilla crafting recipe. + * @param recipe a collection of vanilla crafting recipes. */ public ResearchPage(IRecipe[] recipe) { this.type = PageType.NORMAL_CRAFTING; this.recipe = recipe; -// this.recipeOutput = recipe.getRecipeOutput(); + } + + /** + * @param recipe a collection of arcane crafting recipes. + */ + public ResearchPage(IArcaneRecipe[] recipe) { + this.type = PageType.ARCANE_CRAFTING; + this.recipe = recipe; + } + + /** + * @param recipe a collection of infusion crafting recipes. + */ + public ResearchPage(InfusionRecipe[] recipe) { + this.type = PageType.INFUSION_CRAFTING; + this.recipe = recipe; } /** @@ -88,12 +105,25 @@ public class ResearchPage { /** * @param recipe an alchemy crafting recipe. */ - public ResearchPage(RecipeCrucible recipe) { + public ResearchPage(CrucibleRecipe recipe) { this.type = PageType.CRUCIBLE_CRAFTING; this.recipe = recipe; this.recipeOutput = recipe.recipeOutput; } + /** + * @param recipe an infusion crafting recipe. + */ + public ResearchPage(InfusionRecipe recipe) { + this.type = PageType.INFUSION_CRAFTING; + this.recipe = recipe; + if (recipe.recipeOutput instanceof ItemStack) { + this.recipeOutput = (ItemStack) recipe.recipeOutput; + } else { + this.recipeOutput = recipe.recipeInput; + } + } + /** * @param image * @param caption this can (but does not have to) be a reference to a localization variable, not the actual text. diff --git a/apis/thaumcraft/api/wands/IWandFocus.java b/apis/thaumcraft/api/wands/IWandFocus.java index 123338dac..8346df939 100755 --- a/apis/thaumcraft/api/wands/IWandFocus.java +++ b/apis/thaumcraft/api/wands/IWandFocus.java @@ -14,7 +14,15 @@ public interface IWandFocus { WAVE, CHARGE; } + /** + * @return The color the focus should be changed to. + */ public int getFocusColor(); + + /** + * @return An icon that will be drawn as a block inside the focus "block". + */ + Icon getFocusDepthLayerIcon(); public Icon getOrnament(); @@ -47,6 +55,10 @@ public interface IWandFocus { boolean onFocusBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player); + public boolean acceptsEnchant(int id); + + + } diff --git a/apis/thaumcraft/api/wands/ItemFocusBasic.java b/apis/thaumcraft/api/wands/ItemFocusBasic.java index 28e2cf80e..7b2982105 100755 --- a/apis/thaumcraft/api/wands/ItemFocusBasic.java +++ b/apis/thaumcraft/api/wands/ItemFocusBasic.java @@ -2,7 +2,9 @@ package thaumcraft.api.wands; import java.text.DecimalFormat; import java.util.List; +import java.util.Map; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; @@ -11,6 +13,7 @@ import net.minecraft.util.Icon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import cpw.mods.fml.relauncher.Side; @@ -33,6 +36,12 @@ public class ItemFocusBasic extends Item implements IWandFocus { return icon; } + @Override + public boolean isItemTool(ItemStack par1ItemStack) + { + return true; + } + @Override public void addInformation(ItemStack stack,EntityPlayer player, List list, boolean par4) { AspectList al = this.getVisCost(); @@ -96,7 +105,12 @@ public class ItemFocusBasic extends Item implements IWandFocus { */ @Override public String getSortingHelper(ItemStack itemstack) { - return "00"; + Map ench = EnchantmentHelper.getEnchantments(itemstack); + String out=""; + for (Integer lvl:ench.values()) { + out = out + lvl + ""; + } + return out; } @Override @@ -122,6 +136,23 @@ public class ItemFocusBasic extends Item implements IWandFocus { return WandFocusAnimation.WAVE; } + @Override + public Icon getFocusDepthLayerIcon() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see thaumcraft.api.wands.IWandFocus#acceptsEnchant(int) + * By default fortune is off for all wands + */ + @Override + public boolean acceptsEnchant(int id) { + if (id==ThaumcraftApi.enchantFrugal|| + id==ThaumcraftApi.enchantPotency) return true; + return false; + } + diff --git a/apis/thaumcraft/api/wands/WandTriggerRegistry.java b/apis/thaumcraft/api/wands/WandTriggerRegistry.java index e4e52c77d..3a37c5c02 100755 --- a/apis/thaumcraft/api/wands/WandTriggerRegistry.java +++ b/apis/thaumcraft/api/wands/WandTriggerRegistry.java @@ -58,10 +58,10 @@ public class WandTriggerRegistry { */ public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player, int x, int y, int z, int side, int blockid, int meta) { - if (!triggers.containsKey(Arrays.asList(blockid,meta))) return false; - + List l = triggers.get(Arrays.asList(blockid,meta)); if (l==null) l = triggers.get(Arrays.asList(blockid,-1)); + if (l==null) return false; IWandTriggerManager manager = (IWandTriggerManager) l.get(0); int event = (Integer) l.get(1);