diff --git a/src/main/java/gripe/_90/appliede/me/service/EMCStorage.java b/src/main/java/gripe/_90/appliede/me/service/EMCStorage.java index a9554be..00785f2 100644 --- a/src/main/java/gripe/_90/appliede/me/service/EMCStorage.java +++ b/src/main/java/gripe/_90/appliede/me/service/EMCStorage.java @@ -328,16 +328,18 @@ private long getAmountAfterPowerExpenditure(BigInteger maxEmc, BigInteger itemEm var available = energyService.extractAEPower(toExpend.doubleValue(), Actionable.SIMULATE, PowerMultiplier.ONE); var expended = Math.min(available, toExpend.doubleValue()); - energyService.extractAEPower(expended, Actionable.MODULATE, PowerMultiplier.ONE); - - return expended == available - ? maxEmc.divide(itemEmc).longValue() - : BigDecimal.valueOf(available) - .min(toExpend) - .divide(multiplier, RoundingMode.HALF_UP) - .toBigInteger() - .divide(itemEmc) - .longValue(); + var amount = BigDecimal.valueOf(available) + .min(toExpend) + .divide(multiplier, RoundingMode.HALF_UP) + .toBigInteger() + .divide(itemEmc) + .longValue(); + + if (amount > 0) { + energyService.extractAEPower(expended, Actionable.MODULATE, PowerMultiplier.ONE); + } + + return amount; } private void addKnowledge(AEItemKey what, IKnowledgeProvider provider, Player player) {