Interface SingleSlotStorage<T>

Type Parameters:
T - The type of the stored resource.
All Superinterfaces:
Iterable<StorageView<T>>, SlottedStorage<T>, Storage<T>, StorageView<T>
All Known Implementing Classes:
FullItemFluidStorage, SingleFluidStorage, SingleItemStorage, SingleStackStorage, SingleVariantItemStorage, SingleVariantStorage

public interface SingleSlotStorage<T> extends SlottedStorage<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()
      Description copied from interface: Storage
      Iterate through the contents of this storage. 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.

      Storage.insert(T, long, TransactionContext) and Storage.extract(T, long, 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.

      If a modification is made to the storage during iteration, the iterator might become invalid at the end of the outermost transaction. In particular, if multiple storage views are extracted from, the entire iteration should be wrapped in a transaction.

      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface Storage<T>
      Returns:
      An iterator over the contents of this storage. Calling remove on the iterator is not allowed.
    • getSlotCount

      default int getSlotCount()
      Description copied from interface: SlottedStorage
      Retrieve the number of slots in this storage.
      Specified by:
      getSlotCount in interface SlottedStorage<T>
    • getSlot

      default SingleSlotStorage<T> getSlot(int slot)
      Description copied from interface: SlottedStorage
      Retrieve a specific slot of this storage.
      Specified by:
      getSlot in interface SlottedStorage<T>