Added exceptions to the Recipe handlers. Don't crash, but log to the console what went wrong.
This commit is contained in:
@@ -800,7 +800,9 @@ public class RecipeHandler implements IRecipeHandler
|
||||
|
||||
return net.minecraft.item.crafting.Ingredient.fromStacks( itemStack );
|
||||
}
|
||||
return null;
|
||||
|
||||
AELog.warn( "Looking for ingredient with name '" + partName + "' ended up with a null item!" );
|
||||
return net.minecraft.item.crafting.Ingredient.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,26 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.recipes.helpers;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -35,6 +54,10 @@ public class PartRecipeFactory implements IRecipeFactory
|
||||
|
||||
return new PartShapelessCraftingFactory( new ResourceLocation( AppEng.MOD_ID, "part_shapeless_crafting" ), recipe.getIngredients(), recipe.getRecipeOutput() );
|
||||
}
|
||||
return null;
|
||||
else
|
||||
{
|
||||
throw new JsonSyntaxException( "Applied Energistics 2 was given a custom recipe that it does not know how to handle!\n"
|
||||
+ "Type should either be '" + AppEng.MOD_ID + ":shapeless' or '" + AppEng.MOD_ID + ":shaped', got '"+type+"'!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.recipes.helpers;
|
||||
|
||||
import appeng.api.recipes.ResolverResult;
|
||||
@@ -104,11 +122,16 @@ public class PartShapedCraftingFactory extends ShapedOreRecipe
|
||||
|
||||
Item item = Item.getByNameOrId( AppEng.MOD_ID + ":" + resolverResult.itemName );
|
||||
if(item == null)
|
||||
{
|
||||
AELog.warn( "item was null for " + resolverResult.itemName + " ( " + ingredient + " )!" );
|
||||
throw new JsonSyntaxException ( "Got a null item for " + resolverResult.itemName + " ( " + ingredient + " ). This should never happen!" );
|
||||
}
|
||||
ItemStack itemStack = new ItemStack( item, count, resolverResult.damageValue, resolverResult.compound );
|
||||
|
||||
return new PartShapedCraftingFactory( group.isEmpty() ? null : new ResourceLocation( group ), itemStack, primer );
|
||||
}
|
||||
return null;
|
||||
|
||||
// Should never reach this part unless mangled JSON or bug in AE.
|
||||
throw new JsonSyntaxException ( "Couldn't find the resulting item in AE. This means AE was provided a recipe that it shouldn't be handling.\nWas looking for : '" + ingredient + "'." );
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.recipes.helpers;
|
||||
|
||||
import appeng.api.recipes.ResolverResult;
|
||||
@@ -8,6 +26,7 @@ import appeng.core.AppEng;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
@@ -55,12 +74,17 @@ public class PartShapelessCraftingFactory extends ShapelessOreRecipe
|
||||
Item item = Item.getByNameOrId( AppEng.MOD_ID + ":" + resolverResult.itemName );
|
||||
|
||||
if( item == null )
|
||||
{
|
||||
AELog.warn( "item was null for " + resolverResult.itemName + " ( " + ingredient + " )!" );
|
||||
throw new JsonSyntaxException ( "Got a null item for " + resolverResult.itemName + " ( " + ingredient + " ). This should never happen!" );
|
||||
}
|
||||
|
||||
ItemStack itemStack = new ItemStack( item, count, resolverResult.damageValue, resolverResult.compound );
|
||||
|
||||
return new PartShapelessCraftingFactory(group.isEmpty() ? null : new ResourceLocation(group), ings, itemStack);
|
||||
}
|
||||
return null;
|
||||
|
||||
throw new JsonSyntaxException( "Couldn't find the resulting item in AE. This means AE was provided a recipe that it shouldn't be handling.\n"
|
||||
+ "Was looking for : '" + ingredient + "'." );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user