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.gradleadd the following to therepositories { }section:
repositories {
...
maven {
url "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
}
- In
build.gradleadd 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#registerwhile custom wire types can be registered throughWireTypes#register. -
A block's signal behavior is controlled by implementing methods from the
SignalBlockBehaviorinterface. Signal source blocks should implement theisSignalSourcemethod, analog signal source blocks should implement theisAnalogSignalSourcemethod, signal consumer blocks should implement theisSignalConsumermethod, custom signal conductors should implement theisSignalConductormethod (by default vanilla redstone conductors will conduct signals of any type), and custom wire blocks should implement theisWiremethod. -
Signal type equality should be checked through the
SignalType#ismethod, this is to allow the use ofSignalTypes.ANYto capture any and all signal types. -
Wire type equality should be checked through the
WireType#ismethod, this is to allow the use ofWireTypes.ANYto capture any and all wire types. -
If your signal source block only emits one type of signal, you can implement the
BasicSignalSourceinterface to offload the work of dealing with signal types. Similarly, theBasicAnalogSignalSource,BasicSignalConsumer, andBasicWireinterfaces 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
SignalLevelshould be used instead. If your block implements theBasicSignalConsumerinterface, you can call the helper methods it defines to offload the work of dealing with signal types.