Interface SlottedStorage<T>
- Type Parameters:
T
- The type of the stored resources.
- 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
extract, getVersion, insert, iterator, nonEmptyIterator, nonEmptyViews, 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)
.
-