Interface IEnergyStorage

All Known Implementing Classes:
ComponentEnergyStorage, EmptyEnergyStorage, EnergyHandlerAdapter, EnergyStorage

@Deprecated(since="1.21.9", forRemoval=true) public interface IEnergyStorage
Deprecated, for removal: This API element is subject to removal in a future version.
Use EnergyHandler instead. Code that is written against IEnergyStorage but receives an EnergyHandler can temporarily use of(net.neoforged.neoforge.transfer.energy.EnergyHandler) to ease migration.
An energy storage is the unit of interaction with Energy inventories.

A reference implementation can be found at EnergyStorage. 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.

  • Method Details

    • of

      static IEnergyStorage of(EnergyHandler handler)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a wrapper around a EnergyHandler, to present it as a legacy IEnergyStorage.

      This class is intended to make migration easier for code that expects an IEnergyStorage.

    • receiveEnergy

      @Deprecated(since="1.21.9", forRemoval=true) int receiveEnergy(int toReceive, boolean simulate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds energy to the storage. Returns the amount of energy that was accepted.
      Parameters:
      toReceive - The amount of energy being received.
      simulate - If true, the insertion will only be simulated, meaning getEnergyStored() will not change.
      Returns:
      Amount of energy that was (or would have been, if simulated) accepted by the storage.
    • extractEnergy

      @Deprecated(since="1.21.9", forRemoval=true) int extractEnergy(int toExtract, boolean simulate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Removes energy from the storage. Returns the amount of energy that was removed.
      Parameters:
      toExtract - The amount of energy being extracted.
      simulate - If true, the extraction will only be simulated, meaning getEnergyStored() will not change.
      Returns:
      Amount of energy that was (or would have been, if simulated) extracted from the storage.
    • getEnergyStored

      @Deprecated(since="1.21.9", forRemoval=true) int getEnergyStored()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the amount of energy currently stored.
    • getMaxEnergyStored

      @Deprecated(since="1.21.9", forRemoval=true) int getMaxEnergyStored()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the maximum amount of energy that can be stored.
    • canExtract

      @Deprecated(since="1.21.9", forRemoval=true) boolean canExtract()
      Deprecated, for removal: This API element is subject to removal in a future version.
      There is no direct equivalent for this method, since each energy handler is expected to perform this check on extraction already. Please open an issue on GitHub if you have a use for an equivalent of this method.
      Returns if this storage can have energy extracted. If this is false, then any calls to extractEnergy will return 0.
    • canReceive

      @Deprecated(since="1.21.9", forRemoval=true) boolean canReceive()
      Deprecated, for removal: This API element is subject to removal in a future version.
      There is no direct equivalent for this method, since each energy handler is expected to perform this check on insertion already. Please open an issue on GitHub if you have a use for an equivalent of this method.
      Used to determine if this storage can receive energy. If this is false, then any calls to receiveEnergy will return 0.