IEnergyStorage

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

script.zs
import crafttweaker.api.capability.IEnergyStorage;

Methods

Checks if energy can be extracted from this storage.

Returns: true if the storage can be extracted from, false otherwise.
Return Type: boolean

script.zs
// IEnergyStorage.canExtract() as boolean
myIEnergyStorage.canExtract();

Checks if this storage can receive energy.

Returns: true if this storage can receive energy, false otherwise.
Return Type: boolean

script.zs
// IEnergyStorage.canReceive() as boolean
myIEnergyStorage.canReceive();

Extracts energy from the storage.

Returns: the amount of energy that was extracted.
Return Type: int

script.zs
// IEnergyStorage.extractEnergy(maxExtract as int, simulate as boolean) as int
myIEnergyStorage.extractEnergy(400, false);
ParameterTypeDescription
Parameter
maxExtract
Type
int
Description
The max amount of energy to be extracted.
Parameter
simulate
Type
boolean
Description
If the energy should actually be extracted or not.

Gets the amount of energy stored.

Returns: The amount of energy stored.
Return Type: int

script.zs
// IEnergyStorage.getEnergyStored() as int
myIEnergyStorage.getEnergyStored();

Gets the max energy that can be stored.

Returns: The max energy that can be stored.
Return Type: int

script.zs
// IEnergyStorage.getMaxEnergyStored() as int
myIEnergyStorage.getMaxEnergyStored();

Adds energy to the storage.

Returns: the amount of energy that was accepted.
Return Type: int

script.zs
// IEnergyStorage.receiveEnergy(maxReceive as int, simulate as boolean) as int
myIEnergyStorage.receiveEnergy(300, false);
ParameterTypeDescription
Parameter
maxReceive
Type
int
Description
The max amount of energy to be inserted.
Parameter
simulate
Type
boolean
Description
If the energy should actually be inserted or not.

Properties

NameTypeHas GetterHas SetterDescription
Name
canExtract
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if energy can be extracted from this storage.
Name
canReceive
Type
boolean
Has Getter
true
Has Setter
false
Description
Checks if this storage can receive energy.
Name
energyStored
Type
int
Has Getter
true
Has Setter
false
Description
Gets the amount of energy stored.
Name
maxEnergyStored
Type
int
Has Getter
true
Has Setter
false
Description
Gets the max energy that can be stored.