Interface IIngredientComponentStorage<T,M>

Type Parameters:
T - The instance type.
M - The matching condition parameter, may be Void. Instances MUST properly implement the equals method.
All Superinterfaces:
Iterable<T>
All Known Subinterfaces:
IIngredientComponentStorageSlotted<T,M>
All Known Implementing Classes:
IngredientComponentStorageEmpty, IngredientComponentStorageSlottedEmpty, IngredientComponentStorageWrapperHandlerEnergyStorage.ComponentStorageWrapper, IngredientComponentStorageWrapperHandlerFluidStack.ComponentStorageWrapper, IngredientComponentStorageWrapperHandlerItemStack.ComponentStorageWrapper, IngredientComponentStorageWrapperHandlerItemStack.ComponentStorageWrapperCombined, IngredientComponentStorageWrapperHandlerItemStackSlotless.ComponentStorageWrapper

public interface IIngredientComponentStorage<T,M> extends Iterable<T>
A minimal storage for a type of ingredient component. By not taking into account slots, the storage provider instead of the consumer is responsible for providing an efficient insertion and extraction algorithm. The is interface defines no requirements on how instances must be stored internally. For example, an implementing storage could combine internally several instances together that are equal to each other and take the sum of their quantities. Note: The storage provider MUST ensure deterministic behaviour for extraction and insertion. For example, the three first returned ingredients hereafter must equal each other.
          ingredient1 = insert(myIngredient, true);
          ingredient2 = insert(myIngredient, true);
          ingredient3 = insert(myIngredient, false);
          ingredient4 = insert(myIngredient, true); // Can be different again
       
The same applies to extraction. This should not be used as a capability, instead the IIngredientComponentStorageHandler capability should be used, as this can hold storage for different ingredient components.
  • Method Summary

    Modifier and Type
    Method
    Description
    extract(long maxQuantity, boolean simulate)
    Extract any ingredient, but the given maximum amount from the storage.
    extract(T prototype, M matchCondition, boolean simulate)
    Extract an ingredient matching the given prototype from the storage.
     
    long
     
    insert(T ingredient, boolean simulate)
    Inserts an ingredient into the storage and return the remainder.
    Get all ingredients in this storage.
    iterator(T prototype, M matchCondition)
    Find all ingredients matching the given prototype from the storage.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • getComponent

      IngredientComponent<T,M> getComponent()
      Returns:
      The ingredient component type this storage applies to.
    • iterator

      Iterator<T> iterator()
      Get all ingredients in this storage.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      An iterator over all available ingredients in this storage.
    • iterator

      Iterator<T> iterator(@Nonnull T prototype, M matchCondition)
      Find 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.
      Parameters:
      prototype - The ingredient to search for.
      matchCondition - The flags to compare the given prototype by according to IngredientComponent.getMatcher().
      Returns:
      An iterator over ingredients that match the given prototype, which may potentially be empty.
    • getMaxQuantity

      long getMaxQuantity()
      Returns:
      The maximum allowed quantity over all instances.
    • insert

      T insert(@Nonnull T ingredient, boolean simulate)
      Inserts an ingredient into the storage and return the remainder. The ingredient should not be modified in this function!
      Parameters:
      ingredient - Ingredient to insert.
      simulate - If true, the insertion is only simulated.
      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

      T extract(@Nonnull T prototype, M matchCondition, boolean simulate)
      Extract 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 by IngredientComponent.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 by IngredientComponent.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.
      Parameters:
      prototype - The ingredient to search for.
      matchCondition - The flags to compare the given prototype by according to IngredientComponent.getMatcher().
      simulate - If true, the insertion is only simulated
      Returns:
      Ingredient extracted from the slot, must be IIngredientMatcher.getEmptyInstance(), if nothing can be extracted
    • extract

      T extract(long maxQuantity, boolean simulate)
      Extract any ingredient, but the given maximum amount from the storage.
      Parameters:
      maxQuantity - The maximum amount to extract.
      simulate - If true, the insertion is only simulated
      Returns:
      Ingredient extracted from the slot, must be IIngredientMatcher.getEmptyInstance(), if nothing can be extracted