Fixed Display overflow

This commit is contained in:
Blood-Asp 2015-12-13 17:35:07 +01:00
parent 8659c9573c
commit 8722e0e2f2

View file

@ -262,8 +262,11 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier
}
public long[] getStoredEnergy() {
boolean scaleOverflow =false;
boolean storedOverflow = false;
long tScale = getBaseMetaTileEntity().getEUCapacity();
long tStored = getBaseMetaTileEntity().getStoredEU();
long tStep = 0;
if (mInventory != null) {
for (ItemStack aStack : mInventory) {
if (GT_ModHandler.isElectricItem(aStack)) {
@ -271,8 +274,11 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier
if (aStack.getItem() instanceof GT_MetaBase_Item) {
Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack);
if (stats != null) {
if(stats[0]>Long.MAX_VALUE/2){scaleOverflow=true;}
tScale = tScale + stats[0];
tStored = tStored + ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack);
tStep = ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack);
if(tStep > Long.MAX_VALUE/2){storedOverflow=true;}
tStored = tStored + tStep;
}
} else if (aStack.getItem() instanceof IElectricItem) {
tStored = tStored + (long) ic2.api.item.ElectricItem.manager.getCharge(aStack);
@ -282,6 +288,8 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier
}
}
if(scaleOverflow){tScale=Long.MAX_VALUE;}
if(storedOverflow){tStored=Long.MAX_VALUE;}
return new long[]{tStored, tScale};
}