Don't oversearch paths when target block won't accept all energy sent
This commit is contained in:
parent
8544368ab2
commit
fdc9944c17
@ -477,7 +477,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
|
|||||||
private var searchedOnTick = 0
|
private var searchedOnTick = 0
|
||||||
|
|
||||||
private fun getPath(a: EnergyCableBlockEntity.Node, b: EnergyCableBlockEntity.Node, energyToTransfer: Decimal, sort: Boolean): List<SegmentPath> {
|
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()
|
return listOf()
|
||||||
|
|
||||||
if (searchedOnTick != UNIVERSE_TICKS) {
|
if (searchedOnTick != UNIVERSE_TICKS) {
|
||||||
@ -558,7 +558,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
|
|||||||
val it = side.neighbour.get() ?: continue
|
val it = side.neighbour.get() ?: continue
|
||||||
if (it is EnergyCableBlockEntity.CableSide) 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
|
hit = true
|
||||||
|
|
||||||
if (paths.size == 1) {
|
if (paths.size == 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user