Try to move as much as possible energy between energy storages

This commit is contained in:
DBotThePony 2023-04-16 00:09:16 +07:00
parent a65fb6d829
commit b7434d632c
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -351,7 +351,7 @@ fun moveBetweenSlots(source: IItemHandler, sourceSlot: Int, destination: IItemHa
} }
@Suppress("name_shadowing") @Suppress("name_shadowing")
fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE, simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal { fun moveEnergy(source: IEnergyStorage, destination: IEnergyStorage, amount: Decimal = Decimal.LONG_MAX_VALUE.coerceAtLeast(source.energyStoredMattery), simulate: Boolean, ignoreFlowRestrictions: Boolean = false): Decimal {
val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(amount, true) else source.extractEnergy(amount, true) val extracted = if (ignoreFlowRestrictions && source is IMatteryEnergyStorage) source.extractEnergy(amount, true) else source.extractEnergy(amount, true)
if (extracted.isPositive) { if (extracted.isPositive) {