diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt index f837fe360..3f0b335e6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.block.entity.cable +import it.unimi.dsi.fastutil.ints.IntRBTreeSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet @@ -20,7 +21,6 @@ import ru.dbotthepony.mc.otm.graph.GraphNodeList import ru.dbotthepony.mc.otm.onceServer import java.util.* import java.util.concurrent.atomic.AtomicLong -import kotlin.ConcurrentModificationException import kotlin.collections.ArrayList import kotlin.collections.HashSet import kotlin.collections.LinkedHashSet @@ -85,9 +85,6 @@ class EnergyCableGraph : GraphNodeList { } // do nothing ContainsStatus.DOES_NOT_BELONG -> throw IllegalArgumentException("$node does not belong to $this") ContainsStatus.CONTAINS -> { - if (isIteratingNodes) - throw ConcurrentModificationException("Bug trap: currently iterating energy receivers!") - for (dir in RelativeSide.entries) { val pair = node to dir @@ -594,9 +591,6 @@ class EnergyCableGraph : GraphNodeList() - isIteratingNodes = true - for (pair in itr) { + i++ + // recursion prevention if (!fromNode.currentlyTransferringTo.add(pair)) continue @@ -659,8 +656,12 @@ class EnergyCableGraph : GraphNodeList