Demote crash to warning on bad Shaped/Shapless recipes and add a more informative error message.

This commit is contained in:
Chicken-Bones committed 2015-02-26 09:32:43 +10:00
1 parent 277c8b5cc0
commit 922ec6b1cb
4 files changed
+18 -15

No files matched your search

+1 -1
View File
@@ -341,7 +341,7 @@ public class NEIServerUtils
if (obj instanceof List)
return ((List<ItemStack>) obj).toArray(new ItemStack[0]);
throw new ClassCastException("not an ItemStack, ItemStack[] or List<ItemStack?");
throw new ClassCastException(obj+" not an ItemStack, ItemStack[] or List<ItemStack?");
}
public static List<Integer> getRange(final int start, final int end) {
-1
View File
@@ -2,7 +2,6 @@ package codechicken.nei.api;
import codechicken.core.featurehack.GameDataManipulator;
import codechicken.nei.*;
import codechicken.nei.ItemList.EverythingItemFilter;
import codechicken.nei.ItemList.ItemsLoadedCallback;
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
import codechicken.nei.config.ArrayDumper;
@@ -148,22 +148,20 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler
}
public CachedShapedRecipe forgeShapedRecipe(ShapedOreRecipe recipe) {
int width;
int height;
try {
width = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 4);
height = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 5);
int width = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 4);
int height = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 5);
Object[] items = recipe.getInput();
for (Object item : items)
if (item instanceof List && ((List<?>) item).isEmpty())//ore handler, no ores
return null;
return new CachedShapedRecipe(width, height, items, recipe.getRecipeOutput());
} catch (Exception e) {
NEIClientConfig.logger.error("Error loading recipe", e);
NEIClientConfig.logger.error("Error loading recipe: ", e);
return null;
}
Object[] items = recipe.getInput();
for (Object item : items)
if (item instanceof List && ((List<?>) item).isEmpty())//ore handler, no ores
return null;
return new CachedShapedRecipe(width, height, items, recipe.getRecipeOutput());
}
@Override
@@ -1,5 +1,6 @@
package codechicken.nei.recipe;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
@@ -151,7 +152,12 @@ public class ShapelessRecipeHandler extends ShapedRecipeHandler
if (item instanceof List && ((List<?>) item).isEmpty())//ore handler, no ores
return null;
return new CachedShapelessRecipe(items, recipe.getRecipeOutput());
try {
return new CachedShapelessRecipe(items, recipe.getRecipeOutput());
} catch (Exception e) {
NEIClientConfig.logger.error("Error loading recipe: ", e);
return null;
}
}
@Override