Interface WiredNode
- All Superinterfaces:
PacketNetwork
WiredElement
s and WiredNetwork
s.
Firstly, a node acts as a packet network, capable of sending and receiving modem messages to connected nodes. These methods may be safely used on any thread.
When sending a packet, the system will attempt to find the shortest path between the two nodes based on their element's position. Note that packet senders and receivers can have different locations from their associated element: the distance between the two will be added to the total packet's distance.
Wired nodes also provide several convenience methods for interacting with a wired network. These should only ever be used on the main server thread.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Create a connection from this node to another.default boolean
disconnectFrom
(WiredNode node) Destroy a connection between this node and another.The associated element for this network node.The network this node is currently connected to.default boolean
remove()
Sever all connections this node has, removing it from this network.default void
updatePeripherals
(Map<String, IPeripheral> peripherals) Mark this node's peripherals as having changed.Methods inherited from interface dan200.computercraft.api.network.PacketNetwork
addReceiver, isWireless, removeReceiver, transmitInterdimensional, transmitSameDimension
-
Method Details
-
getElement
WiredElement getElement()The associated element for this network node.- Returns:
- This node's element.
-
getNetwork
WiredNetwork getNetwork()The network this node is currently connected to. Note that this may change after any network operation, so it should not be cached.This should only be used on the server thread.
- Returns:
- This node's network.
-
connectTo
Create a connection from this node to another.This should only be used on the server thread.
- Parameters:
node
- The other node to connect to.- Returns:
true
if a connection was created orfalse
if the connection already exists.- See Also:
-
disconnectFrom
Destroy a connection between this node and another.This should only be used on the server thread.
- Parameters:
node
- The other node to disconnect from.- Returns:
true
if a connection was destroyed orfalse
if no connection exists.- Throws:
IllegalArgumentException
- Ifnode
is not on the same network.- See Also:
-
remove
default boolean remove()Sever all connections this node has, removing it from this network.This should only be used on the server thread. You should only call this on nodes that your network element owns.
- Returns:
- Whether this node was removed from the network. One cannot remove a node from a network where it is the only element.
- Throws:
IllegalArgumentException
- If the node is not in the network.- See Also:
-
updatePeripherals
Mark this node's peripherals as having changed.This should only be used on the server thread. You should only call this on nodes that your network element owns.
- Parameters:
peripherals
- The new peripherals for this node.- See Also:
-