Transfer API base implementations
Technici4n opened this issue ยท 0 comments
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
andextract
. 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
: addoffer
anddrop
functions, and changeofferOrDrop
to use those. -
FilteringStorage
: new class that delegates to another storage, but after checkingcanInsert(T)
andcanExtract(T)
.