Class EnergyStorage

  • All Implemented Interfaces:
    IEnergyStorage

    public class EnergyStorage
    extends java.lang.Object
    implements IEnergyStorage
    Reference implementation of IEnergyStorage. Use/extend this or implement your own. Derived from the Redstone Flux power system designed by King Lemming and originally utilized in Thermal Expansion and related mods. Created with consent and permission of King Lemming and Team CoFH. Released with permission under LGPL 2.1 when bundled with Forge.
    • Constructor Summary

      Constructors 
      Constructor Description
      EnergyStorage​(int capacity)  
      EnergyStorage​(int capacity, int maxTransfer)  
      EnergyStorage​(int capacity, int maxReceive, int maxExtract)  
      EnergyStorage​(int capacity, int maxReceive, int maxExtract, int energy)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canExtract()
      Returns if this storage can have energy extracted.
      boolean canReceive()
      Used to determine if this storage can receive energy.
      int extractEnergy​(int maxExtract, boolean simulate)
      Removes energy from the storage.
      int getEnergyStored()
      Returns the amount of energy currently stored.
      int getMaxEnergyStored()
      Returns the maximum amount of energy that can be stored.
      int receiveEnergy​(int maxReceive, boolean simulate)
      Adds energy to the storage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • energy

        protected int energy
      • capacity

        protected int capacity
      • maxReceive

        protected int maxReceive
      • maxExtract

        protected int maxExtract
    • Constructor Detail

      • EnergyStorage

        public EnergyStorage​(int capacity)
      • EnergyStorage

        public EnergyStorage​(int capacity,
                             int maxTransfer)
      • EnergyStorage

        public EnergyStorage​(int capacity,
                             int maxReceive,
                             int maxExtract)
      • EnergyStorage

        public EnergyStorage​(int capacity,
                             int maxReceive,
                             int maxExtract,
                             int energy)
    • Method Detail

      • receiveEnergy

        public int receiveEnergy​(int maxReceive,
                                 boolean simulate)
        Description copied from interface: IEnergyStorage
        Adds energy to the storage. Returns quantity of energy that was accepted.
        Specified by:
        receiveEnergy in interface IEnergyStorage
        Parameters:
        maxReceive - Maximum amount of energy to be inserted.
        simulate - If TRUE, the insertion will only be simulated.
        Returns:
        Amount of energy that was (or would have been, if simulated) accepted by the storage.
      • extractEnergy

        public int extractEnergy​(int maxExtract,
                                 boolean simulate)
        Description copied from interface: IEnergyStorage
        Removes energy from the storage. Returns quantity of energy that was removed.
        Specified by:
        extractEnergy in interface IEnergyStorage
        Parameters:
        maxExtract - Maximum amount of energy to be extracted.
        simulate - If TRUE, the extraction will only be simulated.
        Returns:
        Amount of energy that was (or would have been, if simulated) extracted from the storage.
      • canExtract

        public boolean canExtract()
        Description copied from interface: IEnergyStorage
        Returns if this storage can have energy extracted. If this is false, then any calls to extractEnergy will return 0.
        Specified by:
        canExtract in interface IEnergyStorage
      • canReceive

        public boolean canReceive()
        Description copied from interface: IEnergyStorage
        Used to determine if this storage can receive energy. If this is false, then any calls to receiveEnergy will return 0.
        Specified by:
        canReceive in interface IEnergyStorage