Package net.minecraftforge.energy
Class EmptyEnergyStorage
java.lang.Object
net.minecraftforge.energy.EmptyEnergyStorage
- All Implemented Interfaces:
IEnergyStorage
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns if this storage can have energy extracted.booleanUsed to determine if this storage can receive energy.intextractEnergy(int maxExtract, boolean simulate) Removes energy from the storage.intReturns the amount of energy currently stored.intReturns the maximum amount of energy that can be stored.intreceiveEnergy(int maxReceive, boolean simulate) Adds energy to the storage.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
EmptyEnergyStorage
protected EmptyEnergyStorage()
-
-
Method Details
-
receiveEnergy
public int receiveEnergy(int maxReceive, boolean simulate) Description copied from interface:IEnergyStorageAdds energy to the storage. Returns quantity of energy that was accepted.- Specified by:
receiveEnergyin interfaceIEnergyStorage- 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:IEnergyStorageRemoves energy from the storage. Returns quantity of energy that was removed.- Specified by:
extractEnergyin interfaceIEnergyStorage- 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.
-
getEnergyStored
public int getEnergyStored()Description copied from interface:IEnergyStorageReturns the amount of energy currently stored.- Specified by:
getEnergyStoredin interfaceIEnergyStorage
-
getMaxEnergyStored
public int getMaxEnergyStored()Description copied from interface:IEnergyStorageReturns the maximum amount of energy that can be stored.- Specified by:
getMaxEnergyStoredin interfaceIEnergyStorage
-
canExtract
public boolean canExtract()Description copied from interface:IEnergyStorageReturns if this storage can have energy extracted. If this is false, then any calls to extractEnergy will return 0.- Specified by:
canExtractin interfaceIEnergyStorage
-
canReceive
public boolean canReceive()Description copied from interface:IEnergyStorageUsed to determine if this storage can receive energy. If this is false, then any calls to receiveEnergy will return 0.- Specified by:
canReceivein interfaceIEnergyStorage
-