Package net.commoble.exmachina.api

# Interface SignalReceiver

All Known Implementing Classes:
  `DefaultReceiver`

public interface SignalReceiver

A SignalReceiver is a signal graph node assignable to Blocks, which

- Can be connected to by the graph
- Will not connect to further graph nodes
- Can be notified of signal power updates

Unlike `SignalTransmitter`s, multiple SignalReceivers can exist at the same node position.

SignalReceivers can be assigned to blocks via the exmachina:signal_receiver block datamap:

     data/exmachina/data_maps/block/signal_receiver.json
     [
       "namespace:blockid": {
         "type": "namespace:receiver_type_id",
         // additional fields
       }
     ]

## Field Summary

Fields
Modifier and Type
Field
Description
`static final com.mojang.serialization.Codec<SignalReceiver>`
`CODEC`
Master dispatch codec for SignalReceivers

## Method Summary

Modifier and Type
Method
Description
`com.mojang.serialization.MapCodec<? extends SignalReceiver>`
`codec()`
Returns sub-codec for this receiver type registered via `ExMachinaRegistries.SIGNAL_RECEIVER_TYPE`.
`Collection<Receiver>`
`getAllReceivers(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos receiverPos, net.minecraft.world.level.block.state.BlockState receiverState, Channel channel)`
Retrieves all Receiver instances returnable by `getReceiverEndpoint(net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState,net.minecraft.core.Direction,net.commoble.exmachina.api.Face,net.commoble.exmachina.api.Channel)`
`@Nullable Receiver`
`getReceiverEndpoint(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos receiverPos, net.minecraft.world.level.block.state.BlockState receiverState, net.minecraft.core.Direction receiverSide, Face connectedFace, Channel channel)`
Provides Receiver functions to the grapher at a given position
`default void`
`resetUnusedReceivers(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos, Collection<Receiver> receivers)`
This method is invoked on a SignalReceiver when a graph update occurs where a SignalReceiver block is but not all of its receivers were connected to a graph.

## Field Details

### CODEC

static final com.mojang.serialization.Codec<SignalReceiver> CODEC
Master dispatch codec for SignalReceivers

## Method Details

### codec

com.mojang.serialization.MapCodec<? extends SignalReceiver> codec()
Returns sub-codec for this receiver type registered via `ExMachinaRegistries.SIGNAL_RECEIVER_TYPE`.

Returns:
  sub-codec for this receiver type registered via `ExMachinaRegistries.SIGNAL_RECEIVER_TYPE`

### getReceiverEndpoint

@Nullable @Nullable Receiver getReceiverEndpoint(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos receiverPos, net.minecraft.world.level.block.state.BlockState receiverState, net.minecraft.core.Direction receiverSide, Face connectedFace, Channel channel)
Provides Receiver functions to the grapher at a given position

Parameters:
  `level` - Level where the signal graph exists
  `receiverPos` - BlockPos where this receiver's block exists
  `receiverState` - BlockState of this receiver's block
  `receiverSide` - Direction of the face of the receiverpos where this receiver exists, e.g. down -> the bottom of receiverPos
  `connectedFace` - Face (pos+direction) of the graph node which is attempting to connect to this receiver
  `channel` - Channel this receiver is attempting to be reached on
Returns:
  Receiver function to invoke after the signal graph updates (or null if no receiver node exists for the given context)

### getAllReceivers

Collection<Receiver> getAllReceivers(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos receiverPos, net.minecraft.world.level.block.state.BlockState receiverState, Channel channel)
Retrieves all Receiver instances returnable by `getReceiverEndpoint(net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState,net.minecraft.core.Direction,net.commoble.exmachina.api.Face,net.commoble.exmachina.api.Channel)`

Parameters:
  `level` - Level where the signal graph exists
  `receiverPos` - BlockPos where this receiver's block exists
  `receiverState` - BlockState of this receiver's block
  `channel` - Channel this receiver is attempting to be reached on
Returns:
  Collection of all receiver functions that can conceivably be returned by `getReceiverEndpoint(net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState,net.minecraft.core.Direction,net.commoble.exmachina.api.Face,net.commoble.exmachina.api.Channel)`

### resetUnusedReceivers

default void resetUnusedReceivers(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos, Collection<Receiver> receivers)
This method is invoked on a SignalReceiver when a graph update occurs where a SignalReceiver block is but not all of its receivers were connected to a graph.

Parameters:
  `level` - Level where the signal graph exists
  `pos` - BlockPos where this receiver's block exists
  `receivers` - Collection of Receiver instances that are providable by the block at the given position, but were not part of any graph after a graph update occurs. This usually indicates that the receivers should be reset to signal power 0.