Skip to content

Service Registry

DarkBladeDev edited this page May 10, 2026 · 1 revision

🏛️ Service Registry (SOA)

MultiBlockEngine is built with a Service-Oriented Architecture (SOA). This means that functionality is divided into independent, decoupled services that communicate through well-defined API contracts.

💉 Dependency Injection

The engine provides a built-in DI system for both internal core components and external addons.

Using @InjectService

In any class managed by the engine (like a MultiblockAddon or a registered service), you can simply annotate a field to have it automatically populated:

public class MyLogic {
    @InjectService
    private MultiblockRuntimeService runtime;
    
    @InjectService
    private EnergyService energy;
}

Manual Lookup

If you are in a context where injection isn't possible, you can use the AddonAPI:

MultiblockRuntimeService service = AddonAPI.getService(MultiblockRuntimeService.class);

📋 Available Core Services

Service Description
MultiblockRuntimeService Manage active multiblock instances, search, and lifecycle.
AddonLifecycleService Manage addon registration and state.
HologramService Create and manage TextDisplay holograms above multiblocks.
PersistenceService Low-level access to the SQLite/MySQL database.
MetricsService Track performance and usage statistics.
MessageService i18n-aware messaging and formatting.

🔌 Ecosystem Services (Addons)

These services are provided by the official addons and might not be available if the addon is missing.

Service Addon Description
NetworkService mbe-wiring Manage topologies, nodes, and graphs.
EnergyService mbe-energy Handle power producers, consumers, and storage.
PanelViewService mbe-ui Open and manage dynamic UI panels.
BlueprintService mbe-blueprints Start/stop visual preview sessions.

🛠️ Service Lifecycle

Services go through several phases:

  1. Register: The service is added to the registry.
  2. Initialize: Dependencies are injected, but logic shouldn't start yet.
  3. Start: The engine is ready, and services can start tasks/listeners.
  4. Stop: Graceful shutdown and data saving.

Clone this wiki locally