Interface StorageView<T>
- Type Parameters:
T
- The type of the stored resource. Experimental feature, we reserve the right to remove or change it without further notice. The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
- All Known Subinterfaces:
SingleSlotStorage<T>
- All Known Implementing Classes:
BlankVariantView
,FullItemFluidStorage
,SingleFluidStorage
,SingleStackStorage
,SingleVariantItemStorage
,SingleVariantStorage
@Experimental
public interface StorageView<T>
A view of a single stored resource in a
Storage
, for use with Storage.iterator(net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext)
or Storage.exactView(net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext, T)
.
A view is always tied to a specific transaction, and should not be accessed outside of it.
-
Method Summary
Modifier and TypeMethodDescriptionlong
extract
(T resource, long maxAmount, TransactionContext transaction) Try to extract a resource from this view.long
long
boolean
-
Method Details
-
extract
Try to extract a resource from this view.- Returns:
- The amount that was extracted.
-
isResourceBlank
boolean isResourceBlank()Returntrue
if thegetResource()
contained in this storage view is blank, orfalse
otherwise.This function is mostly useful when dealing with storages of arbitrary types. For transfer variant storages, this should always be equivalent to
getResource().isBlank()
. -
getResource
T getResource()- Returns:
- The resource stored in this view. May not be blank if
isResourceBlank()
isfalse
.
-
getAmount
long getAmount()- Returns:
- The amount of
getResource()
stored in this view.
-
getCapacity
long getCapacity()- Returns:
- The total amount of
getResource()
that could be stored in this view, or an estimate of the number of resources that could be stored if this view has a blank resource.
-