Interface EnergyContainer
- All Superinterfaces:
net.minecraft.world.Clearable,Serializable
- All Known Implementing Classes:
ExtractOnlyEnergyContainer,InsertOnlyEnergyContainer,PlatformBlockEnergyManager,PlatformItemEnergyManager,SimpleEnergyContainer,UnlimitedEnergyContainer,WrappedBlockEnergyContainer,WrappedItemEnergyContainer
-
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanlongextractEnergy(long maxAmount, boolean simulate) Extracts a given amount of energy into the container.longlongstatic booleanholdsEnergy(net.minecraft.world.item.ItemStack stack) Checks if an ItemStack holds energy.static booleanholdsEnergy(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable net.minecraft.core.Direction direction) Checks if the given block entity holds energy.static booleanholdsEnergy(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable net.minecraft.core.Direction direction) Checks if the given block at the specified position and state holds energy.longinsertEnergy(long maxAmount, boolean simulate) Inserts a given amount of energy into the container.default longinternalExtract(long amount, boolean simulate) An internal version ofextractEnergy(long, boolean)that is used by mod authors looking to directly interact with their own containers.default longinternalInsert(long amount, boolean simulate) An internal version ofinsertEnergy(long, boolean)that is used by mod authors looking to directly interact with their own containers.longlongstatic EnergyContainerof(ItemStackHolder holder) Retrieves an instance of EnergyContainer for the given item stack holder.static EnergyContainerof(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable net.minecraft.core.Direction direction) Retrieves an instance of EnergyContainer for the given block entity and direction.static EnergyContainerof(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable net.minecraft.core.Direction direction) Retrieves an instance of EnergyContainer for the given level, position, state, entity, and direction.default voidreadSnapshot(EnergySnapshot snapshot) Sets theEnergyContainerwith the given state ofEnergySnapshot.voidsetEnergy(long energy) Sets a given amount of energy in the container.Methods inherited from interface net.minecraft.world.Clearable
clearContentMethods inherited from interface earth.terrarium.botarium.util.Serializable
deserialize, serialize
-
Method Details
-
of
@ImplementedByExtension static EnergyContainer of(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable @Nullable net.minecraft.core.Direction direction) Retrieves an instance of EnergyContainer for the given level, position, state, entity, and direction. This method can be used to retrieve EnergyContainers from Botarium and any other mod that uses the modloader's Energy API.- Parameters:
level- The level of the EnergyContainer.pos- The position of the EnergyContainer.state- The block state of the EnergyContainer.entity- The block entity associated with the EnergyContainer (can be null).direction- The direction of the EnergyContainer (can be null).- Returns:
- An instance of EnergyContainer.
-
of
static EnergyContainer of(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable @Nullable net.minecraft.core.Direction direction) Retrieves an instance of EnergyContainer for the given block entity and direction. This method can be used to retrieve EnergyContainers from Botarium and any other mod that uses the modloader's Energy API.- Parameters:
block- The block entity associated with the EnergyContainer.direction- The direction of the EnergyContainer (can be null).- Returns:
- An instance of EnergyContainer.
-
of
Retrieves an instance of EnergyContainer for the given item stack holder. On Fabric, the item stack holder's internal stack will be mutated, and you should replace the item stack inside the container inside with the stack fromItemStackHolder.getStack(). This method can be used to retrieve EnergyContainers from Botarium and any other mod that uses the modloader's Energy API.- Parameters:
holder- The item stack holder.- Returns:
- An instance of EnergyContainer.
-
holdsEnergy
@ImplementedByExtension static boolean holdsEnergy(net.minecraft.world.item.ItemStack stack) Checks if an ItemStack holds energy. This method can be used to check ItemStacks from Botarium and any other mod that uses the modloader's Energy API.- Parameters:
stack- The ItemStack to check.- Returns:
- True if the ItemStack holds energy, false otherwise.
-
holdsEnergy
@ImplementedByExtension static boolean holdsEnergy(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable @Nullable net.minecraft.world.level.block.entity.BlockEntity entity, @Nullable @Nullable net.minecraft.core.Direction direction) Checks if the given block at the specified position and state holds energy. This method can be used to check blocks from Botarium and any other mod that uses the modloader's Energy API.NOTE: While Fabric and NeoForge support attaching energy to blocks, MinecraftForge does not. This means that while Botarium does support energy blocks on Fabric and NeoForge, it does not support them on Forge, and this method will always return false on a block without a block entity on MinecraftForge.
- Parameters:
level- The level of the block.pos- The position of the block.state- The block state.entity- The block entity associated with the block (can be null).direction- The direction of the block (can be null).- Returns:
- True if the block holds energy, false otherwise.
-
holdsEnergy
static boolean holdsEnergy(net.minecraft.world.level.block.entity.BlockEntity block, @Nullable @Nullable net.minecraft.core.Direction direction) Checks if the given block entity holds energy. This method can be used to check block entities from Botarium and any other mod that uses the modloader's Energy API.- Parameters:
block- The block entity to check.direction- The direction of the block entity (can be null).- Returns:
- True if the block entity holds energy, false otherwise.
-
insertEnergy
long insertEnergy(long maxAmount, boolean simulate) Inserts a given amount of energy into the container.- 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.
-
internalInsert
default long internalInsert(long amount, boolean simulate) An internal version ofinsertEnergy(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
insertEnergy(long, boolean). -
extractEnergy
long extractEnergy(long maxAmount, boolean simulate) Extracts a given amount of energy into the container.- 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.
-
internalExtract
default long internalExtract(long amount, boolean simulate) An internal version ofextractEnergy(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
extractEnergy(long, boolean). -
setEnergy
void setEnergy(long energy) Sets a given amount of energy in the container.- Parameters:
energy- The amount of energy to set in the container.
-
getStoredEnergy
long getStoredEnergy()- Returns:
- The amount of energy in the container.
-
getMaxCapacity
long getMaxCapacity()- Returns:
- The maximum amount of energy that can be stored in the container.
-
maxInsert
long maxInsert()- Returns:
- The maximum amount of energy that can be inserted into the container at a time.
-
maxExtract
long maxExtract()- Returns:
- The maximum amount of energy that can be extracted from the container at a time.
-
allowsInsertion
boolean allowsInsertion()- Returns:
- Weather the container allows for energy to be inserted.
-
allowsExtraction
boolean allowsExtraction()- Returns:
- Weather the container allows for energy to be extracted.
-
createSnapshot
EnergySnapshot createSnapshot()- Returns:
- A
EnergySnapshotof the given state of theEnergyContainer.
-
readSnapshot
Sets theEnergyContainerwith the given state ofEnergySnapshot.- Parameters:
snapshot- TheEnergySnapshotto set theEnergyContainerto.
-