Don't oversearch paths when target block won't accept all energy sent

This commit is contained in:
DBotThePony 2025-02-11 10:51:52 +07:00
parent 8544368ab2
commit fdc9944c17
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -477,7 +477,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
private var searchedOnTick = 0
private fun getPath(a: EnergyCableBlockEntity.Node, b: EnergyCableBlockEntity.Node, energyToTransfer: Decimal, sort: Boolean): List<SegmentPath> {
if (!a.canTraverse || !b.canTraverse)
if (!a.canTraverse || !b.canTraverse || energyToTransfer <= Decimal.ZERO)
return listOf()
if (searchedOnTick != UNIVERSE_TICKS) {
@ -558,7 +558,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
val it = side.neighbour.get() ?: continue
if (it is EnergyCableBlockEntity.CableSide) continue
val paths = getPath(fromNode, node, residue, !simulate)
val paths = getPath(fromNode, node, it.receiveEnergy(residue, true), !simulate)
hit = true
if (paths.size == 1) {