From b7434d632c40480c513a8a24d170f7fb4502e269 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 16 Apr 2023 00:09:16 +0700 Subject: [PATCH] Try to move as much as possible energy between energy storages --- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt index 1f2950ed1..124338e45 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -351,7 +351,7 @@ fun moveBetweenSlots(source: IItemHandler, sourceSlot: Int, destination: IItemHa } @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) if (extracted.isPositive) {