From 03dfef00c43e4e29bcc1a67ea0b2cc6ce82776b6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 29 Mar 2025 20:30:38 +0700 Subject: [PATCH] ??? --- .../otm/block/entity/cable/EnergyCableGraph.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 aa754d4a7..f837fe360 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 @@ -20,6 +20,7 @@ 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 @@ -84,6 +85,9 @@ 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 @@ -590,6 +594,9 @@ class EnergyCableGraph : GraphNodeList() + isIteratingNodes = true + for (pair in itr) { // recursion prevention if (!fromNode.currentlyTransferringTo.add(pair)) @@ -737,6 +751,8 @@ class EnergyCableGraph : GraphNodeList