Class IngredientComponentStorageWrapperHandlerResourceHandler.ComponentStorageWrapper<R extends net.neoforged.neoforge.transfer.resource.Resource,T,M>
java.lang.Object
org.cyclops.commoncapabilities.ingredient.storage.IngredientComponentStorageWrapperHandlerResourceHandler.ComponentStorageWrapper<R,T,M>
- All Implemented Interfaces:
Iterable<T>,IIngredientComponentStorage<T,,M> IIngredientComponentStorageSlotted<T,M>
- Direct Known Subclasses:
IngredientComponentStorageWrapperHandlerItemStack.ComponentStorageWrapperCombined
- Enclosing class:
IngredientComponentStorageWrapperHandlerResourceHandler<C,R extends net.neoforged.neoforge.transfer.resource.Resource, T, M>
public static class IngredientComponentStorageWrapperHandlerResourceHandler.ComponentStorageWrapper<R extends net.neoforged.neoforge.transfer.resource.Resource,T,M>
extends Object
implements IIngredientComponentStorageSlotted<T,M>
-
Constructor Summary
ConstructorsConstructorDescriptionComponentStorageWrapper(IngredientComponent<T, M> ingredientComponent, net.neoforged.neoforge.transfer.ResourceHandler<R> storage, IResourceConverter<R, T> resourceConverter) -
Method Summary
Modifier and TypeMethodDescriptionextract(int slot, long maxQuantity, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Extract the at most the given quantity from the ingredient from the given slot in the storage.extract(long maxQuantity, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Extract any ingredient, but the given maximum amount from the storage.extract(T prototype, M matchFlags, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Extract an ingredient matching the given prototype from the storage.protected TfinalizeExtractionForAmount(T instancePrototype, org.apache.commons.lang3.tuple.Pair<org.cyclops.cyclopscore.datastructure.Wrapper<Integer>, List<Integer>> value, int requiredQuantity, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) longlonggetMaxQuantity(int slot) Get the maximum allowed quantity in the given slot.getSlotContents(int slot) Get the ingredient that is contained in the given slot.intgetSlots()insert(int slot, T ingredient, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Inserts an ingredient into the storage in the given slot and return the remainder.Inserts an ingredient into the storage and return the remainder.iterator()Get all ingredients in this storage.Find all ingredients matching the given prototype from the storage.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage
extract, extract, insertMethods inherited from interface org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorageSlotted
extract, insertMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ComponentStorageWrapper
public ComponentStorageWrapper(IngredientComponent<T, M> ingredientComponent, net.neoforged.neoforge.transfer.ResourceHandler<R> storage, IResourceConverter<R, T> resourceConverter)
-
-
Method Details
-
getComponent
- Specified by:
getComponentin interfaceIIngredientComponentStorage<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Returns:
- The ingredient component type this storage applies to.
-
iterator
Description copied from interface:IIngredientComponentStorageGet all ingredients in this storage.- Specified by:
iteratorin interfaceIIngredientComponentStorage<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Specified by:
iteratorin interfaceIterable<R extends net.neoforged.neoforge.transfer.resource.Resource>- Returns:
- An iterator over all available ingredients in this storage.
-
iterator
Description copied from interface:IIngredientComponentStorageFind all ingredients matching the given prototype from the storage. Calling this method will not modify the storage in any way. Results from this method MUST NOT be modified.- Specified by:
iteratorin interfaceIIngredientComponentStorage<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Parameters:
prototype- The ingredient to search for.matchFlags- The flags to compare the given prototype by according toIngredientComponent.getMatcher().- Returns:
- An iterator over ingredients that match the given prototype, which may potentially be empty.
-
getMaxQuantity
public long getMaxQuantity()- Specified by:
getMaxQuantityin interfaceIIngredientComponentStorage<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Returns:
- The maximum allowed quantity over all instances.
-
insert
public T insert(@Nonnull T ingredient, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Description copied from interface:IIngredientComponentStorageInserts an ingredient into the storage and return the remainder. The ingredient should not be modified in this function!- Specified by:
insertin interfaceIIngredientComponentStorage<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Parameters:
ingredient- Ingredient to insert.transaction- The transaction context.- Returns:
- The remaining ingredient that was not inserted (if the entire ingredient is accepted,
then return
IIngredientMatcher.getEmptyInstance()). May be the same as the input ingredient if unchanged, otherwise a new ingredient.
-
extract
public T extract(@Nonnull T prototype, M matchFlags, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Description copied from interface:IIngredientComponentStorageExtract an ingredient matching the given prototype from the storage. Note that only the extracted ingredient must match the prototype under the given condition. Internally, ingredients can be combined and matched in any way. For example, an exact match could be produced by combining several ingredients. If the primary quantifier (as identified byIngredientComponent.getPrimaryQuantifier()) IS NOT part of the match condition, then the quantity of the given prototype MUST be interpreted as the maximum quantity that must be extracted. If the primary quantifier (as identified byIngredientComponent.getPrimaryQuantifier()) IS part of the match condition, then the quantity of the given prototype MUST be interpreted as the exact quantity that must be extracted. If the storage has a HIGHER OR EQUAL available quantity, then the storage MUST allow the given quantity to be extracted. If the storage on the other hand has a LOWER available quantity, then extraction is not allowed.- Specified by:
extractin interfaceIIngredientComponentStorage<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Parameters:
prototype- The ingredient to search for.matchFlags- The flags to compare the given prototype by according toIngredientComponent.getMatcher().transaction- The transaction context.- Returns:
- Ingredient extracted from the slot, must be
IIngredientMatcher.getEmptyInstance(), if nothing can be extracted
-
finalizeExtractionForAmount
-
extract
public T extract(long maxQuantity, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Description copied from interface:IIngredientComponentStorageExtract any ingredient, but the given maximum amount from the storage.- Specified by:
extractin interfaceIIngredientComponentStorage<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Parameters:
maxQuantity- The maximum amount to extract.transaction- The transaction context.- Returns:
- Ingredient extracted from the slot, must be
IIngredientMatcher.getEmptyInstance(), if nothing can be extracted
-
getSlots
public int getSlots()- Specified by:
getSlotsin interfaceIIngredientComponentStorageSlotted<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Returns:
- The number of available slots.
-
getSlotContents
Description copied from interface:IIngredientComponentStorageSlottedGet the ingredient that is contained in the given slot. Note: The returned ingredient MUST NOT not be modified by the caller.- Specified by:
getSlotContentsin interfaceIIngredientComponentStorageSlotted<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Parameters:
slot- A slot number.- Returns:
- The contained ingredient.
-
getMaxQuantity
public long getMaxQuantity(int slot) Description copied from interface:IIngredientComponentStorageSlottedGet the maximum allowed quantity in the given slot.- Specified by:
getMaxQuantityin interfaceIIngredientComponentStorageSlotted<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Parameters:
slot- A slot number.- Returns:
- The maximum allowed in the given slot.
-
insert
public T insert(int slot, @Nonnull T ingredient, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Description copied from interface:IIngredientComponentStorageSlottedInserts an ingredient into the storage in the given slot and return the remainder. The ingredient should not be modified in this function!- Specified by:
insertin interfaceIIngredientComponentStorageSlotted<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Parameters:
slot- A slot number to insert to.ingredient- Ingredient to insert.transaction- The transaction context.- Returns:
- The remaining ingredient that was not inserted (if the entire ingredient is accepted,
then return
IIngredientMatcher.getEmptyInstance()). May be the same as the input ingredient if unchanged, otherwise a new ingredient.
-
extract
public T extract(int slot, long maxQuantity, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction) Description copied from interface:IIngredientComponentStorageSlottedExtract the at most the given quantity from the ingredient from the given slot in the storage.- Specified by:
extractin interfaceIIngredientComponentStorageSlotted<R extends net.neoforged.neoforge.transfer.resource.Resource,T> - Parameters:
slot- A slot number to extract from.maxQuantity- The maximum amount to extract.transaction- The transaction context.- Returns:
- Ingredient extracted from the slot, must be
IIngredientMatcher.getEmptyInstance(), if nothing can be extracted
-