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.ItemStack
attemptInsertion(net.minecraft.item.ItemStack stack, Simulation simulation)
Inserts the given stack into this insertable, and returns the excess.default ItemInsertable
filtered(ItemFilter filter)
default ItemFilter
Returns anItemFilter
to determine ifattemptInsertion(ItemStack, Simulation)
will accept a stack.default ItemInsertable
default net.minecraft.item.ItemStack
insert(net.minecraft.item.ItemStack stack)
Inserts the given stack into this insertable, and returns the excess.default boolean
offer(net.minecraft.item.ItemStack stack)
Deprecated.default boolean
offer(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 boolean
wouldAccept(net.minecraft.item.ItemStack stack)
default boolean
wouldPartiallyAccept(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.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.This is an override forLimitedConsumer
, for the full javadoc you probably want to callattemptInsertion(ItemStack, Simulation)
directly.- Specified by:
offer
in 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.ACTION
then 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:
offer
in 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:
wouldAccept
in 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 aSimulation
parameter ofACTION
.- 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
Returns anItemFilter
to 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 (likeItemExtractable
orGroupedItemInv
.
-
LimitedConsumer
, for the full javadoc you probably want to callinsert(ItemStack)
directly.