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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRootStorageImpl(MutableResourceList list, Set<RootStorageListener> listeners) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(RootStorageListener listener) Adds a listener.voidAdds a source and resorts all the sources.booleancontains(ResourceKey resource) longextract(ResourceKey resource, long amount, Action action, Actor actor) Extracts a resource from a storage.findTrackedResourceByActorType(ResourceKey resource, Class<? extends Actor> actorType) Finds the tracked resource by actor type.longget(ResourceKey resource) getAll()longbooleanChecks if a source is present.longinsert(ResourceKey resource, long amount, Action action, Actor actor) Inserts a resource into a storage.voidremoveListener(RootStorageListener listener) Removes a listener.voidremoveSource(Storage source) Removes a source .voidSorts the sources in the backing storage.
-
Field Details
-
storage
-
-
Constructor Details
-
RootStorageImpl
public RootStorageImpl() -
RootStorageImpl
-
RootStorageImpl
-
-
Method Details
-
sortSources
public void sortSources()Description copied from interface:RootStorageSorts the sources in the backing storage.- Specified by:
sortSourcesin interfaceRootStorage
-
addSource
Description copied from interface:RootStorageAdds a source and resorts all the sources.- Specified by:
addSourcein interfaceRootStorage- Parameters:
source- the source
-
removeSource
Description copied from interface:RootStorageRemoves a source .- Specified by:
removeSourcein interfaceRootStorage- Parameters:
source- the source
-
hasSource
Description copied from interface:RootStorageChecks if a source is present.- Specified by:
hasSourcein interfaceRootStorage- Parameters:
matcher- a predicate- Returns:
- whether the predicate matched
-
addListener
Description copied from interface:RootStorageAdds a listener.- Specified by:
addListenerin interfaceRootStorage- Parameters:
listener- the listener
-
removeListener
Description copied from interface:RootStorageRemoves a listener.- Specified by:
removeListenerin interfaceRootStorage- Parameters:
listener- the listener
-
get
- Specified by:
getin interfaceRootStorage- Parameters:
resource- the resource- Returns:
- the amount stored, or zero if not stored
-
contains
- Specified by:
containsin interfaceRootStorage- Parameters:
resource- the resource- Returns:
- whether the storage contains the resource
-
extract
Description copied from interface:ExtractableStorageExtracts a resource from a storage.- Specified by:
extractin interfaceExtractableStorage- Parameters:
resource- the resource, may not be nullamount- the amount, must be larger than 0action- the mode of extractionactor- the source- Returns:
- the amount extracted
-
insert
Description copied from interface:InsertableStorageInserts a resource into a storage.- Specified by:
insertin interfaceInsertableStorage- Parameters:
resource- the resource, may not be nullamount- the amount, must be larger than 0action- the mode of insertionactor- the source- Returns:
- the amount inserted
-
getAll
- Specified by:
getAllin interfaceStorageView- Returns:
- a list of resource amounts
-
getStored
public long getStored()- Specified by:
getStoredin interfaceStorageView- Returns:
- the amount stored
-
findTrackedResourceByActorType
public Optional<TrackedResource> findTrackedResourceByActorType(ResourceKey resource, Class<? extends Actor> actorType) Description copied from interface:TrackedStorageFinds the tracked resource by actor type.- Specified by:
findTrackedResourceByActorTypein interfaceTrackedStorage- Parameters:
resource- the resourceactorType- the actor type- Returns:
- the tracked resource modified by the given actor type, if present
-