public interface Network
Node
, the most basic form.Component
, used to expose callbacks to user code.Connector
, used for consuming of producing energy.Visibility
.
Network
to create and join networks.Modifier and Type | Method and Description |
---|---|
boolean |
connect(Node nodeA,
Node nodeB)
Adds a new node connection in the network.
|
boolean |
disconnect(Node nodeA,
Node nodeB)
Removes a node connection in the network.
|
java.lang.Iterable<Node> |
neighbors(Node node)
The list of nodes the specified node is directly connected to.
|
Node |
node(java.lang.String address)
Get the network node with the specified address.
|
java.lang.Iterable<Node> |
nodes()
The list of all nodes in this network.
|
java.lang.Iterable<Node> |
nodes(Node reference)
The list of addressed nodes in the network reachable by the specified node.
|
boolean |
remove(Node node)
Removes a node from the network.
|
void |
sendToAddress(Node source,
java.lang.String target,
java.lang.String name,
java.lang.Object... data)
Sends a message to the node with the specified address.
|
void |
sendToNeighbors(Node source,
java.lang.String name,
java.lang.Object... data)
Sends a message to all addressed, visible neighbors of the source node.
|
void |
sendToReachable(Node source,
java.lang.String name,
java.lang.Object... data)
Sends a message to all addressed nodes reachable to the source node.
|
void |
sendToVisible(Node source,
java.lang.String name,
java.lang.Object... data)
Sends a message to all addressed nodes visible to the source node.
|
boolean connect(Node nodeA, Node nodeB)
nodeA
- the first node.nodeB
- the second node.java.lang.IllegalArgumentException
- if neither node is in this network.boolean disconnect(Node nodeA, Node nodeB)
nodeA
- the first node.nodeB
- the second node.java.lang.IllegalArgumentException
- if the nodes are not in this network.boolean remove(Node node)
TileEntity.setRemoved()
) or unloaded
(e.g. in TileEntity.onChunkUnloaded()
).
Removing the node can lead to one or more new networks if it was the a
bridge node, i.e. the only node connecting the resulting networks.node
- the node to remove from the network.Node node(java.lang.String address)
address
- the address of the node to get.java.lang.Iterable<Node> nodes()
java.lang.Iterable<Node> nodes(Node reference)
reference
- the node to get the visible other nodes for.java.lang.Iterable<Node> neighbors(Node node)
node
- the node to get the neighbors for.java.lang.IllegalArgumentException
- if the specified node is not in this network.void sendToAddress(Node source, java.lang.String target, java.lang.String name, java.lang.Object... data)
source
- the node that sends the message.target
- the id of the node to send the message to.name
- the name of the message.data
- the message to send.java.lang.IllegalArgumentException
- if the source node is not in this network.void sendToNeighbors(Node source, java.lang.String name, java.lang.Object... data)
neighbors(Node)
and additionally
filtered for reachability (so that unreachable nodes are ignored).
source
- the node that sends the message.name
- the name of the message.data
- the message to send.java.lang.IllegalArgumentException
- if the source node is not in this network.neighbors(Node)
void sendToReachable(Node source, java.lang.String name, java.lang.Object... data)
nodes(Node)
.
source
- the node that sends the message.data
- the message to send.java.lang.IllegalArgumentException
- if the source node is not in this network.nodes(Node)
void sendToVisible(Node source, java.lang.String name, java.lang.Object... data)
nodes(Node)
and additionally
filtered for visibility (so that invisible nodes are ignored).
source
- the node that sends the message.data
- the message to send.java.lang.IllegalArgumentException
- if the source node is not in this network.nodes(Node)
,
Component.canBeSeenFrom(Node)