Small correction to checked energy extensions
This commit is contained in:
parent
b9cb5db9ac
commit
1365ac445a
@ -38,6 +38,9 @@ internal fun IEnergyStorage.receiveEnergy(amount: Decimal, simulate: Boolean): D
|
||||
return receiveEnergyChecked(amount, simulate)
|
||||
|
||||
if (!amount.isPositive)
|
||||
throw IllegalArgumentException("Negative energy: $amount")
|
||||
|
||||
if (!canReceive())
|
||||
return Decimal.ZERO
|
||||
|
||||
if (amount > Decimal.INT_MAX_VALUE)
|
||||
@ -54,6 +57,9 @@ internal fun IEnergyStorage.extractEnergy(amount: Decimal, simulate: Boolean): D
|
||||
return extractEnergyChecked(amount, simulate)
|
||||
|
||||
if (!amount.isPositive)
|
||||
throw IllegalArgumentException("Negative energy: $amount")
|
||||
|
||||
if (!canExtract())
|
||||
return Decimal.ZERO
|
||||
|
||||
if (amount > Decimal.INT_MAX_VALUE)
|
||||
|
Loading…
Reference in New Issue
Block a user