Class IngredientComponentStorageWrapperHandlerItemStack.ComponentStorageWrapper

java.lang.Object
org.cyclops.commoncapabilities.ingredient.storage.IngredientComponentStorageWrapperHandlerItemStack.ComponentStorageWrapper
All Implemented Interfaces:
Iterable<net.minecraft.world.item.ItemStack>, IIngredientComponentStorage<net.minecraft.world.item.ItemStack,Integer>, IIngredientComponentStorageSlotted<net.minecraft.world.item.ItemStack,Integer>
Direct Known Subclasses:
IngredientComponentStorageWrapperHandlerItemStack.ComponentStorageWrapperCombined
Enclosing class:
IngredientComponentStorageWrapperHandlerItemStack<C>

public static class IngredientComponentStorageWrapperHandlerItemStack.ComponentStorageWrapper extends Object implements IIngredientComponentStorageSlotted<net.minecraft.world.item.ItemStack,Integer>
  • Constructor Summary

    Constructors
    Constructor
    Description
    ComponentStorageWrapper(IngredientComponent<net.minecraft.world.item.ItemStack,Integer> ingredientComponent, net.neoforged.neoforge.items.IItemHandler storage)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.ItemStack
    extract(int slot, long maxQuantity, boolean simulate)
    Extract the at most the given quantity from the ingredient from the given slot in the storage.
    net.minecraft.world.item.ItemStack
    extract(long maxQuantity, boolean simulate)
    Extract any ingredient, but the given maximum amount from the storage.
    net.minecraft.world.item.ItemStack
    extract(net.minecraft.world.item.ItemStack prototype, Integer matchFlags, boolean simulate)
    Extract an ingredient matching the given prototype from the storage.
    protected net.minecraft.world.item.ItemStack
    finalizeExtraction(net.minecraft.world.item.ItemStack instancePrototype, org.apache.commons.lang3.tuple.Pair<org.cyclops.cyclopscore.datastructure.Wrapper<Integer>,List<Integer>> value, int requiredQuantity, boolean simulate)
     
    IngredientComponent<net.minecraft.world.item.ItemStack,Integer>
     
    long
     
    long
    getMaxQuantity(int slot)
    Get the maximum allowed quantity in the given slot.
    net.minecraft.world.item.ItemStack
    getSlotContents(int slot)
    Get the ingredient that is contained in the given slot.
    int
     
    net.minecraft.world.item.ItemStack
    insert(int slot, net.minecraft.world.item.ItemStack ingredient, boolean simulate)
    Inserts an ingredient into the storage in the given slot and return the remainder.
    net.minecraft.world.item.ItemStack
    insert(net.minecraft.world.item.ItemStack ingredient, boolean simulate)
    Inserts an ingredient into the storage and return the remainder.
    Iterator<net.minecraft.world.item.ItemStack>
    Get all ingredients in this storage.
    Iterator<net.minecraft.world.item.ItemStack>
    iterator(net.minecraft.world.item.ItemStack prototype, Integer matchFlags)
    Find all ingredients matching the given prototype from the storage.
    protected net.minecraft.world.item.ItemStack
    storageExtractItem(int slot, int amount, boolean simulate)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • ComponentStorageWrapper

      public ComponentStorageWrapper(IngredientComponent<net.minecraft.world.item.ItemStack,Integer> ingredientComponent, net.neoforged.neoforge.items.IItemHandler storage)
  • Method Details

    • getComponent

      public IngredientComponent<net.minecraft.world.item.ItemStack,Integer> getComponent()
      Specified by:
      getComponent in interface IIngredientComponentStorage<net.minecraft.world.item.ItemStack,Integer>
      Returns:
      The ingredient component type this storage applies to.
    • iterator

      public Iterator<net.minecraft.world.item.ItemStack> iterator()
      Description copied from interface: IIngredientComponentStorage
      Get all ingredients in this storage.
      Specified by:
      iterator in interface IIngredientComponentStorage<net.minecraft.world.item.ItemStack,Integer>
      Specified by:
      iterator in interface Iterable<net.minecraft.world.item.ItemStack>
      Returns:
      An iterator over all available ingredients in this storage.
    • iterator

      public Iterator<net.minecraft.world.item.ItemStack> iterator(@Nonnull net.minecraft.world.item.ItemStack prototype, Integer matchFlags)
      Description copied from interface: IIngredientComponentStorage
      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.
      Specified by:
      iterator in interface IIngredientComponentStorage<net.minecraft.world.item.ItemStack,Integer>
      Parameters:
      prototype - The ingredient to search for.
      matchFlags - 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

      public long getMaxQuantity()
      Specified by:
      getMaxQuantity in interface IIngredientComponentStorage<net.minecraft.world.item.ItemStack,Integer>
      Returns:
      The maximum allowed quantity over all instances.
    • insert

      public net.minecraft.world.item.ItemStack insert(@Nonnull net.minecraft.world.item.ItemStack ingredient, boolean simulate)
      Description copied from interface: IIngredientComponentStorage
      Inserts an ingredient into the storage and return the remainder. The ingredient should not be modified in this function!
      Specified by:
      insert in interface IIngredientComponentStorage<net.minecraft.world.item.ItemStack,Integer>
      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

      public net.minecraft.world.item.ItemStack extract(@Nonnull net.minecraft.world.item.ItemStack prototype, Integer matchFlags, boolean simulate)
      Description copied from interface: IIngredientComponentStorage
      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.
      Specified by:
      extract in interface IIngredientComponentStorage<net.minecraft.world.item.ItemStack,Integer>
      Parameters:
      prototype - The ingredient to search for.
      matchFlags - 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
    • finalizeExtraction

      protected net.minecraft.world.item.ItemStack finalizeExtraction(net.minecraft.world.item.ItemStack instancePrototype, org.apache.commons.lang3.tuple.Pair<org.cyclops.cyclopscore.datastructure.Wrapper<Integer>,List<Integer>> value, int requiredQuantity, boolean simulate)
    • extract

      public net.minecraft.world.item.ItemStack extract(long maxQuantity, boolean simulate)
      Description copied from interface: IIngredientComponentStorage
      Extract any ingredient, but the given maximum amount from the storage.
      Specified by:
      extract in interface IIngredientComponentStorage<net.minecraft.world.item.ItemStack,Integer>
      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
    • getSlots

      public int getSlots()
      Specified by:
      getSlots in interface IIngredientComponentStorageSlotted<net.minecraft.world.item.ItemStack,Integer>
      Returns:
      The number of available slots.
    • getSlotContents

      public net.minecraft.world.item.ItemStack getSlotContents(int slot)
      Description copied from interface: IIngredientComponentStorageSlotted
      Get the ingredient that is contained in the given slot. Note: The returned ingredient MUST NOT not be modified by the caller.
      Specified by:
      getSlotContents in interface IIngredientComponentStorageSlotted<net.minecraft.world.item.ItemStack,Integer>
      Parameters:
      slot - A slot number.
      Returns:
      The contained ingredient.
    • getMaxQuantity

      public long getMaxQuantity(int slot)
      Description copied from interface: IIngredientComponentStorageSlotted
      Get the maximum allowed quantity in the given slot.
      Specified by:
      getMaxQuantity in interface IIngredientComponentStorageSlotted<net.minecraft.world.item.ItemStack,Integer>
      Parameters:
      slot - A slot number.
      Returns:
      The maximum allowed in the given slot.
    • insert

      public net.minecraft.world.item.ItemStack insert(int slot, @Nonnull net.minecraft.world.item.ItemStack ingredient, boolean simulate)
      Description copied from interface: IIngredientComponentStorageSlotted
      Inserts an ingredient into the storage in the given slot and return the remainder. The ingredient should not be modified in this function!
      Specified by:
      insert in interface IIngredientComponentStorageSlotted<net.minecraft.world.item.ItemStack,Integer>
      Parameters:
      slot - A slot number to insert to.
      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

      public net.minecraft.world.item.ItemStack extract(int slot, long maxQuantity, boolean simulate)
      Description copied from interface: IIngredientComponentStorageSlotted
      Extract the at most the given quantity from the ingredient from the given slot in the storage.
      Specified by:
      extract in interface IIngredientComponentStorageSlotted<net.minecraft.world.item.ItemStack,Integer>
      Parameters:
      slot - A slot number to extract from.
      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
    • storageExtractItem

      protected net.minecraft.world.item.ItemStack storageExtractItem(int slot, int amount, boolean simulate)