Class IngredientComponentStorageSlottedWrapped<T,M>
java.lang.Object
org.cyclops.cyclopscore.ingredient.storage.IngredientComponentStorageWrapped<T,M>
org.cyclops.cyclopscore.ingredient.storage.IngredientComponentStorageSlottedWrapped<T,M>
- Type Parameters:
T- The instance type.M- The matching condition parameter.
- All Implemented Interfaces:
Iterable<T>, IIngredientComponentStorage<T,M>, IIngredientComponentStorageSlotted<T, M>
public class IngredientComponentStorageSlottedWrapped<T,M>
extends IngredientComponentStorageWrapped<T,M>
implements IIngredientComponentStorageSlotted<T,M>
An ingredient storage wrapper.
-
Constructor Summary
ConstructorsConstructorDescriptionIngredientComponentStorageSlottedWrapped(IIngredientComponentStorageSlotted<T, M> ingredientComponentStorageSlotted, boolean iterate, boolean insert, boolean extract) -
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.protected IIngredientComponentStorageSlotted<T, M> longgetMaxQuantity(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.Methods inherited from class IngredientComponentStorageWrapped
extract, extract, getComponent, getMaxQuantity, insert, isExtract, isInsert, isRead, iterator, iteratorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IIngredientComponentStorage
extract, extract, extract, extract, getComponent, getMaxQuantity, insert, insert, iterator, iteratorMethods inherited from interface IIngredientComponentStorageSlotted
extract, insertMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
IngredientComponentStorageSlottedWrapped
public IngredientComponentStorageSlottedWrapped(IIngredientComponentStorageSlotted<T, M> ingredientComponentStorageSlotted, boolean iterate, boolean insert, boolean extract)
-
-
Method Details
-
getIngredientComponentStorage
- Overrides:
getIngredientComponentStoragein classIngredientComponentStorageWrapped<T,M>
-
getSlots
public int getSlots()- Specified by:
getSlotsin interfaceIIngredientComponentStorageSlotted<T,M> - 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<T,M> - 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<T,M> - 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<T,M> - 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<T,M> - 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
-