Signal is an API for adding redstone-like blocks.
While the Signal API does not add any tools for adding custom blocks in general, it abstracts the concept of redstone power and handles the interactions between different signal types.
If you wish to use the signal API for your own custom redstone-like blocks, you can add it as a dependency to your project.
- In
build.gradle
add the following to therepositories { }
section:
repositories {
...
maven {
url "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
}
- In
build.gradle
add the following to thedependencies { }
section:
dependencies {
...
modImplementation "maven.modrinth:signal:${project.signal_version}"
}
- Define the version of Signal you are using in
gradle.properties
, for example:
signal_version=mc1.19-1.0.0
-
If you wish to create your own custom signal and/or wire types, you should bootstrap them in your mod's initializer. Custom signal types can be registered through
SignalTypes#register
while custom wire types can be registered throughWireTypes#register
. -
A block's signal behavior is controlled by implementing methods from the
SignalBlockBehavior
interface. Signal source blocks should implement theisSignalSource
method, analog signal source blocks should implement theisAnalogSignalSource
method, signal consumer blocks should implement theisSignalConsumer
method, custom signal conductors should implement theisSignalConductor
method (by default vanilla redstone conductors will conduct signals of any type), and custom wire blocks should implement theisWire
method. -
Signal type equality should be checked through the
SignalType#is
method, this is to allow the use ofSignalTypes.ANY
to capture any and all signal types. -
Wire type equality should be checked through the
WireType#is
method, this is to allow the use ofWireTypes.ANY
to capture any and all wire types. -
If your signal source block only emits one type of signal, you can implement the
BasicSignalSource
interface to offload the work of dealing with signal types. Similarly, theBasicAnalogSignalSource
,BasicSignalConsumer
, andBasicWire
interfaces can be used for custom analog signal source blocks, signal consumer blocks, and wire blocks respectively. -
All of the vanilla methods for querying emitted and received power are deprecated, and the methods declared in
SignalLevel
should be used instead. If your block implements theBasicSignalConsumer
interface, you can call the helper methods it defines to offload the work of dealing with signal types.