-
Notifications
You must be signed in to change notification settings - Fork 0
Wiring System
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.
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.
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 bymbe-energy). -
DATA: For signal and logic. -
FLUID: For liquid transport. -
ITEM: For item logistics.
Machines interact with networks through Ports. A port defines:
-
Direction:
INPUT(accepts) orOUTPUT(emits). - Type: Which network type it belongs to.
- Location: The specific block in the pattern that acts as the port.
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]Multiblocks automatically register their defined ports into active network graphs upon formation:
-
Automatic Port Node Registration: When a structure forms (
MultiblockFormEvent),MultiblockWiringBridgeregisters all declared ports asNetworkNodes in theNetworkService. -
Automatic Cleanup: On deconstruction or structure break (
MultiblockUnformEvent), ports are safely detached and surrounding network graphs recalculate topology. -
Connection Evaluation:
WireConnectionEvaluatorvalidates line-of-sight and distance constraints between nodes before establishing graph edges.
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();
// ...
});
}