Download Fabric Flux — Minecraft Mods — MetaMods
Fabric Flux

Fabric Flux

Active

Downloads

0

Last update

4 years ago
Client
Libraries

Fabric Flux

Important: This modification is not part of Fabric. It is a third-party library that allows developers to create energy mods for the Fabric platform.

Fabric Flux (abbreviated as FF) is a library designed to implement an energy system in mods for the Fabric platform.

Battery

Battery crafting recipe Try using this battery on various entities.

How It Works

The system is based on two main concepts: containers and interfaces.

  • Flux Container is an object that provides access to interfaces. Some containers may require additional data for access. For example, an item will require an ItemStack to provide an interface.
  • Flux Interface is used to transfer energy between containers. Two interfaces are required to complete an energy transfer.

Recommendations for Developers

  • Every Item that accepts energy should implement IFluxContainer and always check in getFluxFor if the object type is ItemStack. Other object types are also supported.
  • Any BlockEntity can implement both IFlux and IFluxContainer. If a controller is implemented, the getFluxFor method should always check if the object type is Direction. Other object types are also supported.
  • If an interface simply does not accept input/output, it should return -1 instead of the energy amount (which cannot be less than 0). This should be checked before calculating energy.
  • DO NOT STORE Flux Interfaces, only containers. Some interfaces can be created anew by a controller. There are exceptions for items, such as charging/discharging a battery (Item must create a new interface because it cannot be stored in an item stack).
  • IFlux::to should be used to transfer energy. This method can be overridden.
  • The FluxBattery class is provided in the API as a basic interface.

Differences from Other Energy APIs

FF is slightly different from Forge Energy API. This modification has fewer methods to implement and is not capability-based (instead, it uses containers). There are no equivalents to canExtractEnergy/canReceiveEnergy, checking with extractFlux/receiveFlux(0, true) does the same thing, although it is not required.

Project members
Szeweq

Szeweq

Created: 28 Jan 2021

ID: 37142