mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-25 22:44:36 +00:00
Prevent ConcurrentModificationException while searching for fuels in ItemList (#926)
This commit is contained in:
1 parent
ccbf94790a
commit
d5f25a4be8
2 files changed
+7
-4
No files matched your search
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user