Ejemplo n.º 1
0
 public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) {
   int[] key = new int[] {Item.getIdFromItem(stack.getItem()), stack.getItemDamage()};
   if (keyCache.containsKey(key)) {
     if (keyCache.get(key) == null) return null;
     if (ThaumcraftApiHelper.isResearchComplete(
         player.getCommandSenderName(), (String) (keyCache.get(key))[0])) return keyCache.get(key);
     else return null;
   }
   for (ResearchCategoryList rcl : ResearchCategories.researchCategories.values()) {
     for (ResearchItem ri : rcl.research.values()) {
       if (ri.getPages() == null) continue;
       for (int a = 0; a < ri.getPages().length; a++) {
         ResearchPage page = ri.getPages()[a];
         if (page.recipeOutput != null && stack != null && page.recipeOutput.isItemEqual(stack)) {
           keyCache.put(key, new Object[] {ri.key, a});
           if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key))
             return new Object[] {ri.key, a};
           else return null;
         }
       }
     }
   }
   keyCache.put(key, null);
   return null;
 }
Ejemplo n.º 2
0
 /**
  * @param stack the item
  * @return the thaumcraft recipe key that produces that item. Used by the thaumonomicon drilldown
  *     feature.
  */
 public static String getCraftingRecipeKey(ItemStack stack) {
   for (Object r : getCraftingRecipes()) {
     if (r instanceof IArcaneRecipe) {
       if (ThaumcraftApiHelper.areItemsEqual(stack, ((IArcaneRecipe) r).getRecipeOutput()))
         return ((IArcaneRecipe) r).getKey();
     }
     if (r instanceof IInfusionRecipe) {
       if (ThaumcraftApiHelper.areItemsEqual(stack, ((IInfusionRecipe) r).getRecipeOutput()))
         return ((IInfusionRecipe) r).getKey();
     }
   }
   return "";
 }
Ejemplo n.º 3
0
 /**
  * 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:
  *
  * <p><i>ThaumcraftApi.registerComplexObjectTag(new ItemStack(Blocks.cobblestone), (new
  * AspectList()).add(Aspect.MECHANISM, 2).add(Aspect.MOTION, 4));</i>
  *
  * @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);
   }
 }
Ejemplo n.º 4
0
 /**
  * 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:
  *
  * <p><i>ThaumcraftApi.registerComplexObjectTag(Block.pistonBase.blockID, 0, (new
  * ObjectTags()).add(EnumTag.MECHANISM, 2).add(EnumTag.MOTION, 4));</i>
  *
  * @param id
  * @param meta pass -1 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(int id, int meta, ObjectTags aspects) {
   if (!exists(id, meta)) {
     ObjectTags tmp = ThaumcraftApiHelper.generateTags(id, meta);
     if (tmp != null && tmp.size() > 0) {
       for (EnumTag tag : tmp.getAspects()) {
         aspects.add(tag, tmp.getAmount(tag));
       }
     }
     registerObjectTag(id, meta, aspects);
   } else {
     ObjectTags tmp = ThaumcraftApiHelper.getObjectTags(new ItemStack(id, 1, meta));
     for (EnumTag tag : aspects.getAspects()) {
       tmp.merge(tag, tmp.getAmount(tag));
     }
     registerObjectTag(id, meta, tmp);
   }
 }
Ejemplo n.º 5
0
 /**
  * Used to assign apsects to the given item/block. Here is an example of the declaration for
  * cobblestone:
  *
  * <p><i>ThaumcraftApi.registerObjectTag(Block.cobblestone.blockID, -1, (new
  * ObjectTags()).add(EnumTag.ROCK, 1).add(EnumTag.DESTRUCTION, 1));</i>
  *
  * @param id
  * @param meta pass -1 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(int id, int meta, ObjectTags aspects) {
   aspects = ThaumcraftApiHelper.cullTags(aspects);
   objectTags.put(Arrays.asList(id, meta), aspects);
 }