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 cd63f30a7..2f2049a2a 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,6 +1,9 @@ package ru.dbotthepony.mc.otm.block.entity.cable +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet import net.minecraft.core.BlockPos import org.apache.logging.log4j.LogManager import ru.dbotthepony.mc.otm.UNIVERSE_TICKS @@ -63,7 +66,7 @@ class EnergyCableGraph : GraphNodeList() + val segments = ObjectLinkedOpenHashSet() private var shortCircuit = false private var lastTickTransfers = 0 private var lastTick = 0 @@ -79,11 +82,7 @@ class EnergyCableGraph : GraphNodeList): Decimal { + fun transfer(amount: Decimal, simulate: Boolean, instantSnapshot: Reference2ObjectOpenHashMap): Decimal { if (!amount.isPositive || shortCircuit) { return Decimal.ZERO } @@ -125,8 +124,8 @@ class EnergyCableGraph : GraphNodeList() - private val paths = HashSet() + private val nodes = ObjectLinkedOpenHashSet() + private val paths = ReferenceOpenHashSet() operator fun contains(node: EnergyCableBlockEntity.Node): Boolean { return node in nodes @@ -183,7 +182,7 @@ class EnergyCableGraph : GraphNodeList): Decimal { + fun throughput(instantSnapshot: Reference2ObjectOpenHashMap): Decimal { if (lastTick != UNIVERSE_TICKS) { transferredLastTick = Decimal.ZERO lastTick = UNIVERSE_TICKS @@ -194,7 +193,7 @@ class EnergyCableGraph : GraphNodeList): Decimal { + fun transfer(amount: Decimal, instantSnapshot: Reference2ObjectOpenHashMap): Decimal { if (lastTick != UNIVERSE_TICKS) { transferredLastTick = Decimal.ZERO lastTick = UNIVERSE_TICKS