Package alexiil.mc.lib.attributes.item
Interface FixedItemInv.CopyingFixedItemInv
- All Superinterfaces:
AbstractItemInvView
,Convertible
,FixedItemInv
,FixedItemInvView
- All Known Implementing Classes:
CombinedFixedItemInv.OfCopying
,DelegatingFixedItemInv.OfCopying
,FullFixedItemInv
,MappedFixedItemInv.OfCopying
,SimpleFixedItemInv
,SimpleLimitedFixedItemInv.OfCopying
,SubFixedItemInv.OfCopying
- Enclosing interface:
- FixedItemInv
The "complex" variant of
FixedItemInv
that always returns copies of the stack held. As such this allows
per-slot listeners to be registered, and full filter usage (as no-one can modify this inventory in a way that is
not permitted).-
Nested Class Summary
Nested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
AbstractItemInvView.DefaultChangeTracker
Nested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
FixedItemInv.CopyingFixedItemInv, FixedItemInv.ModifiableFixedItemInv
-
Method Summary
Modifier and TypeMethodDescriptiondefault ListenerToken
addListener
(InvMarkDirtyListener listener, ListenerRemovalToken removalToken) Adds the given listener to this inventory, such thatInvMarkDirtyListener.onMarkDirty(AbstractItemInvView)
will be called every time that any stored stack is changed (either fromFixedItemInv.setInvStack(int, ItemStack, Simulation)
orFixedItemInv.ModifiableFixedItemInv.markDirty()
).default ListenerToken
addListener
(ItemInvSlotChangeListener listener, ListenerRemovalToken removalToken) Adds the given listener to this inventory, such that theItemInvSlotChangeListener.onChange(FixedItemInvView, int, ItemStack, ItemStack)
will be called every time that this inventory changes.default net.minecraft.item.ItemStack
getInvStack
(int slot) default SingleCopyingItemSlot
getSlot
(int slot) net.minecraft.item.ItemStack
getUnmodifiableInvStack
(int slot) Methods inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
getChangeValue
Methods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
createLimitedFixedInv, extractStack, forceSetInvStack, getExtractable, getGroupedInv, getInsertable, getMappedInv, getSubInv, getTransferable, insertStack, isItemValidForSlot, modifySlot, setInvStack, slotIterable
Methods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInvView
convertTo, getFilterForSlot, getFixedView, getMaxAmount, getSlotCount, offerSelfAsAttribute, stackIterable
-
Method Details
-
getInvStack
default net.minecraft.item.ItemStack getInvStack(int slot) - Specified by:
getInvStack
in interfaceFixedItemInv
- Specified by:
getInvStack
in interfaceFixedItemInvView
- Parameters:
slot
- The slot index. Must be a value between 0 (inclusive) andFixedItemInvView.getSlotCount()
(exclusive) to be valid. (Like in arrays, lists, etc).- Returns:
- a copy of the
ItemStack
held in this inventory.
-
getUnmodifiableInvStack
net.minecraft.item.ItemStack getUnmodifiableInvStack(int slot) - Returns:
- The
ItemStack
that is held by this inventory. Modifying the returnedItemStack
in any way will (most likely - depending on the implementation) throw an exception (at some point).
-
getSlot
- Specified by:
getSlot
in interfaceFixedItemInv
- Specified by:
getSlot
in interfaceFixedItemInvView
- Returns:
- A view of a single slot in this inventory.
-
addListener
Description copied from interface:AbstractItemInvView
Adds the given listener to this inventory, such thatInvMarkDirtyListener.onMarkDirty(AbstractItemInvView)
will be called every time that any stored stack is changed (either fromFixedItemInv.setInvStack(int, ItemStack, Simulation)
orFixedItemInv.ModifiableFixedItemInv.markDirty()
).If the listener is registered (and thus this returns null) then it implies that
AbstractItemInvView.getChangeValue()
will change every time that the given listener is invoked, always just-before it is invoked.The default implementation refuses to accept any listeners, but implementations are highly encouraged to override this if they are able to!
- Specified by:
addListener
in interfaceAbstractItemInvView
removalToken
- A token that will be called whenever the given listener is removed from this inventory (or if this inventory itself is unloaded or otherwise invalidated).- Returns:
- A token that represents the listener, or null if the listener could not be added.
-
addListener
default ListenerToken addListener(ItemInvSlotChangeListener listener, ListenerRemovalToken removalToken) Adds the given listener to this inventory, such that theItemInvSlotChangeListener.onChange(FixedItemInvView, int, ItemStack, ItemStack)
will be called every time that this inventory changes. However if this inventory doesn't support listeners then this will return a nulltoken
.The default implementation refuses to accept any listeners, but implementations are highly encouraged to override this if they are able to!
- Parameters:
removalToken
- A token that will be called whenever the given listener is removed from this inventory (or if this inventory itself is unloaded or otherwise invalidated).- Returns:
- A token that represents the listener, or null if the listener could not be added.
-