Class AbstractEnergyConductor
java.lang.Object
com.github.darksoulq.abyssallib.common.energy.AbstractEnergyConductor
- All Implemented Interfaces:
EnergyConductor,EnergyNode
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.
-
Field Summary
Fields inherited from interface com.github.darksoulq.abyssallib.common.energy.EnergyNode
CODEC -
Constructor Summary
ConstructorsConstructorDescriptionAbstractEnergyConductor(double transferRate) Creates a new conductor using the default unitEnergyUnits.PE.AbstractEnergyConductor(double transferRate, EnergyUnit unit) Creates a new conductor with a defined transfer rate and unit. -
Method Summary
Modifier and TypeMethodDescriptiondoubleAttempts to extract energy from this conductor buffer.doubleMap<org.bukkit.block.BlockFace, EnergyNode> doubledoubledoubledoublegetUnit()doubleAttempts to insert energy into this conductor buffer.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.darksoulq.abyssallib.common.energy.EnergyNode
canProvide, canReceive, connect, disconnect, getLocation, getType
-
Constructor Details
-
AbstractEnergyConductor
Creates a new conductor with a defined transfer rate and unit.- Parameters:
transferRate- maximum energy transferable per operationunit- energy unit used for this conductor
-
AbstractEnergyConductor
public AbstractEnergyConductor(double transferRate) Creates a new conductor using the default unitEnergyUnits.PE.- Parameters:
transferRate- maximum energy transferable per operation
-
-
Method Details
-
getTransferRate
public double getTransferRate()- Specified by:
getTransferRatein interfaceEnergyConductor- Returns:
- maximum transfer rate per tick
-
getUnit
- Specified by:
getUnitin interfaceEnergyNode- Returns:
- unit used by this node
-
getConnections
- Specified by:
getConnectionsin interfaceEnergyNode- Returns:
- map of connected nodes by face
-
getEnergy
public double getEnergy()- Specified by:
getEnergyin interfaceEnergyNode- Returns:
- current stored energy
-
getCapacity
public double getCapacity()- Specified by:
getCapacityin interfaceEnergyNode- Returns:
- maximum energy capacity
-
getMaxInsert
public double getMaxInsert()- Specified by:
getMaxInsertin interfaceEnergyNode- Returns:
- max energy accepted per tick
-
getMaxExtract
public double getMaxExtract()- Specified by:
getMaxExtractin interfaceEnergyNode- 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:
insertin interfaceEnergyNode- Parameters:
side- the side the energy is inserted from, ornullamount- the amount of energy to insertaction- 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:
extractin interfaceEnergyNode- Parameters:
side- the side the energy is extracted from, ornullamount- the amount of energy to extractaction- whether to execute or simulate- Returns:
- the amount of energy extracted from the buffer
-