Fabric API

Fabric API

106M Downloads

Transfer API base implementations

Technici4n opened this issue ยท 0 comments

commented

The purpose of this issue is to collect a few helpers that the community could make use of, so I can PR them to the transfer API in a few days.
I will keep this list updated, please let me know if you would like more helpers.

  • simulate default implementations for insert and extract. This is easily done and quite convenient:
default long simulateExtract(T resource, long maxAmount, @Nullable TransactionContext transaction) {
    try (Transaction simulateTransaction = Transaction.openNested(transaction)) {
        return extract(resource, maxAmount, simulateTransaction);
    }
}
  • base implementation for "continuous" fluid-containing items. Items that could make use of this include MI tanks, jetpacks and diesel tools; Industrial Revolution tanks and jetpack; probably many others.
  • PlayerInventoryStorage: add offer and drop functions, and change offerOrDrop to use those.
  • FilteringStorage: new class that delegates to another storage, but after checking canInsert(T) and canExtract(T).