fabric/fabric-transfer-api-v1
2021-07-12 19:25:45 +01:00
..
src Fabric Transfer API: "fluid only" edition (#1356) 2021-07-12 18:28:33 +01:00
build.gradle Bump version 2021-07-12 19:25:45 +01:00
README.md Fabric Transfer API: "fluid only" edition (#1356) 2021-07-12 18:28:33 +01:00

Fabric Transfer API (v1)

This module provides common facilities for the transfer of fluids and other game resources.

Transactions

The Transaction system provides a scope that can be used to simulate any number of transfer operations, and then cancel or validate all of them at once. One can think of transactions as video game checkpoints. A more detailed explanation can be found in the class javadoc of Transaction. Every transfer operation requires a Transaction parameter. SnapshotParticipant is the reference implementation of a "participant", that is an object participating in a transaction.

Storages

A Storage<T> is any object that can store resources of type T. Its contents can be read, and resources can be inserted into it or extracted from it. StorageUtil provides a few helpful functions to work with Storages, for example to move resources between two Storages. The storage/base package provides a few helpers to accelerate implementation of Storage<T>.

Fluid transfer

A Storage<FluidVariant> is any object that can store fluids. It is just a Storage<T>, where T is FluidVariant, the immutable combination of a Fluid and additional NBT data. Instances can be accessed through the API lookups defined in FluidStorage.

Implementors of fluid inventories with a fixed number of "slots" or "tanks" can use SingleFluidStorage, and combine them with CombinedStorage.

The unit for fluid transfer is 1/81000ths of a bucket, also known as droplets. FluidConstants contains a few helpful constants to work with droplets.

Client-side Fluid variant rendering will use regular fluid rendering by default, ignoring the additional NBT data. Fluids that wish to render differently depending on the stored NBT data can register a FluidVariantRenderHandler.