Interface ItemInsertable

All Superinterfaces:
LimitedConsumer<net.minecraft.item.ItemStack>
All Known Subinterfaces:
GroupedItemInv, ItemTransferable, LimitedGroupedItemInv
All Known Implementing Classes:
CombinedGroupedItemInv, CombinedItemInsertable, DelegatingGroupedItemInv, DirectFixedItemInv, EmptyGroupedItemInv, EmptyItemTransferable, FilteredItemInsertable, FilteredItemTransferable, FullFixedItemInv, GroupedItemInvFixedWrapper, ItemTransferableItemEntity, RejectingItemInsertable, SimpleFixedItemInv, SimpleFixedItemInvInsertable, SimpleGroupedItemInv, SimpleLimitedGroupedItemInv, SingleCopyingItemSlot, SingleItemSlot
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ItemInsertable extends LimitedConsumer<net.minecraft.item.ItemStack>
Defines an object that can have items inserted into it.
  • Method Details

    • attemptInsertion

      net.minecraft.item.ItemStack attemptInsertion(net.minecraft.item.ItemStack stack, Simulation simulation)
      Inserts the given stack into this insertable, and returns the excess.
      Parameters:
      stack - The incoming stack. Must not be modified by this call.
      simulation - If Simulation.SIMULATE then this shouldn't modify anything.
      Returns:
      the excess ItemStack that wasn't accepted. This will be independent of this insertable, however it might be the given stack instead of a completely new object.
    • offer

      @Deprecated default boolean offer(net.minecraft.item.ItemStack stack, Simulation simulation)
      Deprecated.
      This is an override for LimitedConsumer, for the full javadoc you probably want to call attemptInsertion(ItemStack, Simulation) directly.
      Specified by:
      offer in interface LimitedConsumer<net.minecraft.item.ItemStack>
      Parameters:
      stack - The object to offer. This interface makes no guarantees about whether this object will be defensively copied or not - so callers should assume that any objects passed to this may be modified in any way. Likewise, this has no requirements for what callers may do with the object after it has been passed in.
      simulation - If Simulation.ACTION then this will modify state (if accepted).
      Returns:
      True if the object would have been accepted.
    • offer

      @Deprecated default boolean offer(net.minecraft.item.ItemStack stack)
      Deprecated.
      This is an override for LimitedConsumer, for the full javadoc you probably want to call insert(ItemStack) directly.
      Specified by:
      offer in interface LimitedConsumer<net.minecraft.item.ItemStack>
      Parameters:
      stack - The object to offer. This interface makes no guarantees about whether this object will be defensively copied or not - so callers should assume that any objects passed to this may be modified in any way. Likewise, this has no requirements for what callers may do with the object after it has been passed in
      Returns:
      True if the offer was accepted, or false if nothing happened.
    • wouldAccept

      default boolean wouldAccept(net.minecraft.item.ItemStack stack)
      Specified by:
      wouldAccept in interface LimitedConsumer<net.minecraft.item.ItemStack>
      Parameters:
      stack - The object to test for. This interface makes no guarantees about whether this object will be defensively copied or not - so callers should assume that any objects passed to this may be modified in any way. Likewise, this has no requirements for what callers may do with the object after it has been passed in
      Returns:
      True if insert(ItemStack) would fully accept the given stack, and return an empty excess.
    • wouldPartiallyAccept

      default boolean wouldPartiallyAccept(net.minecraft.item.ItemStack stack)
      Returns:
      True if insert(ItemStack) would accept any non-zero amount of the given stack, and return an excess that is smaller than the given stack.
    • insert

      default net.minecraft.item.ItemStack insert(net.minecraft.item.ItemStack stack)
      Inserts the given stack into this insertable, and returns the excess.

      This is equivalent to calling attemptInsertion(ItemStack, Simulation) with a Simulation parameter of ACTION.

      Parameters:
      stack - The incoming stack. Must not be modified by this call.
      Returns:
      the excess ItemStack that wasn't accepted. This will be independent of this insertable, however it might be the given stack instead of a completely new object.
    • getInsertionFilter

      default ItemFilter getInsertionFilter()
      Returns an ItemFilter to determine if attemptInsertion(ItemStack, Simulation) will accept a stack. The default implementation is a call to attemptInsertion(stack, Simulation.SIMULATE), and it is only useful to override this if the resulting filter contains information that might be usable by the caller.
      Returns:
      A filter to determine if attemptInsertion(ItemStack, Simulation) will accept the entirety of a given stack.
    • filtered

      default ItemInsertable filtered(ItemFilter filter)
    • getPureInsertable

      default ItemInsertable getPureInsertable()
      Returns:
      An object that only implements ItemInsertable, and does not expose any of the other modification methods that sibling or subclasses offer (like ItemExtractable or GroupedItemInv.