Package net.commoble.exmachina.internal.mechanical

# Record Class MechanicalGraph

java.lang.Object
java.lang.Record
net.commoble.exmachina.internal.mechanical.MechanicalGraph

Record Components:
  `groupedNodes` - The graph's nodes grouped by parity and gear ratio and level
  `nodesInGraph` - all the nodes in the graph
  `baseVelocity` - double value of the angular velocity of the origin node of the graph (in signed radians per second, positive value indicates thumb points to positive end of the axis of rotation)

@Internal public record MechanicalGraph(Map<net.commoble.exmachina.internal.mechanical.MechanicalGraph.GearGroup,Map<net.minecraft.world.level.LevelAccessor,List<net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode>>> groupedNodes, Map<MechanicalGraphKey,net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode> nodesInGraph, double baseVelocity) extends Record
Represents a mechanical graph of connected nodes

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final record`
`MechanicalGraph.GearRatio`
Cached values for a gear fraction

## Constructor Summary

Constructors
Constructor
Description
`MechanicalGraph(Map<net.commoble.exmachina.internal.mechanical.MechanicalGraph.GearGroup,Map<net.minecraft.world.level.LevelAccessor,List<net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode>>> groupedNodes, Map<MechanicalGraphKey,net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode> nodesInGraph, double baseVelocity)`
Creates an instance of a `MechanicalGraph` record class.

## Method Summary

Modifier and Type
Method
Description
`double`
`baseVelocity()`
Returns the value of the `baseVelocity` record component.
`final boolean`
`equals(Object o)`
Indicates whether some other object is "equal to" this one.
`static MechanicalGraph`
`fromOriginNode(net.minecraft.world.level.LevelAccessor level, MechanicalGraphKey originKey, MechanicalNode originNode, Function<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>,net.minecraft.world.level.LevelAccessor> levelLookup, Function<net.minecraft.world.level.BlockGetter,Function<net.minecraft.core.BlockPos,MechanicalBlockState>> componentLookup, Map<org.apache.commons.lang3.math.Fraction,MechanicalGraph.GearRatio> gearCache)`
Constructs a MechanicalGraph from a given origin
`Map<net.commoble.exmachina.internal.mechanical.MechanicalGraph.GearGroup,Map<net.minecraft.world.level.LevelAccessor,List<net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode>>>`
`groupedNodes()`
Returns the value of the `groupedNodes` record component.
`final int`
`hashCode()`
Returns a hash code value for this object.
`Map<MechanicalGraphKey,net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode>`
`nodesInGraph()`
Returns the value of the `nodesInGraph` record component.
`final String`
`toString()`
Returns a string representation of this record class.
`void`
`updateListeners(Map<org.apache.commons.lang3.math.Fraction,MechanicalGraph.GearRatio> gearCache)`
Informs all mechanical update listeners of their new power and velocity values

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

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

## Constructor Details

### MechanicalGraph

public MechanicalGraph(Map<net.commoble.exmachina.internal.mechanical.MechanicalGraph.GearGroup,Map<net.minecraft.world.level.LevelAccessor,List<net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode>>> groupedNodes, Map<MechanicalGraphKey,net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode> nodesInGraph, double baseVelocity)
Creates an instance of a `MechanicalGraph` record class.

Parameters:
  `groupedNodes` - the value for the `groupedNodes` record component
  `nodesInGraph` - the value for the `nodesInGraph` record component
  `baseVelocity` - the value for the `baseVelocity` record component

## Method Details

### fromOriginNode

@Internal public static MechanicalGraph fromOriginNode(net.minecraft.world.level.LevelAccessor level, MechanicalGraphKey originKey, MechanicalNode originNode, Function<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>,net.minecraft.world.level.LevelAccessor> levelLookup, Function<net.minecraft.world.level.BlockGetter,Function<net.minecraft.core.BlockPos,MechanicalBlockState>> componentLookup, Map<org.apache.commons.lang3.math.Fraction,MechanicalGraph.GearRatio> gearCache)
Constructs a MechanicalGraph from a given origin

Parameters:
  `level` - LevelAccessor of the origin node
  `originKey` - MechanicalGraphKey describing the origin node's position
  `originNode` - MechanicalNode describing the properties of the origin node
  `levelLookup` - Function to determine the level of a node based on the node key's level key
  `componentLookup` - Function to perform cache lookups for mechanical components by position
  `gearCache` - Map of cached gear values
Returns:
  MechanicalGraph constructed from the given origin

### updateListeners

public void updateListeners(Map<org.apache.commons.lang3.math.Fraction,MechanicalGraph.GearRatio> gearCache)
Informs all mechanical update listeners of their new power and velocity values

Parameters:
  `gearCache` - Map of cached gear values

### 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.

### groupedNodes

public Map<net.commoble.exmachina.internal.mechanical.MechanicalGraph.GearGroup,Map<net.minecraft.world.level.LevelAccessor,List<net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode>>> groupedNodes()
Returns the value of the `groupedNodes` record component.

Returns:
  the value of the `groupedNodes` record component

### nodesInGraph

public Map<MechanicalGraphKey,net.commoble.exmachina.internal.mechanical.MechanicalGraph.KeyedNode> nodesInGraph()
Returns the value of the `nodesInGraph` record component.

Returns:
  the value of the `nodesInGraph` record component

### baseVelocity

public double baseVelocity()
Returns the value of the `baseVelocity` record component.

Returns:
  the value of the `baseVelocity` record component