Class SlotlessItemHandlerWrapper

java.lang.Object
org.cyclops.commoncapabilities.api.capability.itemhandler.SlotlessItemHandlerWrapper
All Implemented Interfaces:
ISlotlessItemHandler
Direct Known Subclasses:
IndexedSlotlessItemHandlerWrapper

public abstract class SlotlessItemHandlerWrapper extends Object implements ISlotlessItemHandler
An abstract ISlotlessItemHandler wrapper around an IItemHandler.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final net.neoforged.neoforge.items.IItemHandler
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    SlotlessItemHandlerWrapper(net.neoforged.neoforge.items.IItemHandler itemHandler)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.ItemStack
    extractItem(int amount, boolean simulate)
    Extracts an ItemStack from the item handler.
    net.minecraft.world.item.ItemStack
    extractItem(net.minecraft.world.item.ItemStack matchStack, int matchFlags, boolean simulate)
    Extract an ItemStack matching the given stack from the item handler.
    Iterator<net.minecraft.world.item.ItemStack>
    findItems(net.minecraft.world.item.ItemStack stack, int matchFlags)
    Find all ItemStacks matching the given stack from the item handler.
    protected abstract PrimitiveIterator.OfInt
     
    Iterator<net.minecraft.world.item.ItemStack>
     
    int
    Retrieves the total item stack count allowed to exist in this handler.
    protected abstract PrimitiveIterator.OfInt
     
    protected abstract PrimitiveIterator.OfInt
    getNonEmptySlotsWithItemStack(net.minecraft.world.item.ItemStack itemStack, int matchFlags)
    Get the slots in which the given ItemStack is present according to the given match flags.
    protected abstract PrimitiveIterator.OfInt
    getNonFullSlotsWithItemStack(net.minecraft.world.item.ItemStack itemStack, int matchFlags)
    Get the slots in which the given ItemStack is present according to the given match flags.
    protected abstract PrimitiveIterator.OfInt
    getSlotsWithItemStack(net.minecraft.world.item.ItemStack itemStack, int matchFlags)
    Get an iterator over all slots in which the given ItemStack is present according to the given match flags.
    net.minecraft.world.item.ItemStack
    insertItem(net.minecraft.world.item.ItemStack stack, boolean simulate)
    Inserts an ItemStack into the item handler and return the remainder.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • itemHandler

      protected final net.neoforged.neoforge.items.IItemHandler itemHandler
  • Constructor Details

    • SlotlessItemHandlerWrapper

      public SlotlessItemHandlerWrapper(net.neoforged.neoforge.items.IItemHandler itemHandler)
  • Method Details

    • getNonFullSlotsWithItemStack

      protected abstract PrimitiveIterator.OfInt getNonFullSlotsWithItemStack(@Nonnull net.minecraft.world.item.ItemStack itemStack, int matchFlags)
      Get the slots in which the given ItemStack is present according to the given match flags. Stacksize of the item in the slot must be below the maximum stack size, so there must be room left in the slot.
      Parameters:
      itemStack - The ItemStack to look for.
      matchFlags - The flags to match the given ItemStack by.
      Returns:
      The slots in which the ItemStack are present.
    • getNonEmptySlotsWithItemStack

      protected abstract PrimitiveIterator.OfInt getNonEmptySlotsWithItemStack(@Nonnull net.minecraft.world.item.ItemStack itemStack, int matchFlags)
      Get the slots in which the given ItemStack is present according to the given match flags. Stacksize of the item in the slot must be larger than zero.
      Parameters:
      itemStack - The ItemStack to look for.
      matchFlags - The flags to match the given ItemStack by.
      Returns:
      The slots in which the ItemStack are present.
    • getSlotsWithItemStack

      protected abstract PrimitiveIterator.OfInt getSlotsWithItemStack(@Nonnull net.minecraft.world.item.ItemStack itemStack, int matchFlags)
      Get an iterator over all slots in which the given ItemStack is present according to the given match flags. Stacksize of the item in the slot must be larger than zero.
      Parameters:
      itemStack - The ItemStack to look for.
      matchFlags - The flags to match the given ItemStack by.
      Returns:
      An iterator over all slots in which the ItemStack is present.
    • getEmptySlots

      protected abstract PrimitiveIterator.OfInt getEmptySlots()
      Returns:
      The slots with no ItemStack.
    • getNonEmptySlots

      protected abstract PrimitiveIterator.OfInt getNonEmptySlots()
      Returns:
      The slots that are not empty.
    • getItems

      public Iterator<net.minecraft.world.item.ItemStack> getItems()
      Specified by:
      getItems in interface ISlotlessItemHandler
      Returns:
      An immutable iterator over all available ingredients in this storage.
    • findItems

      public Iterator<net.minecraft.world.item.ItemStack> findItems(@Nonnull net.minecraft.world.item.ItemStack stack, int matchFlags)
      Description copied from interface: ISlotlessItemHandler
      Find all ItemStacks matching the given stack from the item handler. Calling this method will not modify the storage in any way. Results from this method MUST NOT be modified.
      Specified by:
      findItems in interface ISlotlessItemHandler
      Parameters:
      stack - The ItemStack to search for.
      matchFlags - The flags to compare the given matchStack by according to ItemMatch. ItemMatch.DAMAGE | ItemMatch.NBT will for instance make sure to only extract items that have exactly the same damage value and nbt tag, while ignoring the stacksize.
      Returns:
      An immutable iterator over ItemStacks that match the given stack, which may potentially be empty.
    • insertItem

      @Nonnull public net.minecraft.world.item.ItemStack insertItem(@Nonnull net.minecraft.world.item.ItemStack stack, boolean simulate)
      Description copied from interface: ISlotlessItemHandler
      Inserts an ItemStack into the item handler and return the remainder. The ItemStack should not be modified in this function! Note: This behaviour is subtly different from IFluidHandlers.fill()
      Specified by:
      insertItem in interface ISlotlessItemHandler
      Parameters:
      stack - ItemStack to insert.
      simulate - If true, the insertion is only simulated
      Returns:
      The remaining ItemStack that was not inserted (if the entire stack is accepted, then return ItemStack.EMPTY). May be the same as the input ItemStack if unchanged, otherwise a new ItemStack.
    • extractItem

      @Nonnull public net.minecraft.world.item.ItemStack extractItem(int amount, boolean simulate)
      Description copied from interface: ISlotlessItemHandler
      Extracts an ItemStack from the item handler. The returned value must be null if nothing is extracted, otherwise it's stack size must not be greater than amount or the itemstacks getMaxStackSize().
      Specified by:
      extractItem in interface ISlotlessItemHandler
      Parameters:
      amount - Amount to extract (may be greater than the current stacks max limit)
      simulate - If true, the extraction is only simulated
      Returns:
      ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted
    • extractItem

      @Nonnull public net.minecraft.world.item.ItemStack extractItem(@Nonnull net.minecraft.world.item.ItemStack matchStack, int matchFlags, boolean simulate)
      Description copied from interface: ISlotlessItemHandler
      Extract an ItemStack matching the given stack from the item handler. If nothing is extracted, otherwise it's stack size must not be greater than the itemstacks getMaxStackSize() If the stacksize is ignored according to the matchFlags, then the stacksize of the given matchStack MUST be interpreted as the maximum quantity that must be extracted.
      Specified by:
      extractItem in interface ISlotlessItemHandler
      Parameters:
      matchStack - The ItemStack to search for.
      matchFlags - The flags to compare the given matchStack by according to ItemMatch. ItemMatch.DAMAGE | ItemMatch.NBT will for instance make sure to only extract items that have exactly the same damage value and nbt tag, while ignoring the stacksize.
      simulate - If true, the insertion is only simulated
      Returns:
      ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted
    • getLimit

      public int getLimit()
      Description copied from interface: ISlotlessItemHandler
      Retrieves the total item stack count allowed to exist in this handler.
      Specified by:
      getLimit in interface ISlotlessItemHandler
      Returns:
      The maximum item count allowed in the handler.