Fix overflow when charging ultimate battery
This commit is contained in:
parent
2d8df8d145
commit
b3e0abed70
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);
|
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)
|
if (tStats == null || tStats[2] > aTier || !(tStats[3] == -1 || tStats[3] == -3 || (tStats[3] < 0 && aCharge == Integer.MAX_VALUE)) || aStack.stackSize != 1)
|
||||||
return 0;
|
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);
|
if (!aSimulate) setCharge(aStack, tNewCharge);
|
||||||
return tNewCharge - tChargeBefore;
|
return tNewCharge - tChargeBefore;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue