/FastTransferLib

A fast energy api for the Fabric ecosystem.

Primary LanguageJavaCreative Commons Zero v1.0 UniversalCC0-1.0

DEPRECATED, USE THE NEW TECHREBORN ENERGY INSTEAD

TechReborn Energy was reworked recently and now offers an interface similar to FTL's, but a little closer to the Fabric Transfer API and embracing its transaction system. As such, FTL is deprecated in favor of TR Energy.

Fast Transfer Lib

A clean, simple and fast energy api for the Fabric ecosystem, with bidirectional compatibility with Tech Reborn Energy, based on the Fabric API Lookup module. Currently used by Industrial Revolution and Wireless Networks, with support from other mods as well.

Installation

repositories {
    maven {
        name = "Technici4n"
        url = "https://raw.githubusercontent.com/Technici4n/Technici4n-maven/master/"
        content {
            includeGroup "net.fabricmc.fabric-api" // until PR # is merged
            includeGroup "dev.technici4n"
        }
    }
    maven {
        name = "BuildCraft"
        url = "https://mod-buildcraft.com/maven"
    }
}

dependencies {
    modApi include("dev.technici4n:FastTransferLib:${project.ftl_version}")
}

In gradle.properties:

# put latest version here, check the commits!
ftl_version=/* ... */

Usage

EnergyIo is the core interface of FTL. Instances are queried and exposed through the SIDED and ITEM lookups in EnergyApi.

To register simple energy-containing items with an energy capacity and maximum insertion/extraction rates, SimpleItemEnergyIo#getProvider can be used. Simple energy-containing block entities can store a SimpleEnergyIo in a field and expose it via the SIDED lookup.

EnergyMovement provides a helper function to transfer energy between two EnergyIo's. EnergyPreconditions provides a few checks to fail-fast in case of bad API usage.

License

This library is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.