Interface SlottedStorage<T>
- Type Parameters:
T
- The type of the stored resources. 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 Superinterfaces:
Iterable<StorageView<T>>
,Storage<T>
- All Known Subinterfaces:
InventoryStorage
,PlayerInventoryStorage
,SingleSlotStorage<T>
- All Known Implementing Classes:
CombinedSlottedStorage
,FullItemFluidStorage
,SingleFluidStorage
,SingleItemStorage
,SingleStackStorage
,SingleVariantItemStorage
,SingleVariantStorage
A
Storage
implementation made of indexed slots.
Please note that some storages may not implement this interface.
It is up to the storage implementation to decide whether to implement this interface or not.
Checking whether a storage is slotted can be done using instanceof
.
-
Method Summary
Modifier and TypeMethodDescriptiongetSlot
(int slot) Retrieve a specific slot of this storage.int
Retrieve the number of slots in this storage.default @UnmodifiableView List<SingleSlotStorage<T>>
getSlots()
Retrieve a list containing all the slots of this storage.Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.Storage
exactView, extract, getVersion, insert, iterator, nonEmptyIterator, nonEmptyViews, simulateExtract, simulateInsert, supportsExtraction, supportsInsertion
-
Method Details
-
getSlotCount
int getSlotCount()Retrieve the number of slots in this storage. -
getSlot
Retrieve a specific slot of this storage.- Throws:
IndexOutOfBoundsException
- If the slot index is out of bounds.
-
getSlots
Retrieve a list containing all the slots of this storage. The list must not be modified.This function can be used to interface with code that requires a slot list, for example
StorageUtil.insertStacking(java.util.List<? extends net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage<T>>, T, long, net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext)
orContainerItemContext.getAdditionalSlots()
.It is guaranteed that calling this function is fast. The default implementation returns a view over the storage that delegates to
getSlotCount()
andgetSlot(int)
.
-