Interface SingleSlotStorage<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 Superinterfaces:
Storage<T>, StorageView<T>
All Known Implementing Classes:
FullItemFluidStorage, SingleFluidStorage, SingleStackStorage, SingleVariantItemStorage, SingleVariantStorage

@Experimental public interface SingleSlotStorage<T> extends Storage<T>, StorageView<T>
A storage that is also its only storage view. It can be used in APIs for storages that are wrappers around a single "slot", or for slightly more convenient implementation.
  • Method Details

    • iterator

      default Iterator<StorageView<T>> iterator(TransactionContext transaction)
      Description copied from interface: Storage
      Iterate through the contents of this storage, for the scope of the passed transaction. Every visited StorageView represents a stored resource and an amount. The iterator doesn't guarantee that a single resource only occurs once during an iteration. Calling remove on the iterator is not allowed.

      The returned iterator and any view it returns are only valid for the scope of to the passed transaction. They should not be used once that transaction is closed. Using the iterator or any view once the transaction is closed is undefined behavior.

      Storage.insert(T, long, net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext) and Storage.extract(T, long, net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext) may be called safely during iteration. Extractions should be visible to an open iterator, but insertions are not required to. In particular, inventories with a fixed amount of slots may wish to make insertions visible to iterators, but inventories with a dynamic or very large amount of slots should not do that to ensure timely termination of the iteration.

      Specified by:
      iterator in interface Storage<T>
      Parameters:
      transaction - The transaction to which the scope of the returned iterator is tied.
      Returns:
      An iterator over the contents of this storage. Calling remove on the iterator is not allowed.