Prevent ConcurrentModificationException while searching for fuels in ItemList (#926)

This commit is contained in:
slprime authored and GitHub committed 2026-05-06 19:43:50 +03:00
1 parent ccbf94790a
commit d5f25a4be8
2 files changed
+7 -4

No files matched your search

+3 -1
View File
@@ -251,7 +251,6 @@ public class ItemList {
private void updateOrdering(List<ItemStack> items) {
final Map<ItemStack, Integer> newOrdering = new HashMap<>();
ItemSorter.sort(items);
if (!CollapsibleItems.isEmpty()) {
final HashMap<Integer, Integer> groups = new HashMap<>();
@@ -424,6 +423,9 @@ public class ItemList {
}
}
if (interrupted()) return;
ItemSorter.sort(items);
if (interrupted()) return;
ItemList.items = items;
ItemList.itemMap = itemMap;
@@ -84,12 +84,13 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
efuels.add(Item.getItemFromBlock(Blocks.wooden_door));
efuels.add(Item.getItemFromBlock(Blocks.trapped_chest));
Stopwatch stopwatch = Stopwatch.createStarted();
final Stopwatch stopwatch = Stopwatch.createStarted();
final List<ItemStack> itemsSnapshot = new ArrayList<>(ItemList.items);
if (parallel) {
try {
FurnaceRecipeHandler.afuels = ItemList.forkJoinPool
.submit(
() -> ItemList.items.parallelStream().map(TemplateRecipeHandler::identifyFuel)
() -> itemsSnapshot.parallelStream().map(TemplateRecipeHandler::identifyFuel)
.filter(Objects::nonNull).collect(Collectors.toCollection(ArrayList::new)))
.get();
} catch (InterruptedException | ExecutionException e) {
@@ -97,7 +98,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
e.printStackTrace();
}
} else {
FurnaceRecipeHandler.afuels = ItemList.items.stream().map(TemplateRecipeHandler::identifyFuel)
FurnaceRecipeHandler.afuels = itemsSnapshot.stream().map(TemplateRecipeHandler::identifyFuel)
.filter(Objects::nonNull).collect(Collectors.toCollection(ArrayList::new));
}