-
Notifications
You must be signed in to change notification settings - Fork 0
Energy System
Important
The Energy System is NOT part of the MultiBlockEngine core. It is an independent addon (mbe-energy) that relies on the mbe-wiring framework to function. It communicates with the core engine exclusively via the MBEServiceRegistry.
The Energy System is a specialized layer built on top of the Wiring System. It provides a standard way to handle power production, consumption, and storage across your multiblock machines.
Producers generate energy (e.g., Solar Panels, Generators).
- Rate: How much energy they produce per tick.
- Buffer: Internal storage before pushing to the network.
Consumers use energy to perform tasks (e.g., Electric Furnaces, Miners).
- Demand: How much they need to operate.
- Behavior: What happens when they run out of power? (e.g., State changes to INACTIVE).
Storage modules (Batteries, Capacitors) hold energy for later use.
- Capacity: Maximum energy they can hold.
- I/O Rate: How fast they can charge or discharge.
When producers and consumers are connected via ENERGY type cables (provided by mbe-wiring), they form an Energy Network.
- Distribution: The addon automatically distributes power from producers to consumers.
- Priority: Certain machines can be given higher priority for power.
Use the Multimeter Tool (mbe:multimeter) on any energy node or port to view real-time statistics:
- Stored Energy / Capacity: Current buffer level.
- Net Flow Rate: Power input vs output per tick across the connected energy graph.
- Producer / Consumer Breakdown: Detailed listing of connected energy nodes.
While complex power logic is often handled by Java addons, you can define basic energy variables and reactions entirely in YAML using standard ECA rules:
id: electric_furnace
variables:
energy_stored: 0
energy_capacity: 10000
actions:
on_tick:
- type: conditional
conditions:
- type: variable
key: energy_stored
value: 10
comparison: GREATER_OR_EQUAL
then:
# Perform work and consume energy
- type: modify_variable
key: energy_stored
operation: SUBTRACT
amount: 10Accessing the energy system in Java requires injecting the exposed EnergyService:
@InjectService
private EnergyService energyService;
public void chargeMachine(MultiblockInstance instance, double amount) {
EnergyStorage storage = energyService.getStorage(instance);
storage.receiveEnergy(amount, false);
}