From 4ef66dff7ca47e03d94fa4faf4ed7a595a44152c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 18 Jan 2025 16:11:17 +0700 Subject: [PATCH] Don't sort cable paths when simulating transfer --- .../mc/otm/block/entity/cable/EnergyCableGraph.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 22901e472..13e60b2b5 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 @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.objects.ReferenceArraySet import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet import net.minecraft.core.BlockPos import org.apache.logging.log4j.LogManager +import ru.dbotthepony.mc.otm.SERVER_IS_LIVE import ru.dbotthepony.mc.otm.UNIVERSE_TICKS import ru.dbotthepony.mc.otm.capability.receiveEnergy import ru.dbotthepony.mc.otm.core.math.Decimal @@ -76,6 +77,10 @@ class EnergyCableGraph : GraphNodeList): Decimal { + return segments.minOfOrNull { it.throughput(instantSnapshot) } ?: Decimal.ZERO + } + operator fun contains(node: EnergyCableBlockEntity.Node): Boolean { return segments.any { node in it } } @@ -186,7 +191,7 @@ class EnergyCableGraph : GraphNodeList { + private fun getPath(a: EnergyCableBlockEntity.Node, b: EnergyCableBlockEntity.Node, energyToTransfer: Decimal, sort: Boolean): List { if (!a.canTraverse || !b.canTraverse) return listOf() @@ -438,7 +443,9 @@ class EnergyCableGraph : GraphNodeList