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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(ResourceListListener listener) Adds a listener.void
Adds a source and resorts all the sources.boolean
contains
(ResourceKey resource) long
extract
(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.long
get
(ResourceKey resource) getAll()
long
boolean
Checks if a source is present.long
insert
(ResourceKey resource, long amount, Action action, Actor actor) Inserts a resource into a storage.void
removeListener
(ResourceListListener listener) Removes a listener.void
removeSource
(Storage source) Removes a source .void
Sorts the sources in the backing storage.
-
Field Details
-
storage
-
-
Constructor Details
-
RootStorageImpl
public RootStorageImpl() -
RootStorageImpl
-
-
Method Details
-
sortSources
public void sortSources()Description copied from interface:RootStorage
Sorts the sources in the backing storage.- Specified by:
sortSources
in interfaceRootStorage
-
addSource
Description copied from interface:RootStorage
Adds a source and resorts all the sources.- Specified by:
addSource
in interfaceRootStorage
- Parameters:
source
- the source
-
removeSource
Description copied from interface:RootStorage
Removes a source .- Specified by:
removeSource
in interfaceRootStorage
- Parameters:
source
- the source
-
hasSource
Description copied from interface:RootStorage
Checks if a source is present.- Specified by:
hasSource
in interfaceRootStorage
- Parameters:
matcher
- a predicate- Returns:
- whether the predicate matched
-
addListener
Description copied from interface:RootStorage
Adds a listener.- Specified by:
addListener
in interfaceRootStorage
- Parameters:
listener
- the listener
-
removeListener
Description copied from interface:RootStorage
Removes a listener.- Specified by:
removeListener
in interfaceRootStorage
- Parameters:
listener
- the listener
-
get
- Specified by:
get
in interfaceRootStorage
- Parameters:
resource
- the resource- Returns:
- the amount stored, or zero if not stored
-
contains
- Specified by:
contains
in interfaceRootStorage
- Parameters:
resource
- the resource- Returns:
- whether the storage contains the resource
-
extract
Description copied from interface:ExtractableStorage
Extracts a resource from a storage.- Specified by:
extract
in 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:InsertableStorage
Inserts a resource into a storage.- Specified by:
insert
in 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:
getAll
in interfaceStorageView
- Returns:
- a list of resource amounts
-
getStored
public long getStored()- Specified by:
getStored
in interfaceStorageView
- 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 interfaceTrackedStorage
- Parameters:
resource
- the resourceactorType
- the actor type- Returns:
- the tracked resource modified by the given actor type, if present
-