Interface ISlotlessItemHandler

All Known Implementing Classes:
DefaultSlotlessItemHandlerWrapper, IndexedSlotlessItemHandlerWrapper, SlotlessItemHandlerWrapper

public interface ISlotlessItemHandler
A simplified form of the ResourceHandler for items that is slot-agnostic. By not taking into account slots, the item handler provider instead of the consumer is responsible for providing an efficient item insertion and extraction algorithm.
  • Method Summary

    Modifier and Type
    Method
    Description
    default net.minecraft.world.item.ItemStack
    extractItem(int amount, boolean simulate)
    Extracts an ItemStack from the item handler.
    net.minecraft.world.item.ItemStack
    extractItem(int amount, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction)
    Extracts an ItemStack from the item handler.
    default 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.
    net.minecraft.world.item.ItemStack
    extractItem(net.minecraft.world.item.ItemStack matchStack, int matchFlags, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction)
    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.
    Iterator<net.minecraft.world.item.ItemStack>
     
    int
    Retrieves the total item stack count allowed to exist in this handler.
    default 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.
    net.minecraft.world.item.ItemStack
    insertItem(net.minecraft.world.item.ItemStack stack, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction)
    Inserts an ItemStack into the item handler and return the remainder.
  • Method Details

    • getItems

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

      Iterator<net.minecraft.world.item.ItemStack> findItems(@Nonnull net.minecraft.world.item.ItemStack stack, int matchFlags)
      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.
      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 net.minecraft.world.item.ItemStack insertItem(@Nonnull net.minecraft.world.item.ItemStack stack, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction)
      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()
      Parameters:
      stack - ItemStack to insert.
      transaction - The transaction context.
      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.
    • insertItem

      @Nonnull default net.minecraft.world.item.ItemStack insertItem(@Nonnull net.minecraft.world.item.ItemStack stack, boolean simulate)
      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()
      Parameters:
      stack - ItemStack to insert.
      simulate - If insertion should be 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 net.minecraft.world.item.ItemStack extractItem(int amount, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction)
      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().
      Parameters:
      amount - Amount to extract (may be greater than the current stacks max limit)
      transaction - The transaction context.
      Returns:
      ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted
    • extractItem

      @Nonnull default net.minecraft.world.item.ItemStack extractItem(int amount, boolean simulate)
      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().
      Parameters:
      amount - Amount to extract (may be greater than the current stacks max limit)
      simulate - If insertion should be simulated.
      Returns:
      ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted
    • extractItem

      @Nonnull net.minecraft.world.item.ItemStack extractItem(@Nonnull net.minecraft.world.item.ItemStack matchStack, int matchFlags, net.neoforged.neoforge.transfer.transaction.TransactionContext transaction)
      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.

      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.
      transaction - The transaction context.
      Returns:
      ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted
    • extractItem

      @Nonnull default net.minecraft.world.item.ItemStack extractItem(@Nonnull net.minecraft.world.item.ItemStack matchStack, int matchFlags, boolean simulate)
      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.

      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 insertion should be simulated.
      Returns:
      ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted
    • getLimit

      int getLimit()
      Retrieves the total item stack count allowed to exist in this handler.
      Returns:
      The maximum item count allowed in the handler.