();
+
+ /**
+ * Checks to see if the passed item/block already has aspects associated with it.
+ * @param id
+ * @param meta
+ * @return
+ */
+ public static boolean exists(Item item, int meta) {
+ AspectList tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,meta));
+ if (tmp==null) {
+ tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,OreDictionary.WILDCARD_VALUE));
+ if (meta==OreDictionary.WILDCARD_VALUE && tmp==null) {
+ int index=0;
+ do {
+ tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,index));
+ index++;
+ } while (index<16 && tmp==null);
+ }
+ if (tmp==null) return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Used to assign apsects to the given item/block. Here is an example of the declaration for cobblestone:
+ * ThaumcraftApi.registerObjectTag(new ItemStack(Blocks.cobblestone), (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1));
+ * @param item the item passed. Pass OreDictionary.WILDCARD_VALUE if all damage values of this item/block should have the same aspects
+ * @param aspects A ObjectTags object of the associated aspects
+ */
+ public static void registerObjectTag(ItemStack item, AspectList aspects) {
+ if (aspects==null) aspects=new AspectList();
+ try {
+ objectTags.put(Arrays.asList(item.getItem(),item.getItemDamage()), aspects);
+ } catch (Exception e) {}
+ }
+
+
+ /**
+ * Used to assign apsects to the given item/block. Here is an example of the declaration for cobblestone:
+ * ThaumcraftApi.registerObjectTag(new ItemStack(Blocks.cobblestone), new int[]{0,1}, (new AspectList()).add(Aspect.ENTROPY, 1).add(Aspect.EARTH, 1));
+ * @param item
+ * @param meta A range of meta values if you wish to lump several item meta's together as being the "same" item (i.e. stair orientations)
+ * @param aspects A ObjectTags object of the associated aspects
+ */
+ public static void registerObjectTag(ItemStack item, int[] meta, AspectList aspects) {
+ if (aspects==null) aspects=new AspectList();
+ try {
+ objectTags.put(Arrays.asList(item.getItem(),meta), aspects);
+ } catch (Exception e) {}
+ }
+
+ /**
+ * Used to assign apsects to the given ore dictionary item.
+ * @param oreDict the ore dictionary name
+ * @param aspects A ObjectTags object of the associated aspects
+ */
+ public static void registerObjectTag(String oreDict, AspectList aspects) {
+ if (aspects==null) aspects=new AspectList();
+ ArrayList ores = OreDictionary.getOres(oreDict);
+ if (ores!=null && ores.size()>0) {
+ for (ItemStack ore:ores) {
+ try {
+ objectTags.put(Arrays.asList(ore.getItem(), ore.getItemDamage()), aspects);
+ } catch (Exception e) {}
+ }
+ }
+ }
+
+ /**
+ * Used to assign aspects to the given item/block.
+ * Attempts to automatically generate aspect tags by checking registered recipes.
+ * Here is an example of the declaration for pistons:
+ * ThaumcraftApi.registerComplexObjectTag(new ItemStack(Blocks.cobblestone), (new AspectList()).add(Aspect.MECHANISM, 2).add(Aspect.MOTION, 4));
+ * @param item, pass OreDictionary.WILDCARD_VALUE to meta if all damage values of this item/block should have the same aspects
+ * @param aspects A ObjectTags object of the associated aspects
+ */
+ public static void registerComplexObjectTag(ItemStack item, AspectList aspects ) {
+ if (!exists(item.getItem(),item.getItemDamage())) {
+ AspectList tmp = ThaumcraftApiHelper.generateTags(item.getItem(), item.getItemDamage());
+ if (tmp != null && tmp.size()>0) {
+ for(Aspect tag:tmp.getAspects()) {
+ aspects.add(tag, tmp.getAmount(tag));
+ }
+ }
+ registerObjectTag(item,aspects);
+ } else {
+ AspectList tmp = ThaumcraftApiHelper.getObjectAspects(item);
+ for(Aspect tag:aspects.getAspects()) {
+ tmp.merge(tag, tmp.getAmount(tag));
+ }
+ registerObjectTag(item,tmp);
+ }
+ }
+
+ //WARP ///////////////////////////////////////////////////////////////////////////////////////
+ private static HashMap