NetworkState

Contains or links to all network-related data for a specific World.

Unless otherwise specified, all functions in this class are only to be called from the network configurator context.

Properties

Link copied to clipboard

A sequence of all loaded ProtoNetworks.

Functions

Link copied to clipboard
suspend fun connectEndPointToBridge(endPoint: NetworkEndPoint, bridge: NetworkBridge, networkType: NetworkType<*>, face: BlockFace, clustersToEnlarge: MutableSet<ProtoNetwork<*>>)

Tries to connect endPoint to bridge from face over networkType, adding all ProtoNetworks whose clusters need to be enlarged with endPoint to clustersToEnlarge.

Link copied to clipboard
suspend fun <T : Network<T>> connectEndPointToEndPoint(endPoint: NetworkEndPoint, other: NetworkEndPoint, networkType: NetworkType<T>, face: BlockFace, clustersToInit: MutableSet<ProtoNetwork<*>>): Boolean

Connects endPoint to other from face over networkType and adds the new ProtoNetwork to clustersToInit.

Link copied to clipboard
operator fun contains(network: ProtoNetwork<*>): Boolean

Checks whether a network with the same UUID as network is present in the network state.

operator fun contains(node: NetworkNode): Boolean

Checks whether a node with the same position as node is present in the network state.

Link copied to clipboard
fun <T : Network<T>> createNetwork(type: NetworkType<T>, networkId: UUID = UUID.randomUUID()): ProtoNetwork<T>

Creates a new ProtoNetwork with the given type and networkId.

Link copied to clipboard
fun deleteNetwork(network: ProtoNetwork<*>)

Removes the network from the network state and schedules the deletion of its data from disk.

Link copied to clipboard
suspend fun disconnectEndPointFromBridge(endPoint: NetworkEndPoint, bridge: NetworkBridge, networkType: NetworkType<*>, face: BlockFace, clustersToInit: MutableSet<ProtoNetwork<*>>)

Disconnects endPoint from bridge at face over networkType, adding all ProtoNetworks whose clusters need to be reinitialized to clustersToInit.

Link copied to clipboard
suspend fun disconnectEndPointFromEndPoint(endPoint: NetworkEndPoint, other: NetworkEndPoint, networkType: NetworkType<*>, face: BlockFace, clustersToInit: MutableSet<ProtoNetwork<*>>)

Disconnects endPoint from other at face over networkType, adding all ProtoNetworks whose clusters need to be reinitialized to clustersToInit.

Link copied to clipboard
inline suspend fun forEachConnectedNode(node: NetworkNode, action: (NetworkType<*>, BlockFace, NetworkNode) -> Unit)

Iterates over all NetworkNodes connected to node, calling action for each connection. The action parameters describe using which NetworkType and through wich BlockFace the NetworkNode is connected. Some NetworkNodes may be connected through multiple NetworkTypes.

inline suspend fun forEachConnectedNode(node: NetworkNode, networkType: NetworkType<*>, action: (BlockFace, NetworkNode) -> Unit)

Iterates over all NetworkNodes connected to node using networkType, calling action for each connection. The action parameters describe through wich BlockFace the NetworkNode is connected.

Link copied to clipboard
inline suspend fun forEachNetwork(bridge: NetworkBridge, action: (NetworkType<*>, ProtoNetwork<*>) -> Unit)

Iterates over all networks of bridge, calling action for each network.

inline suspend fun forEachNetwork(endPoint: NetworkEndPoint, action: (NetworkType<*>, BlockFace, ProtoNetwork<*>) -> Unit)

Iterates over all networks of endPoint, calling action for each network. The action parameters describe with which NetworkType and through which BlockFace the endPoint is connected to the given ProtoNetwork.

inline suspend fun <T : Network<T>> forEachNetwork(endPoint: NetworkEndPoint, networkType: NetworkType<T>, action: (BlockFace, ProtoNetwork<T>) -> Unit)

Iterates over all networkType networks of endPoint, calling action for each network. The action parameters describe through which BlockFace the endPoint is connected to the given ProtoNetwork.

Link copied to clipboard
suspend fun getAllowedFaces(bridge: NetworkBridge, type: NetworkType<*>): Set<BlockFace>

Gets a set of allowed BlockFaces with which bridge is allowed to connect to Networks of the given type, which are all supported faces if the NetworkBridge supports the NetworkType.

fun getAllowedFaces(endPoint: NetworkEndPoint, type: NetworkType<*>): Set<BlockFace>

Computes a set of allowed BlockFaces with which endPoint is allowed to connect to Networks of the given type. Will be empty if the NetworkEndPoint does not contain all required holder types.

Link copied to clipboard

Gets the NetworkBridgeData for bridge, or throws an exception if there is no data.

Link copied to clipboard
suspend fun getBridgeFaces(bridge: NetworkBridge): MutableSet<BlockFace>

Gets the allowed faces for bridge.

Link copied to clipboard
suspend fun getConnectedNode(node: NetworkNode, face: BlockFace): NetworkNode?

