Ejemplo n.º 1
0
 static {
   if (Loader.isModLoaded("Mekanism")) {
     try {
       recipeClass =
           (Class<? super IRecipe>) Class.forName("mekanism.common.recipe.MekanismRecipe");
       checkItemEquals =
           recipeClass.getDeclaredMethod("checkItemEquals", ItemStack.class, ItemStack.class);
       checkItemEquals.setAccessible(true);
       inputField = recipeClass.getDeclaredField("input");
       inputField.setAccessible(true);
     } catch (Exception e) {
       Ref.LOGGER.warn("[Mekanism Recipe Scan] MekanismRecipe.class could not be obtained!", e);
     }
   } else {
     Ref.LOGGER.info("[Mekanism Recipe Scan] Disabled.");
   }
 }
Ejemplo n.º 2
0
 @Override
 public boolean matchItem(ItemStack target, ItemStack candidate, WrappedRecipe recipe) {
   boolean b;
   try {
     b = (Boolean) checkItemEquals.invoke(recipe.recipe, target, candidate);
   } catch (Exception e) {
     Ref.LOGGER.warn("[Mekanism Recipe Handler] failed to match item!", e);
     return false;
   }
   return b;
 }
Ejemplo n.º 3
0
 @Override
 public List<Object> getInputs(IRecipe recipe) {
   List<Object> ingredients = null;
   if (recipeClass != null
       && recipeClass.isInstance(recipe)
       && inputField != null
       && checkItemEquals != null) {
     try {
       Object[] input = (Object[]) inputField.get(recipe);
       ingredients = new ArrayList<Object>(Arrays.asList(input));
     } catch (Exception e) {
       Ref.LOGGER.warn("[Mekanism Recipe Scan] " + recipe.getClass().getName() + " failed!", e);
       return null;
     }
   }
   return ingredients;
 }