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

public class SimpleEnergyContainer extends Object implements EnergyContainer
A simple implementation for energy storage. This class should be wrapped by a WrappedBlockEnergyContainer or a WrappedItemEnergyContainer to provide the necessary functionality.
  • 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: EnergyContainer
      Inserts a given amount of energy into the container.
      Specified by:
      insertEnergy in interface EnergyContainer
      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: EnergyContainer
      Extracts a given amount of energy into the container.
      Specified by:
      extractEnergy in interface EnergyContainer
      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: EnergyContainer
      An internal version of EnergyContainer.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:
      internalInsert in interface EnergyContainer
    • internalExtract

      public long internalExtract(long maxAmount, boolean simulate)
      Description copied from interface: EnergyContainer
      An internal version of EnergyContainer.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:
      internalExtract in interface EnergyContainer
    • setEnergy

      public void setEnergy(long energy)
      Description copied from interface: EnergyContainer
      Sets a given amount of energy in the container.
      Specified by:
      setEnergy in interface EnergyContainer
      Parameters:
      energy - The amount of energy to set in the container.
    • getStoredEnergy

      public long getStoredEnergy()
      Specified by:
      getStoredEnergy in interface EnergyContainer
      Returns:
      The amount of energy in the container.
    • getMaxCapacity

      public long getMaxCapacity()
      Specified by:
      getMaxCapacity in interface EnergyContainer
      Returns:
      The maximum amount of energy that can be stored in the container.
    • maxInsert

      public long maxInsert()
      Specified by:
      maxInsert in interface EnergyContainer
      Returns:
      The maximum amount of energy that can be inserted into the container at a time.
    • maxExtract

      public long maxExtract()
      Specified by:
      maxExtract in interface EnergyContainer
      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: Serializable
      Serializes the information of an object to a CompoundTag.
      Specified by:
      serialize in interface Serializable
      Parameters:
      root - The CompoundTag to serialize to.
      Returns:
      The CompoundTag that 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: Serializable
      Deserializes the information of an object from a CompoundTag.
      Specified by:
      deserialize in interface Serializable
      Parameters:
      root - The CompoundTag to deserialize from.
    • allowsInsertion

      public boolean allowsInsertion()
      Specified by:
      allowsInsertion in interface EnergyContainer
      Returns:
      Weather the container allows for energy to be inserted.
    • allowsExtraction

      public boolean allowsExtraction()
      Specified by:
      allowsExtraction in interface EnergyContainer
      Returns:
      Weather the container allows for energy to be extracted.
    • createSnapshot

      public EnergySnapshot createSnapshot()
      Specified by:
      createSnapshot in interface EnergyContainer
      Returns:
      A EnergySnapshot of the given state of the EnergyContainer.
    • clearContent

      public void clearContent()
      Specified by:
      clearContent in interface net.minecraft.world.Clearable