Skip to content

Arbitrary custom circuits

Max M edited this page Jul 23, 2022 · 2 revisions

The capability used by circuits for connections is stored in com.Da_Technomancer.essentials.api.redstone.RedstoneUtil::REDSTONE_CAPABILITY. The circuit capability handler is com.Da_Technomancer.essentials.api.redstone.IRedstoneHandler.

The circuit system is based on the following model:

  • A circuit has a collection of 'sources' and 'dependents'. A source is another circuit whose output signal this circuit cares about. A dependent is another circuit which cares about this circuit's output signal. Each circuit is responsible for notifying all its dependents (using com.Da_Technomancer.essentials.api.redstone.IRedstoneHandler::notifyInputChange) when it changes output signal.
  • Circuits with only outputs or only inputs might not need to handle both sources and dependents; a circuit that outputs needs to handle dependents, while a circuit with inputs needs to handle sources.
  • The model is designed for storing the collection of sources and dependents in the form WeakReference<LazyOptional>; this prevents the circuit system from interfering with chunk unloading, and allows circuits to remove themselves from the network by invalidating the LazyOptional they returned from getCapability calls.
  • Wire circuits (and junctions, etc) don't store sources and dependents- they just act as intermediaries to pass com.Da_Technomancer.essentials.api.redstone.IRedstoneHandler::requestSrc and com.Da_Technomancer.essentials.api.redstone.IRedstoneHandler::findDependentscalls along. See com.Da_Technomancer.essentials.blocks.redstone.WireTileEntity for an example.
  • Wires can visually 'connect' to any Block that implements com.Da_Technomancer.essentials.api.redstone.IWireConnect.

If you want your custom circuit to be placeable by the Circuit Wrench, call com.Da_Technomancer.essentials.api.redstone.RedstoneUtil::registerCircuit at some point during registration.

Clone this wiki locally