Class SimpleEnergyContainer
java.lang.Object
earth.terrarium.botarium.common.energy.impl.SimpleEnergyContainer
- All Implemented Interfaces:
EnergyContainer,Serializable,net.minecraft.world.Clearable
- Direct Known Subclasses:
ExtractOnlyEnergyContainer,InsertOnlyEnergyContainer
A simple implementation for energy storage.
This class should be wrapped by a
WrappedBlockEnergyContainer or a WrappedItemEnergyContainer to provide the necessary functionality.-
Constructor Summary
ConstructorsConstructorDescriptionSimpleEnergyContainer(long maxCapacity) SimpleEnergyContainer(long maxCapacity, long maxExtract, long maxInsert) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidvoiddeserialize(net.minecraft.nbt.CompoundTag root) Deserializes the information of an object from aCompoundTag.longextractEnergy(long maxAmount, boolean simulate) Extracts a given amount of energy into the container.longlonglonginsertEnergy(long maxAmount, boolean simulate) Inserts a given amount of energy into the container.longinternalExtract(long maxAmount, boolean simulate) An internal version ofEnergyContainer.extractEnergy(long, boolean)that is used by mod authors looking to directly interact with their own containers.longinternalInsert(long maxAmount, boolean simulate) An internal version ofEnergyContainer.insertEnergy(long, boolean)that is used by mod authors looking to directly interact with their own containers.longlongnet.minecraft.nbt.CompoundTagserialize(net.minecraft.nbt.CompoundTag root) Serializes the information of an object to aCompoundTag.voidsetEnergy(long energy) Sets a given amount of energy in the container.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface earth.terrarium.botarium.common.energy.base.EnergyContainer
readSnapshot
-
Constructor Details
-
SimpleEnergyContainer
public SimpleEnergyContainer(long maxCapacity) -
SimpleEnergyContainer
public SimpleEnergyContainer(long maxCapacity, long maxExtract, long maxInsert)
-
-
Method Details
-
insertEnergy
public long insertEnergy(long maxAmount, boolean simulate) Description copied from interface:EnergyContainerInserts a given amount of energy into the container.- Specified by:
insertEnergyin interfaceEnergyContainer- Parameters:
maxAmount- The amount to be inserted into the container.simulate- If true, the container will not be modified.- Returns:
- The amount of energy that was added to the container.
-
extractEnergy
public long extractEnergy(long maxAmount, boolean simulate) Description copied from interface:EnergyContainerExtracts a given amount of energy into the container.- Specified by:
extractEnergyin interfaceEnergyContainer- Parameters:
maxAmount- The amount to be extracted from the container.simulate- If true, the container will not be modified.- Returns:
- The amount of energy that was removed from the container.
-
internalInsert
public long internalInsert(long maxAmount, boolean simulate) Description copied from interface:EnergyContainerAn internal version ofEnergyContainer.insertEnergy(long, boolean)that is used by mod authors looking to directly interact with their own containers.You should not call this method for other mod's containers, instead use
EnergyContainer.insertEnergy(long, boolean).- Specified by:
internalInsertin interfaceEnergyContainer
-
internalExtract
public long internalExtract(long maxAmount, boolean simulate) Description copied from interface:EnergyContainerAn internal version ofEnergyContainer.extractEnergy(long, boolean)that is used by mod authors looking to directly interact with their own containers.You should not call this method for other mod's containers, instead use
EnergyContainer.extractEnergy(long, boolean).- Specified by:
internalExtractin interfaceEnergyContainer
-
setEnergy
public void setEnergy(long energy) Description copied from interface:EnergyContainerSets a given amount of energy in the container.- Specified by:
setEnergyin interfaceEnergyContainer- Parameters:
energy- The amount of energy to set in the container.
-
getStoredEnergy
public long getStoredEnergy()- Specified by:
getStoredEnergyin interfaceEnergyContainer- Returns:
- The amount of energy in the container.
-
getMaxCapacity
public long getMaxCapacity()- Specified by:
getMaxCapacityin interfaceEnergyContainer- Returns:
- The maximum amount of energy that can be stored in the container.
-
maxInsert
public long maxInsert()- Specified by:
maxInsertin interfaceEnergyContainer- Returns:
- The maximum amount of energy that can be inserted into the container at a time.
-
maxExtract
public long maxExtract()- Specified by:
maxExtractin interfaceEnergyContainer- Returns:
- The maximum amount of energy that can be extracted from the container at a time.
-
serialize
public net.minecraft.nbt.CompoundTag serialize(net.minecraft.nbt.CompoundTag root) Description copied from interface:SerializableSerializes the information of an object to aCompoundTag.- Specified by:
serializein interfaceSerializable- Parameters:
root- TheCompoundTagto serialize to.- Returns:
- The
CompoundTagthat was passed in but with the information of the object serialized added to it.
-
deserialize
public void deserialize(net.minecraft.nbt.CompoundTag root) Description copied from interface:SerializableDeserializes the information of an object from aCompoundTag.- Specified by:
deserializein interfaceSerializable- Parameters:
root- TheCompoundTagto deserialize from.
-
allowsInsertion
public boolean allowsInsertion()- Specified by:
allowsInsertionin interfaceEnergyContainer- Returns:
- Weather the container allows for energy to be inserted.
-
allowsExtraction
public boolean allowsExtraction()- Specified by:
allowsExtractionin interfaceEnergyContainer- Returns:
- Weather the container allows for energy to be extracted.
-
createSnapshot
- Specified by:
createSnapshotin interfaceEnergyContainer- Returns:
- A
EnergySnapshotof the given state of theEnergyContainer.
-
clearContent
public void clearContent()- Specified by:
clearContentin interfacenet.minecraft.world.Clearable
-