Class LongAmountToIntUtil

java.lang.Object
org.moddingx.libx.util.game.LongAmountToIntUtil

public class LongAmountToIntUtil extends Object
Utility methods to convert amounts (must be > 0) that are stored as long to int. This is meant to be used whenever an API only allows int values (like IEnergyStorage) but you store the value as a long. This will output half of Integer.MAX_VALUE if there's more energy stored and more free than the maximum int value so things using these APIs will detect that they can extract stuff and also insert it. (Only at half of the possible maximum speed though) To use this with IEnergyStorage, you can use LongEnergyStorage.
  • Constructor Details

    • LongAmountToIntUtil

      public LongAmountToIntUtil()
  • Method Details

    • getValue

      public static int getValue(long stored, long max)
      Gets a value stored as a long as an int value. For more info, see class description.
    • getMaxValue

      public static int getMaxValue(long max)
      Gets a maximum value stored as a long as an int value. For more info see class description.