add nullchecks to assembly tables

This commit is contained in:
asiekierka 2014-12-31 18:05:19 +01:00
parent 4ef1b06aaf
commit e1bb073228
3 changed files with 13 additions and 0 deletions

View file

@ -8,6 +8,7 @@
*/
package buildcraft.builders;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.TreeSet;

View file

@ -41,6 +41,10 @@ public class AssemblyRecipeManager implements IAssemblyRecipeManager {
}
private void addRecipe(String id, IFlexibleRecipe<ItemStack> recipe) {
if (recipe == null) {
throw new RuntimeException("Recipe \"" + id + "\" is null!");
}
if (assemblyRecipes.containsKey(id)) {
throw new RuntimeException("Recipe \"" + id + "\" already registered");
}

View file

@ -267,6 +267,10 @@ public class TileAssemblyTable extends TileLaserTableBase implements IInventory,
for (String recipeId : plannedOutput) {
IFlexibleRecipe<ItemStack> recipe = AssemblyRecipeManager.INSTANCE.getRecipe(recipeId);
if (recipe == null) {
continue;
}
if (recipe == currentRecipe) {
takeNext = true;
} else if (takeNext && recipe.canBeCrafted(this)) {
@ -278,6 +282,10 @@ public class TileAssemblyTable extends TileLaserTableBase implements IInventory,
for (String recipeId : plannedOutput) {
IFlexibleRecipe<ItemStack> recipe = AssemblyRecipeManager.INSTANCE.getRecipe(recipeId);
if (recipe == null) {
continue;
}
if (recipe.canBeCrafted(this)) {
setCurrentRecipe(recipe);
return;