Merge pull request #1254 from Antifluxfield/overflow_fix
Fix overflow when charging ultimate battery
This commit is contained in:
commit
c7851042b9
1 changed files with 2 additions and 1 deletions
|
@ -256,7 +256,8 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
|
|||
Long[] tStats = getElectricStats(aStack);
|
||||
if (tStats == null || tStats[2] > aTier || !(tStats[3] == -1 || tStats[3] == -3 || (tStats[3] < 0 && aCharge == Integer.MAX_VALUE)) || aStack.stackSize != 1)
|
||||
return 0;
|
||||
long tChargeBefore = getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge)));
|
||||
long tTransfer = aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge);
|
||||
long tChargeBefore = getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), Long.MAX_VALUE - tTransfer >= tChargeBefore ? tChargeBefore + tTransfer : Long.MAX_VALUE);
|
||||
if (!aSimulate) setCharge(aStack, tNewCharge);
|
||||
return tNewCharge - tChargeBefore;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue