Skip to content

API Reference

Joseph Bettendorff edited this page Nov 14, 2024 · 10 revisions

More Red adds several APIs for adding additional mod compatibility.

Contents
  1. Using the API
  2. Capabilities
    1. Channeled Power Supplier
  3. Block Behaviours
    1. Expanded Power Supplier
    2. Wire Connector
  4. History

Using the API

As of 1.21, neoforge mods can use More Red's API in a dev environment by including the following in their build.gradle

repositories {
	// java repo to get More Red jars from
	maven { url "https://maven.commoble.net" }
}

dependencies {
	implementation "commoble.morered:${morered_branch}:${morered_version}")
}

Where

  • ${morered_branch} is e.g. morered-1.21
  • ${morered_version} is e.g. 6.0.0.0

API classes are in the commoble.morered.api package and are considered stable until an increment to the first or second digit in the version number, e.g. if you compile against More Red 6.0.0.0, apis will not change until at least 6.1.0.0.

Mods can have soft dependencies on More Red and avoid classloading possibly-not-present More Red classes by creating and using a proxy class:

if (ModList.get().isLoaded("morered"))
{
	YourMoreRedProxy.doMoreRedStuff();
}

Capabilities

Channeled Power Supplier

The ChanneledPowerSupplier capability interface is used by the block entities of Bundled Network Cables, Colored Network Cables, and Bundled Cable Relay Plates to indicate that they are capable of supplying 16-channel power.

The Capability instance is available in the API via MoreRedAPI.CHANNELED_POWER_CAPABILITY. No default instance or storage is supplied; mods wishing to use implementations of the ChanneledPowerSupplier interface must implement their own.

Block Behaviours

More Red defines several "block behaviours", which mods may define by registering behaviours to specific Block instances.

Expanded Power Supplier

The ExpandedPowerSupplier interface indicates that a block can supply redstone power in the [0,31] range inclusively (rather than the [0,15] range that blocks normally use); this is used by Red Alloy Wires and Colored Network Cables to query power from blocks.

The registry for this block behaviour can be retrieved via MoreRedAPI.getExpandedPowerRegistry(). This map is mutable and threadsafe during modloading, and converted to an immutable map when modloading concludes. It is recommended to register blocks to this map in FMLCommonSetupEvent.

A default Expanded Power Supplier is available for blocks not present in the map via MoreRedAPI.getDefaultExpandedPowerSupplier(), which simply returns twice the normal weak signal output of a given blockstate. This currently is NOT returned when the behaviour registry is queried for blocks not present in it.

Wire Connector

The WireConnector interface indicates certain types of wires and cables are allowed to connect to the block the WireConnector is assigned to.

There are two registries for Wire Connectors; MoreRedAPI.getWireConnectabilityRegistry() retrieves the registry used by Red Alloy Wires, while MoreRedAPI.getCableConnectabilityRegistry() retrieves the registry used by Bundled Network Cables. Colored Network Cables will connect to blocks that are registered to either registry. These maps are mutable and threadsafe during modloading, and converted to immutable maps when modloading concludes. It is recommended to register blocks to these maps in FMLCommonSetupEvent.

A default wire connector (for the kind used by red alloy wires) is available via MoreRedAPI.getDefaultWireConnector(), which returns true if the given blockstate allows redstone dust to connect to it, and whose block support shape fills the given side of the block sufficiently for a 2x2 pixel wire to connect to it.

A default cable connector also exists via MoreRedAPI.getDefaultCableConnector(), but currently always returns false.

If a block's wire/cable connector function returns true, then a wire or cable will be able to connect to that block orthagonally, rendering a wire model extending from a wire node to the block, and sharing power with the block. Wire/cable connectors are not required for wires to share power with a block whose face a wire node is directly attached to.

Wire Connectors
Four wires connecting orthagonally to redstone blocks, which use the default connector behaviour. The wires are able to connect because the redstone blocks allow redstone dust to connect to them and are sufficiently thick.

History

Version Changelog
1.21-6.0.0.0 Migrated to neoforge. Dependers should no longer use fg.deobf as neoforge does not reobf mods.
1.19.2? Removed API jar, only one jar is provided
1.16.5-2.1.0.0 Added API

Clone this wiki locally