Package alexiil.mc.lib.attributes.item
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 Summary
Modifier and TypeMethodDescriptionnet.minecraft.item.ItemStackattemptInsertion(net.minecraft.item.ItemStack stack, Simulation simulation) Inserts the given stack into this insertable, and returns the excess.default ItemInsertablefiltered(ItemFilter filter) default ItemFilterReturns anItemFilterto determine ifattemptInsertion(ItemStack, Simulation)will accept a stack.default ItemInsertabledefault net.minecraft.item.ItemStackinsert(net.minecraft.item.ItemStack stack) Inserts the given stack into this insertable, and returns the excess.default booleanoffer(net.minecraft.item.ItemStack stack) Deprecated.default booleanoffer(net.minecraft.item.ItemStack stack, Simulation simulation) Deprecated.This is an override forLimitedConsumer, for the full javadoc you probably want to callattemptInsertion(ItemStack, Simulation)directly.default booleanwouldAccept(net.minecraft.item.ItemStack stack) default booleanwouldPartiallyAccept(net.minecraft.item.ItemStack stack)
-
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- IfSimulation.SIMULATEthen this shouldn't modify anything.- Returns:
- the excess
ItemStackthat 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.This is an override forLimitedConsumer, for the full javadoc you probably want to callattemptInsertion(ItemStack, Simulation)directly.- Specified by:
offerin interfaceLimitedConsumer<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- IfSimulation.ACTIONthen this will modify state (if accepted).- Returns:
- True if the object would have been accepted.
-
offer
Deprecated.This is an override forLimitedConsumer, for the full javadoc you probably want to callinsert(ItemStack)directly.- Specified by:
offerin interfaceLimitedConsumer<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:
wouldAcceptin interfaceLimitedConsumer<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 aSimulationparameter ofACTION.- Parameters:
stack- The incoming stack. Must not be modified by this call.- Returns:
- the excess
ItemStackthat wasn't accepted. This will be independent of this insertable, however it might be the given stack instead of a completely new object.
-
getInsertionFilter
Returns anItemFilterto determine ifattemptInsertion(ItemStack, Simulation)will accept a stack. The default implementation is a call toattemptInsertion(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
-
getPureInsertable
- Returns:
- An object that only implements
ItemInsertable, and does not expose any of the other modification methods that sibling or subclasses offer (likeItemExtractableorGroupedItemInv.
-
LimitedConsumer, for the full javadoc you probably want to callinsert(ItemStack)directly.