Class EmptyEnergyStorage

java.lang.Object
net.neoforged.neoforge.energy.EmptyEnergyStorage
All Implemented Interfaces:
IEnergyStorage

@Deprecated(since="1.21.9", forRemoval=true) public class EmptyEnergyStorage extends Object implements IEnergyStorage
Deprecated, for removal: This API element is subject to removal in a future version.
Use EmptyEnergyHandler instead.
Implementation of IEnergyStorage that cannot store, receive, or provide energy. Use the INSTANCE, don't instantiate. Example:

 ItemStack stack = ...;
 IEnergyStorage storage = stack.getCapability(ForgeCapabilities.ENERGY).orElse(EmptyEnergyStorage.INSTANCE);
 // Use storage without checking whether it's present.
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final EmptyEnergyStorage
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns if this storage can have energy extracted.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Used to determine if this storage can receive energy.
    int
    extractEnergy(int maxExtract, boolean simulate)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Removes energy from the storage.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the amount of energy currently stored.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the maximum amount of energy that can be stored.
    int
    receiveEnergy(int maxReceive, boolean simulate)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Adds energy to the storage.

    Methods inherited from class java.lang.Object

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

    • INSTANCE

      public static final EmptyEnergyStorage INSTANCE
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • EmptyEnergyStorage

      protected EmptyEnergyStorage()
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • receiveEnergy

      public int receiveEnergy(int maxReceive, boolean simulate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IEnergyStorage
      Adds energy to the storage. Returns the amount of energy that was accepted.
      Specified by:
      receiveEnergy in interface IEnergyStorage
      Parameters:
      maxReceive - The amount of energy being received.
      simulate - If true, the insertion will only be simulated, meaning IEnergyStorage.getEnergyStored() will not change.
      Returns:
      Amount of energy that was (or would have been, if simulated) accepted by the storage.
    • extractEnergy

      public int extractEnergy(int maxExtract, boolean simulate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IEnergyStorage
      Removes energy from the storage. Returns the amount of energy that was removed.
      Specified by:
      extractEnergy in interface IEnergyStorage
      Parameters:
      maxExtract - The amount of energy being extracted.
      simulate - If true, the extraction will only be simulated, meaning IEnergyStorage.getEnergyStored() will not change.
      Returns:
      Amount of energy that was (or would have been, if simulated) extracted from the storage.
    • getEnergyStored

      public int getEnergyStored()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IEnergyStorage
      Returns the amount of energy currently stored.
      Specified by:
      getEnergyStored in interface IEnergyStorage
    • getMaxEnergyStored

      public int getMaxEnergyStored()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: IEnergyStorage
      Returns the maximum amount of energy that can be stored.
      Specified by:
      getMaxEnergyStored in interface IEnergyStorage
    • canExtract

      public boolean canExtract()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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