Class AbstractEnergyConductor

java.lang.Object
com.github.darksoulq.abyssallib.common.energy.AbstractEnergyConductor
All Implemented Interfaces:
EnergyConductor, EnergyNode

public abstract class AbstractEnergyConductor extends Object implements EnergyConductor
Base implementation of EnergyConductor representing a transfer-only node with no persistent storage beyond a single-tick buffer.

This implementation enforces a strict transferRate which limits both insertion and extraction per operation. Unlike standard nodes, conductors act as transient carriers within the network.

This class does not automatically register itself into EnergyNetwork.

  • Constructor Details

    • AbstractEnergyConductor

      public AbstractEnergyConductor(double transferRate, EnergyUnit unit)
      Creates a new conductor with a defined transfer rate and unit.
      Parameters:
      transferRate - maximum energy transferable per operation
      unit - energy unit used for this conductor
    • AbstractEnergyConductor

      public AbstractEnergyConductor(double transferRate)
      Creates a new conductor using the default unit EnergyUnits.PE.
      Parameters:
      transferRate - maximum energy transferable per operation
  • Method Details

    • getTransferRate

      public double getTransferRate()
      Specified by:
      getTransferRate in interface EnergyConductor
      Returns:
      maximum transfer rate per tick
    • getUnit

      public EnergyUnit getUnit()
      Specified by:
      getUnit in interface EnergyNode
      Returns:
      unit used by this node
    • getConnections

      public Map<org.bukkit.block.BlockFace, EnergyNode> getConnections()
      Specified by:
      getConnections in interface EnergyNode
      Returns:
      map of connected nodes by face
    • getEnergy

      public double getEnergy()
      Specified by:
      getEnergy in interface EnergyNode
      Returns:
      current stored energy
    • getCapacity

      public double getCapacity()
      Specified by:
      getCapacity in interface EnergyNode
      Returns:
      maximum energy capacity
    • getMaxInsert

      public double getMaxInsert()
      Specified by:
      getMaxInsert in interface EnergyNode
      Returns:
      max energy accepted per tick
    • getMaxExtract

      public double getMaxExtract()
      Specified by:
      getMaxExtract in interface EnergyNode
      Returns:
      max energy extracted per tick
    • insert

      public double insert(@Nullable @Nullable org.bukkit.block.BlockFace side, double amount, Action action)
      Attempts to insert energy into this conductor buffer.
      Specified by:
      insert in interface EnergyNode
      Parameters:
      side - the side the energy is inserted from, or null
      amount - the amount of energy to insert
      action - whether to execute or simulate
      Returns:
      the amount of energy accepted into the buffer
    • extract

      public double extract(@Nullable @Nullable org.bukkit.block.BlockFace side, double amount, Action action)
      Attempts to extract energy from this conductor buffer.
      Specified by:
      extract in interface EnergyNode
      Parameters:
      side - the side the energy is extracted from, or null
      amount - the amount of energy to extract
      action - whether to execute or simulate
      Returns:
      the amount of energy extracted from the buffer