Interface WiredNode
- All Superinterfaces:
PacketNetwork
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 TypeMethodDescriptionboolean
Create a connection from this node to another.boolean
disconnectFrom
(WiredNode node) Destroy a connection between this node and another.The associated element for this network node.boolean
remove()
Sever all connections this node has, removing it from this network.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.
-
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.- See Also:
-
remove
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.
-
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.
-