From 1365ac445a10c5d9459da25f19ad1766334fd14e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 14 Jan 2023 14:24:48 +0700 Subject: [PATCH] Small correction to checked energy extensions --- src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 26871d5a0..81b08130d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/capability/Ext.kt @@ -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)