mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-08 12:34:46 +00:00
Fix ConcurrentModificationException when iterating the crafting recipe list (#1103)
This commit is contained in:
1 parent
afc8a2380b
commit
c1a525594c
2 files changed
+12
-9
No files matched your search
@@ -43,6 +43,10 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler {
|
||||
}
|
||||
}
|
||||
|
||||
protected static List<IRecipe> getCraftingRecipesSnapshot() {
|
||||
return new ArrayList<>(CraftingManager.getInstance().getRecipeList());
|
||||
}
|
||||
|
||||
public class CachedShapedRecipe extends CachedRecipe {
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
@@ -102,7 +106,7 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler {
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
|
||||
for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
|
||||
for (IRecipe irecipe : getCraftingRecipesSnapshot()) {
|
||||
CachedShapedRecipe recipe = null;
|
||||
|
||||
if (irecipe instanceof ShapedRecipes shaped) {
|
||||
@@ -117,7 +121,7 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler {
|
||||
}
|
||||
}
|
||||
} else if (outputId.equals("crafting2x2") && getClass() == ShapedRecipeHandler.class) {
|
||||
for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
|
||||
for (IRecipe irecipe : getCraftingRecipesSnapshot()) {
|
||||
|
||||
if (irecipe instanceof ShapedRecipes shaped && shaped.recipeWidth <= 2 && shaped.recipeHeight <= 2) {
|
||||
CachedShapedRecipe recipe = new CachedShapedRecipe(shaped);
|
||||
@@ -133,7 +137,7 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
|
||||
for (IRecipe irecipe : getCraftingRecipesSnapshot()) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
|
||||
CachedShapedRecipe recipe = null;
|
||||
if (irecipe instanceof ShapedRecipes) recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
|
||||
@@ -149,7 +153,7 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
|
||||
for (IRecipe irecipe : getCraftingRecipesSnapshot()) {
|
||||
CachedShapedRecipe recipe = null;
|
||||
if (irecipe instanceof ShapedRecipes) recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapedOreRecipe) recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
@@ -83,7 +82,7 @@ public class ShapelessRecipeHandler extends ShapedRecipeHandler {
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("crafting") && getClass() == ShapelessRecipeHandler.class) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
List<IRecipe> allrecipes = getCraftingRecipesSnapshot();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
CachedShapelessRecipe recipe = null;
|
||||
|
||||
@@ -98,7 +97,7 @@ public class ShapelessRecipeHandler extends ShapedRecipeHandler {
|
||||
}
|
||||
}
|
||||
} else if (outputId.equals("crafting2x2") && getClass() == ShapelessRecipeHandler.class) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
List<IRecipe> allrecipes = getCraftingRecipesSnapshot();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
CachedShapelessRecipe recipe = null;
|
||||
|
||||
@@ -119,7 +118,7 @@ public class ShapelessRecipeHandler extends ShapedRecipeHandler {
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
List<IRecipe> allrecipes = getCraftingRecipesSnapshot();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
|
||||
CachedShapelessRecipe recipe = null;
|
||||
@@ -136,7 +135,7 @@ public class ShapelessRecipeHandler extends ShapedRecipeHandler {
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
List<IRecipe> allrecipes = getCraftingRecipesSnapshot();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
CachedShapelessRecipe recipe = null;
|
||||
if (irecipe instanceof ShapelessRecipes) recipe = shapelessRecipe((ShapelessRecipes) irecipe);
|
||||
|
||||
Reference in new issue
Block a user