From 5ee05f3a6b4c87de4f723b1765e6dcf7a7eac6c8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 31 Jan 2023 00:26:05 +0700 Subject: [PATCH] Return zero instead of throwing exception --- .../mc/otm/capability/energy/IMatteryEnergyStorage.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt index 9f3853a0c..799f0a8ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/energy/IMatteryEnergyStorage.kt @@ -52,9 +52,7 @@ interface IMatteryEnergyStorage : IEnergyStorage { * @return energy extracted */ fun extractEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { - require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" } - - if (!energyFlow.output) + if (howMuch.isNegative || !energyFlow.output) return Decimal.ZERO return extractEnergy(howMuch, simulate) @@ -86,9 +84,7 @@ interface IMatteryEnergyStorage : IEnergyStorage { * @return energy extracted */ fun receiveEnergyChecked(howMuch: Decimal, simulate: Boolean): Decimal { - require(!howMuch.isNegative) { "Negative amount of energy: $howMuch" } - - if (!energyFlow.input) + if (howMuch.isNegative || !energyFlow.input) return Decimal.ZERO return receiveEnergy(howMuch, simulate)