Record Class PlatformBlockEnergyManager

java.lang.Object
java.lang.Record
earth.terrarium.botarium.forge.energy.PlatformBlockEnergyManager
All Implemented Interfaces:
EnergyContainer, Serializable, net.minecraft.world.Clearable

@Internal public record PlatformBlockEnergyManager(net.minecraftforge.energy.IEnergyStorage energy) extends Record implements EnergyContainer
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlatformBlockEnergyManager(net.minecraftforge.energy.IEnergyStorage energy)
    Creates an instance of a PlatformBlockEnergyManager record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    boolean
     
    void
     
     
    void
    deserialize(net.minecraft.nbt.CompoundTag nbt)
    Deserializes the information of an object from a CompoundTag.
    net.minecraftforge.energy.IEnergyStorage
    Returns the value of the energy record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    long
    extractEnergy(long maxAmount, boolean simulate)
    Extracts a given amount of energy into the container.
    long
     
    long
     
    final int
    Returns a hash code value for this object.
    long
    insertEnergy(long maxAmount, boolean simulate)
    Inserts a given amount of energy into the container.
    long
     
    long
     
    of(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.
    net.minecraft.nbt.CompoundTag
    serialize(net.minecraft.nbt.CompoundTag nbt)
    Serializes the information of an object to a CompoundTag.
    void
    setEnergy(long energy)
    Sets a given amount of energy in the container.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface earth.terrarium.botarium.common.energy.base.EnergyContainer

    internalExtract, internalInsert, readSnapshot
  • Constructor Details

    • PlatformBlockEnergyManager

      public PlatformBlockEnergyManager(net.minecraftforge.energy.IEnergyStorage energy)
      Creates an instance of a PlatformBlockEnergyManager record class.
      Parameters:
      energy - the value for the energy record component
  • Method Details

    • of

      public static PlatformBlockEnergyManager 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)
      Description copied from interface: EnergyContainer
      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.
    • 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.
    • 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.
    • 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.
    • deserialize

      public void deserialize(net.minecraft.nbt.CompoundTag nbt)
      Description copied from interface: Serializable
      Deserializes the information of an object from a CompoundTag.
      Specified by:
      deserialize in interface Serializable
      Parameters:
      nbt - The CompoundTag to deserialize from.
    • serialize

      public net.minecraft.nbt.CompoundTag serialize(net.minecraft.nbt.CompoundTag nbt)
      Description copied from interface: Serializable
      Serializes the information of an object to a CompoundTag.
      Specified by:
      serialize in interface Serializable
      Parameters:
      nbt - The CompoundTag to serialize to.
      Returns:
      The CompoundTag that was passed in but with the information of the object serialized added to it.
    • clearContent

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

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • energy

      public net.minecraftforge.energy.IEnergyStorage energy()
      Returns the value of the energy record component.
      Returns:
      the value of the energy record component