Class CombinedResourceHandler
java.lang.Object
fr.robie.machineengine.api.transfer.storage.CombinedResourceHandler
- All Implemented Interfaces:
ResourceHandler
Several handlers seen as one, e.g. the slots of an inventory. Inserts fill parts that already
hold something first, then empty parts, in order.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongextract(@NotNull ResourceVariant variant, long maxAmount, @NotNull TransactionContext transaction) longinsert(@NotNull ResourceVariant variant, long maxAmount, @NotNull TransactionContext transaction) @NotNull List<ResourceHandler> parts()static @NotNull CombinedResourceHandlerslots(int count, long capacity) booleanboolean@NotNull List<StorageView> views()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ResourceHandler
amountOf
-
Constructor Details
-
CombinedResourceHandler
-
-
Method Details
-
slots
- Returns:
countslots ofcapacityeach
-
parts
-
insert
public long insert(@NotNull @NotNull ResourceVariant variant, long maxAmount, @NotNull @NotNull TransactionContext transaction) - Specified by:
insertin interfaceResourceHandler- Parameters:
maxAmount- the most to insert; must not be negative- Returns:
- how much was accepted, between 0 and
maxAmount
-
extract
public long extract(@NotNull @NotNull ResourceVariant variant, long maxAmount, @NotNull @NotNull TransactionContext transaction) - Specified by:
extractin interfaceResourceHandler- Parameters:
maxAmount- the most to extract; must not be negative- Returns:
- how much was removed, between 0 and
maxAmount
-
views
- Specified by:
viewsin interfaceResourceHandler- Returns:
- a snapshot of the current contents, one view per slot
-
supportsInsertion
public boolean supportsInsertion()- Specified by:
supportsInsertionin interfaceResourceHandler
-
supportsExtraction
public boolean supportsExtraction()- Specified by:
supportsExtractionin interfaceResourceHandler
-