Ejemplo n.º 1
0
 @Override
 @SuppressWarnings("unchecked")
 public void loadCraftingRecipes(String outputId, Object... results) {
   if (outputId.equals("freezing")
       && getClass() == FreezerRecipeHandler.class) // don't want subclasses getting a hold of this
   {
     HashMap<List<Object>, ItemStack> recipes = null;
     try {
       try {
         recipes =
             ReflectionManager.getField(
                 RecipeRegistry.class, HashMap.class, RecipeRegistry.registry(), 1);
       } catch (ArrayIndexOutOfBoundsException e) {
       }
     } catch (Exception e) {
       e.printStackTrace();
       return;
     }
     if (recipes == null) return;
     for (Entry<List<Object>, ItemStack> recipe : recipes.entrySet()) {
       ItemStack item = recipe.getValue();
       arecipes.add(
           new FreezingPair(
               new ItemStack((Item) recipe.getKey().get(0), 1, (Integer) recipe.getKey().get(1)),
               item,
               new ItemStack((Item) recipe.getKey().get(0), 1, (Integer) recipe.getKey().get(1))
                   .getItem()
                   .getContainerItem(
                       new ItemStack(
                           (Item) recipe.getKey().get(0), 1, (Integer) recipe.getKey().get(1)))));
     }
   } else {
     super.loadCraftingRecipes(outputId, results);
   }
 }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 @Override
 public void loadCraftingRecipes(ItemStack result) {
   HashMap<List<Object>, ItemStack> recipes = null;
   try {
     try {
       recipes =
           ReflectionManager.getField(
               RecipeRegistry.class, HashMap.class, RecipeRegistry.registry(), 1);
     } catch (ArrayIndexOutOfBoundsException e) {
     }
   } catch (Exception e) {
     e.printStackTrace();
     return;
   }
   if (recipes == null) return;
   for (Entry<List<Object>, ItemStack> recipe : recipes.entrySet()) {
     ItemStack item = recipe.getValue();
     if (NEIClientUtils.areStacksSameType(item, result)) {
       arecipes.add(
           new FreezingPair(
               new ItemStack((Item) recipe.getKey().get(0), 1, (Integer) recipe.getKey().get(1)),
               item,
               new ItemStack((Item) recipe.getKey().get(0), 1, (Integer) recipe.getKey().get(1))
                   .getItem()
                   .getContainerItem(
                       new ItemStack(
                           (Item) recipe.getKey().get(0), 1, (Integer) recipe.getKey().get(1)))));
     }
   }
 }
Ejemplo n.º 3
0
 @SuppressWarnings("unchecked")
 @Override
 public void loadUsageRecipes(ItemStack ingredient) {
   HashMap<List<Object>, ItemStack> recipes = null;
   try {
     try {
       recipes =
           ReflectionManager.getField(
               RecipeRegistry.class, HashMap.class, RecipeRegistry.registry(), 1);
     } catch (ArrayIndexOutOfBoundsException e) {
     }
   } catch (Exception e) {
     e.printStackTrace();
     return;
   }
   if (recipes == null) return;
   for (Entry<List<Object>, ItemStack> recipe : recipes.entrySet()) {
     ItemStack item = recipe.getValue();
     if (ingredient.getItem() == (Item) recipe.getKey().get(0)
         && ingredient.getItemDamage() == (Integer) recipe.getKey().get(1)) {
       arecipes.add(
           new FreezingPair(ingredient, item, ingredient.getItem().getContainerItem(ingredient)));
     }
   }
 }