Skip to content

Commit

Permalink
Fix #19: Transmuting items to/from EMC does not limit the amount of i…
Browse files Browse the repository at this point in the history
…tems based on stored energy
  • Loading branch information
62832 committed Nov 11, 2024
1 parent 7e66713 commit 0c3158d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/main/java/gripe/_90/appliede/me/service/EMCStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0c3158d

Please sign in to comment.