Skip to content

Commit

Permalink
Fix power calculation resulting in potential infinite EMC void
Browse files Browse the repository at this point in the history
Closes #4
  • Loading branch information
62832 committed May 9, 2024
1 parent 30c470b commit 2295174
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/java/gripe/_90/appliede/me/service/EMCStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,9 @@ private void addKnowledge(AEItemKey what, IKnowledgeProvider provider, Player pl
}

private long getAmountAfterPowerExpenditure(long maxAmount, IEnergySource source) {
var requiredPower = PowerMultiplier.CONFIG.multiply(maxAmount);
var availablePower = source.extractAEPower(requiredPower, Actionable.SIMULATE, PowerMultiplier.CONFIG);
var powerToExpend = Math.min(requiredPower, availablePower);
source.extractAEPower(powerToExpend, Actionable.MODULATE, PowerMultiplier.CONFIG);
return (long) PowerMultiplier.CONFIG.divide(powerToExpend);
var availablePower = source.extractAEPower(maxAmount, Actionable.SIMULATE, PowerMultiplier.CONFIG);
source.extractAEPower(Math.min(maxAmount, availablePower), Actionable.MODULATE, PowerMultiplier.CONFIG);
return (double) maxAmount <= availablePower ? maxAmount : (long) availablePower;
}

public int getHighestTier() {
Expand Down

0 comments on commit 2295174

Please sign in to comment.