Small re-factor to the RecipeRemover

This commit is contained in:
modmuss50 2015-07-27 19:40:00 +01:00
parent b9d880abe2
commit 9c94b045b3
2 changed files with 19 additions and 23 deletions

View file

@ -17,13 +17,11 @@ public class RecipeRemover {
public static void removeAnyRecipe(ItemStack resultItem) public static void removeAnyRecipe(ItemStack resultItem)
{ {
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); i++) for(IRecipe tmpRecipe : recipes){
{
IRecipe tmpRecipe = recipes.get(i);
ItemStack recipeResult = tmpRecipe.getRecipeOutput(); ItemStack recipeResult = tmpRecipe.getRecipeOutput();
if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
{ {
recipes.remove(i--); recipes.remove(tmpRecipe);
} }
} }
} }
@ -31,9 +29,7 @@ public class RecipeRemover {
public static void removeShapedRecipe(ItemStack resultItem) public static void removeShapedRecipe(ItemStack resultItem)
{ {
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); i++) for (IRecipe tmpRecipe : recipes){
{
IRecipe tmpRecipe = recipes.get(i);
if (tmpRecipe instanceof ShapedRecipes) if (tmpRecipe instanceof ShapedRecipes)
{ {
ShapedRecipes recipe = (ShapedRecipes) tmpRecipe; ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
@ -41,7 +37,7 @@ public class RecipeRemover {
if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
{ {
recipes.remove(i++); recipes.remove(tmpRecipe);
} }
} }
} }