Skip to content

Wiring System

DarkBladeDev edited this page Aug 2, 2026 · 4 revisions

πŸ”Œ Wiring & Topology System (mbe-wiring)

Important

The Wiring System is NOT part of the MultiBlockEngine core. It is an independent addon (mbe-wiring) that hooks into the engine via the MBEServiceRegistry. You must install this addon separately if you want to use cable networks.

The Wiring System in MultiBlockEngine is a powerful, generic graph-based framework that allows connecting different blocks and machines through physical "cables" or logic links.

🧠 Core Concepts

1. Network Graph

A network is represented as a mathematical graph where:

  • Nodes: Individual blocks (machines, controllers, or cables).
  • Edges: Connections between these nodes.

The engine maintains these graphs in real-time, handling splits (when a cable is broken) and merges (when cables are connected) efficiently.

2. Network Types

MultiBlockEngine supports multiple isolated topologies. This prevents different systems from interfering with each other even if they share the same space:

  • ENERGY: For power distribution (utilized heavily by mbe-energy).
  • DATA: For signal and logic.
  • FLUID: For liquid transport.
  • ITEM: For item logistics.

3. Ports

Machines interact with networks through Ports. A port defines:

  • Direction: INPUT (accepts) or OUTPUT (emits).
  • Type: Which network type it belongs to.
  • Location: The specific block in the pattern that acts as the port.

🧱 YAML Configuration

You can define ports directly in your multiblock YAML:

id: simple_generator
version: "1.0.0"
controller: FURNACE

ports:
  energy_out:
    direction: output
    type: energy
    block: controller
    capabilities: [emit]

πŸ”„ Multiblock Wiring Integration (MultiblockWiringBridge)

Multiblocks automatically register their defined ports into active network graphs upon formation:

  • Automatic Port Node Registration: When a structure forms (MultiblockFormEvent), MultiblockWiringBridge registers all declared ports as NetworkNodes in the NetworkService.
  • Automatic Cleanup: On deconstruction or structure break (MultiblockUnformEvent), ports are safely detached and surrounding network graphs recalculate topology.
  • Connection Evaluation: WireConnectionEvaluator validates line-of-sight and distance constraints between nodes before establishing graph edges.

πŸ’» Developer API

To interact with the wiring system in Java, your addon must depend on mbe-wiring and inject the NetworkService:

@InjectService
private NetworkService networkService;

public void checkNetwork(Location loc) { // Note: Translating Bukkit Loc to MBE Vector may be required
    Optional<NetworkNode> node = networkService.getNodeAt(loc);
    node.ifPresent(n -> {
        NetworkGraph graph = n.getGraph();
        // ...
    });
}

Clone this wiki locally