@@ -629,13 +629,17 @@ public PowerStationEnergyBank(NBTTagCompound storageTag) {
629629 } else {
630630 stored [0 ] = storageTag .getLong (NBT_STORED + "0" );
631631 stored [1 ] = storageTag .getLong (NBT_STORED + "1" );
632+ drain = storageTag .getLong ("drain" );
633+ drainMod = storageTag .getLong ("drainMod" );
632634 }
633635 capacity = summarize (max );
634636 }
635637
636638 public NBTTagCompound writeToNBT (NBTTagCompound compound ) {
637639 compound .setLong (NBT_STORED + "0" , stored [0 ]);
638640 compound .setLong (NBT_STORED + "1" , stored [1 ]);
641+ compound .setLong ("drain" , drain );
642+ compound .setLong ("drainMod" , drainMod );
639643 return compound ;
640644 }
641645
@@ -706,7 +710,7 @@ public long drain(long amount) {
706710 }
707711 if (stored [1 ] < amount ) {
708712 stored [0 ]--;
709- stored [1 ] = stored [ 1 ] - amount + Long .MAX_VALUE + 1 ;
713+ stored [1 ] -= amount + Long .MIN_VALUE ;
710714 } else stored [1 ] -= amount ;
711715 return amount ;
712716 }
@@ -728,11 +732,10 @@ private static BigInteger summarize(long[] num) {
728732 }
729733
730734 private static void add (long [] num , long val ) {
731- if (val + num [1 ] < 0 ) {
735+ if (( num [1 ] += val ) < 0 ) {
732736 num [0 ]++;
733- num [1 ] + = Long .MIN_VALUE ;
737+ num [1 ] - = Long .MIN_VALUE ;
734738 }
735- num [1 ] += val ;
736739 }
737740
738741 @ VisibleForTesting
0 commit comments