Class SimpleBattery<T extends Number & Comparable<T>>

java.lang.Object
design.aeonic.nifty.api.transfer.base.SimpleBattery<T>
All Implemented Interfaces:
Battery<T>
Direct Known Subclasses:
SimpleBattery.BigBattery, SimpleBattery.IntBattery, SimpleBattery.LongBattery

public abstract class SimpleBattery<T extends Number & Comparable<T>> extends Object implements Battery<T>
  • Constructor Details

    • SimpleBattery

      public SimpleBattery(T capacity)
    • SimpleBattery

      public SimpleBattery(T capacity, T stored)
  • Method Details

    • resize

      public void resize(T capacity)
    • setStored

      public void setStored(T stored)
    • writeNBT

      public abstract void writeNBT(net.minecraft.nbt.CompoundTag tag)
    • readNBT

      public abstract void readNBT(net.minecraft.nbt.CompoundTag tag)
    • zero

      protected abstract T zero()
    • add

      protected abstract T add(T a, T b)
    • subtract

      protected abstract T subtract(T a, T b)
    • min

      protected T min(T a, T b)
    • getCapacity

      public T getCapacity()
      Description copied from interface: Battery
      Gets the maximum capacity of the battery.
      Specified by:
      getCapacity in interface Battery<T extends Number & Comparable<T>>
    • getStored

      public T getStored()
      Description copied from interface: Battery
      Gets the current amount of energy stored in the battery.
      Specified by:
      getStored in interface Battery<T extends Number & Comparable<T>>
    • insert

      public T insert(T amount, boolean simulate)
      Description copied from interface: Battery
      Inserts into the battery. If simulate is true, the actual battery's stored value will not be changed. Returns the amount inserted.
      Specified by:
      insert in interface Battery<T extends Number & Comparable<T>>
    • extract

      public T extract(T amount, boolean simulate)
      Description copied from interface: Battery
      Extracts from the battery. If simulate is true, the actual battery's stored value will not be changed.
      Specified by:
      extract in interface Battery<T extends Number & Comparable<T>>
    • onChange

      public void onChange()
      Called when the battery's stored value changes, override to mark your provider as dirty.