Gets the NetworkNode connected to node at face, or null if there is no connection.

suspend fun getConnectedNode(node: NetworkNode, networkType: NetworkType<*>, face: BlockFace): NetworkNode?

Gets the NetworkNode connected to node at face using networkType, or null if there is no connection.

Link copied to clipboard
suspend fun getConnectedNodes(node: NetworkNode): Table<NetworkType<*>, BlockFace, NetworkNode>

Creates a table that describes using which NetworkType and BlockFace which NetworkNodes are connected to node.

Link copied to clipboard

Gets the NetworkEndPointData for endPoint, or throws an exception if there is no data.

Link copied to clipboard
fun getNearbyNodes(pos: BlockPos, faces: Set<BlockFace>): Map<BlockFace, NetworkNode>

Finds all nearby NetworkNodes of pos using the given faces.

Link copied to clipboard
suspend fun <T : Network<T>> getNetwork(bridge: NetworkBridge, networkType: NetworkType<T>): ProtoNetwork<T>?

Gets the network of bridge of networkType, or null if there is no connection.

suspend fun <T : Network<T>> getNetwork(endPoint: NetworkEndPoint, networkType: NetworkType<T>, face: BlockFace): ProtoNetwork<T>?

Gets the network of endPoint at face, or null if there is no connection.

Link copied to clipboard

Gets the network map of bridge.

suspend fun getNetworks(endPoint: NetworkEndPoint): Table<NetworkType<*>, BlockFace, UUID>

Gets the networks table of endPoint.

Link copied to clipboard

Gets the NetworkNodeData for pos, potentially loading the corresponding network region if necessary and throws an exception if there is no data.

Gets all network node data for the given pos.

Gets the NetworkNodeData for node, or throws an exception if there is no data.

Link copied to clipboard

Gets the supported network types for bridge.

Link copied to clipboard
suspend fun handleEndPointAllowedFacesChange(endPoint: NetworkEndPoint, networkType: NetworkType<*>, face: BlockFace)

Performs network connect/disconnect actions based on the new allowed faces of endPoint for networkType at face.

Link copied to clipboard
suspend fun hasConnection(node: NetworkNode, face: BlockFace): Boolean

Checks whether node has a connection at face.

suspend fun hasConnection(node: NetworkNode, networkType: NetworkType<*>, face: BlockFace): Boolean

Checks whether node has a connection at face using networkType.

Link copied to clipboard
operator fun minusAssign(node: NetworkNode)

Removes node from the network state.

Link copied to clipboard
operator fun plusAssign(networks: Iterable<ProtoNetwork<*>>)

Adds all networks to the network state.

operator fun plusAssign(network: ProtoNetwork<*>)

Adds network to the network state.

operator fun plusAssign(node: NetworkNode)

Adds node to the network state.

Link copied to clipboard
suspend fun removeConnection(node: NetworkNode, networkType: NetworkType<*>, face: BlockFace)

Forgets a connection of node at face using networkType.

Link copied to clipboard
suspend fun removeNetwork(bridge: NetworkBridge, networkType: NetworkType<*>)

Forgets the connection of bridge to the network of networkType.

suspend fun removeNetwork(endPoint: NetworkEndPoint, networkType: NetworkType<*>, faces: Iterable<BlockFace>)

Forgets the connection of endPoint to the network of networkType at all faces.

suspend fun removeNetwork(endPoint: NetworkEndPoint, networkType: NetworkType<*>, face: BlockFace)

Forgets the connection of endPoint to the network of networkType at face.

Link copied to clipboard
suspend fun removeNodeData(node: NetworkNode)

Removes the data for node.

Link copied to clipboard
suspend fun resolveNetwork(networkId: UUID): ProtoNetwork<*>

Resolves a network by its networkId, loading it from disk if necessary.

Link copied to clipboard
suspend fun resolveNode(pos: BlockPos): NetworkNode

Resolves a NetworkNode by its pos.

Link copied to clipboard
suspend fun setBridgeData(pos: BlockPos, data: NetworkBridgeData)

Sets data at pos.

Link copied to clipboard
suspend fun setConnection(node: NetworkNode, networkType: NetworkType<*>, face: BlockFace)

Remembers a connection of node at face using networkType.

Link copied to clipboard

Sets data at pos.

Link copied to clipboard
suspend fun setNetwork(bridge: NetworkBridge, network: ProtoNetwork<*>)

Remembers the connection of bridge to network under ProtoNetwork.type.

suspend fun setNetwork(endPoint: NetworkEndPoint, faces: Iterable<BlockFace>, network: ProtoNetwork<*>)

Remembers the connection of endPoint to network at all faces.

suspend fun setNetwork(endPoint: NetworkEndPoint, face: BlockFace, network: ProtoNetwork<*>)

Remembers the connection of endPoint to network at face.

Link copied to clipboard
fun unloadNetwork(network: ProtoNetwork<*>)

Unloads the network from the network state, but does not delete any data associated with it.