Class RootStorageImpl

java.lang.Object
com.refinedmods.refinedstorage.api.storage.root.RootStorageImpl
All Implemented Interfaces:
ExtractableStorage, InsertableStorage, RootStorage, Storage, StorageView, TrackedStorage
Direct Known Subclasses:
com.refinedmods.refinedstorage.api.network.impl.storage.StorageNetworkComponentImpl

@API(status=STABLE, since="2.0.0-milestone.1.0") public class RootStorageImpl extends Object implements RootStorage
  • Field Details

  • Constructor Details

    • RootStorageImpl

      public RootStorageImpl()
    • RootStorageImpl

      public RootStorageImpl(ResourceList list)
  • Method Details

    • sortSources

      public void sortSources()
      Description copied from interface: RootStorage
      Sorts the sources in the backing storage.
      Specified by:
      sortSources in interface RootStorage
    • addSource

      public void addSource(Storage source)
      Description copied from interface: RootStorage
      Adds a source and resorts all the sources.
      Specified by:
      addSource in interface RootStorage
      Parameters:
      source - the source
    • removeSource

      public void removeSource(Storage source)
      Description copied from interface: RootStorage
      Removes a source .
      Specified by:
      removeSource in interface RootStorage
      Parameters:
      source - the source
    • hasSource

      public boolean hasSource(Predicate<Storage> matcher)
      Description copied from interface: RootStorage
      Checks if a source is present.
      Specified by:
      hasSource in interface RootStorage
      Parameters:
      matcher - a predicate
      Returns:
      whether the predicate matched
    • addListener

      public void addListener(ResourceListListener listener)
      Description copied from interface: RootStorage
      Adds a listener.
      Specified by:
      addListener in interface RootStorage
      Parameters:
      listener - the listener
    • removeListener

      public void removeListener(ResourceListListener listener)
      Description copied from interface: RootStorage
      Removes a listener.
      Specified by:
      removeListener in interface RootStorage
      Parameters:
      listener - the listener
    • get

      public long get(ResourceKey resource)
      Specified by:
      get in interface RootStorage
      Parameters:
      resource - the resource
      Returns:
      the amount stored, or zero if not stored
    • contains

      public boolean contains(ResourceKey resource)
      Specified by:
      contains in interface RootStorage
      Parameters:
      resource - the resource
      Returns:
      whether the storage contains the resource
    • extract

      public long extract(ResourceKey resource, long amount, Action action, Actor actor)
      Description copied from interface: ExtractableStorage
      Extracts a resource from a storage.
      Specified by:
      extract in interface ExtractableStorage
      Parameters:
      resource - the resource, may not be null
      amount - the amount, must be larger than 0
      action - the mode of extraction
      actor - the source
      Returns:
      the amount extracted
    • insert

      public long insert(ResourceKey resource, long amount, Action action, Actor actor)
      Description copied from interface: InsertableStorage
      Inserts a resource into a storage.
      Specified by:
      insert in interface InsertableStorage
      Parameters:
      resource - the resource, may not be null
      amount - the amount, must be larger than 0
      action - the mode of insertion
      actor - the source
      Returns:
      the amount inserted
    • getAll

      public Collection<ResourceAmount> getAll()
      Specified by:
      getAll in interface StorageView
      Returns:
      a list of resource amounts
    • getStored

      public long getStored()
      Specified by:
      getStored in interface StorageView
      Returns:
      the amount stored
    • findTrackedResourceByActorType

      public Optional<TrackedResource> findTrackedResourceByActorType(ResourceKey resource, Class<? extends Actor> actorType)
      Description copied from interface: TrackedStorage
      Finds the tracked resource by actor type.
      Specified by:
      findTrackedResourceByActorType in interface TrackedStorage
      Parameters:
      resource - the resource
      actorType - the actor type
      Returns:
      the tracked resource modified by the given actor type, if present