Package net.neoforged.neoforge.energy
Interface IEnergyStorage
- All Known Implementing Classes:
ComponentEnergyStorage,EmptyEnergyStorage,EnergyHandlerAdapter,EnergyStorage
Deprecated, for removal: This API element is subject to removal in a future version.
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 Summary
Modifier and TypeMethodDescriptionbooleanDeprecated, 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.booleanDeprecated, 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.intextractEnergy(int toExtract, boolean simulate) Deprecated, for removal: This API element is subject to removal in a future version.intDeprecated, for removal: This API element is subject to removal in a future version.Use eitherEnergyHandler.getAmountAsLong()orEnergyHandler.getAmountAsInt()instead.intDeprecated, for removal: This API element is subject to removal in a future version.Use eitherEnergyHandler.getCapacityAsLong()orEnergyHandler.getCapacityAsInt()instead.static IEnergyStorageof(EnergyHandler handler) Deprecated, for removal: This API element is subject to removal in a future version.Creates a wrapper around aEnergyHandler, to present it as a legacyIEnergyStorage.intreceiveEnergy(int toReceive, boolean simulate) Deprecated, for removal: This API element is subject to removal in a future version.
-
Method Details
-
of
Deprecated, for removal: This API element is subject to removal in a future version.Creates a wrapper around aEnergyHandler, to present it as a legacyIEnergyStorage.This class is intended to make migration easier for code that expects an
IEnergyStorage. -
receiveEnergy
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, meaninggetEnergyStored()will not change.- Returns:
- Amount of energy that was (or would have been, if simulated) accepted by the storage.
-
extractEnergy
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, meaninggetEnergyStored()will not change.- Returns:
- Amount of energy that was (or would have been, if simulated) extracted from the storage.
-
getEnergyStored
Deprecated, for removal: This API element is subject to removal in a future version.Use eitherEnergyHandler.getAmountAsLong()orEnergyHandler.getAmountAsInt()instead.Returns the amount of energy currently stored. -
getMaxEnergyStored
Deprecated, for removal: This API element is subject to removal in a future version.Use eitherEnergyHandler.getCapacityAsLong()orEnergyHandler.getCapacityAsInt()instead.Returns the maximum amount of energy that can be stored. -
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, 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.
-
EnergyHandlerinstead. Code that is written againstIEnergyStoragebut receives anEnergyHandlercan temporarily useof(net.neoforged.neoforge.transfer.energy.EnergyHandler)to ease migration.