Package net.commoble.exmachina.internal.signal

# Record Class SignalGraph

java.lang.Object
java.lang.Record
net.commoble.exmachina.internal.signal.SignalGraph

Record Components:
  `nodesInGraph` - TransmissionNodes in this graph
  `blocksInGraph` - Set of BlockPos where signal transmitter nodes exist
  `receiverNodes` - List of Receiver listeners to notify of power updates after the graph update occurs
  `power` - The highest level of redstone power provided to this graph

@Internal public record SignalGraph(Map<NodePos,TransmissionNode> nodesInGraph, Map<net.minecraft.server.level.ServerLevel,Set<net.minecraft.core.BlockPos>> blocksInGraph, Map<net.minecraft.server.level.ServerLevel,List<Receiver>> receiverNodes, int power) extends Record
Represents a graph of connected signal nodes. SignalGraphs are used to determine which blocks are "wired" together, reads the highest level of redstone power accessible by that network, and updates all blocks in the network simultaneously. SignalGraphs are created at the end of a level tick within which a graph update is required, and discarded after updates occur.

## Constructor Summary

Constructors
Constructor
Description
`SignalGraph(Map<NodePos,TransmissionNode> nodesInGraph, Map<net.minecraft.server.level.ServerLevel,Set<net.minecraft.core.BlockPos>> blocksInGraph, Map<net.minecraft.server.level.ServerLevel,List<Receiver>> receiverNodes, int power)`
Creates an instance of a `SignalGraph` record class.

## Method Summary

Modifier and Type
Method
Description
`Map<net.minecraft.server.level.ServerLevel,Set<net.minecraft.core.BlockPos>>`
`blocksInGraph()`
Returns the value of the `blocksInGraph` record component.
`final boolean`
`equals(Object o)`
Indicates whether some other object is "equal to" this one.
`static SignalGraph`
`fromOriginNode(net.minecraft.server.level.ServerLevel level, NodePos originNodePos, TransmissionNode originNode, Map<net.minecraft.server.level.ServerLevel,Map<net.minecraft.core.BlockPos,StateWirer>> knownWirers, Map<PosReceiver,Set<Receiver>> unusedReceivers)`
Creates a SignalGraph at a given origin context
`final int`
`hashCode()`
Returns a hash code value for this object.
`boolean`
`hasTransmissionNode(NodePos nodePos)`
Returns whether this graph has a node at the given NodePos.
`static boolean`
`isBlockInAnyGraph(net.minecraft.server.level.ServerLevel serverLevel, net.minecraft.core.BlockPos pos, Collection<SignalGraph> graphs)`
Returns true if any of the provided graphs contain a transmission node at the given blockpos.
`Map<NodePos,TransmissionNode>`
`nodesInGraph()`
Returns the value of the `nodesInGraph` record component.
`int`
`power()`
Returns the value of the `power` record component.
`Map<net.minecraft.server.level.ServerLevel,List<Receiver>>`
`receiverNodes()`
Returns the value of the `receiverNodes` record component.
`final String`
`toString()`
Returns a string representation of this record class.
`Map<Face,SignalStrength>`
`updateListeners(net.minecraft.server.MinecraftServer server)`
Updates all SignalTransmitter and SignalReceiver listeners and determines which positions adjacent to the graph should receive neighbor updates.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### SignalGraph

public SignalGraph(Map<NodePos,TransmissionNode> nodesInGraph, Map<net.minecraft.server.level.ServerLevel,Set<net.minecraft.core.BlockPos>> blocksInGraph, Map<net.minecraft.server.level.ServerLevel,List<Receiver>> receiverNodes, int power)
Creates an instance of a `SignalGraph` record class.

Parameters:
  `nodesInGraph` - the value for the `nodesInGraph` record component
  `blocksInGraph` - the value for the `blocksInGraph` record component
  `receiverNodes` - the value for the `receiverNodes` record component
  `power` - the value for the `power` record component

## Method Details

### fromOriginNode

@Internal public static SignalGraph fromOriginNode(net.minecraft.server.level.ServerLevel level, NodePos originNodePos, TransmissionNode originNode, Map<net.minecraft.server.level.ServerLevel,Map<net.minecraft.core.BlockPos,StateWirer>> knownWirers, Map<PosReceiver,Set<Receiver>> unusedReceivers)
Creates a SignalGraph at a given origin context

Parameters:
  `level` - ServerLevel where the signal graph is being created
  `originNodePos` - NodePos (blockpos + direction + channel) of the origin node
  `originNode` - TransmissionNode at the origin nodepos
  `knownWirers` - StateWirer lookup cache
  `unusedReceivers` - Receiver listeners which were at requested graph update positions but have not been included in any signal graph yet during this graph update
Returns:
  SignalGraph created from the origin context

### hasTransmissionNode

@Internal public boolean hasTransmissionNode(NodePos nodePos)
Returns whether this graph has a node at the given NodePos.

Parameters:
  `nodePos` - NodePos to check whether this graph contains
Returns:
  whether this graph has a node at the given NodePos

### isBlockInAnyGraph

@Internal public static boolean isBlockInAnyGraph(net.minecraft.server.level.ServerLevel serverLevel, net.minecraft.core.BlockPos pos, Collection<SignalGraph> graphs)
Returns true if any of the provided graphs contain a transmission node at the given blockpos.

Parameters:
  `serverLevel` - ServerLevel to check position in
  `pos` - BlockPos to check whether any graph is containing
  `graphs` - SignalGraphs to check for the containment of the BlockPos
Returns:
  true if any of the provided graphs contain a transmission node at the given blockpos

### updateListeners

@Internal public Map<Face,SignalStrength> updateListeners(net.minecraft.server.MinecraftServer server)
Updates all SignalTransmitter and SignalReceiver listeners and determines which positions adjacent to the graph should receive neighbor updates. After all listeners in all graphs update, neighbor updates on blocks which are adjacent to but not within any signal graph occur.

Parameters:
  `server` - MinecraftServer where this signal graph is
Returns:
  Map of node Faces whose neighbors should be updated, e.g. (pos+west) = the block to the west of pos should receive a neighbor update

### toString

public final String toString()
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.

Specified by:
  `toString` in class `Record`
Returns:
  a string representation of this object

### hashCode

public final int hashCode()
Returns a hash code value for this object. The value is derived from the hash code of each of the record components.

Specified by:
  `hashCode` in class `Record`
Returns:
  a hash code value for this object

### equals

public final boolean equals(Object o)
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with `Objects::equals(Object,Object)`; primitive components are compared with '=='.

Specified by:
  `equals` in class `Record`
Parameters:
  `o` - the object with which to compare
Returns:
  `true` if this object is the same as the `o` argument; `false` otherwise.

### nodesInGraph

public Map<NodePos,TransmissionNode> nodesInGraph()
Returns the value of the `nodesInGraph` record component.

Returns:
  the value of the `nodesInGraph` record component

### blocksInGraph

public Map<net.minecraft.server.level.ServerLevel,Set<net.minecraft.core.BlockPos>> blocksInGraph()
Returns the value of the `blocksInGraph` record component.

Returns:
  the value of the `blocksInGraph` record component

### receiverNodes

public Map<net.minecraft.server.level.ServerLevel,List<Receiver>> receiverNodes()
Returns the value of the `receiverNodes` record component.

Returns:
  the value of the `receiverNodes` record component

### power

public int power()
Returns the value of the `power` record component.

Returns:
  the value of the `power` record component