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.DefaultChangeTrackerNested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
FixedItemInv.CopyingFixedItemInv, FixedItemInv.ModifiableFixedItemInv -
Method Summary
Modifier and TypeMethodDescriptiondefault ListenerTokenaddListener(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 ListenerTokenaddListener(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.ItemStackgetInvStack(int slot) default SingleCopyingItemSlotgetSlot(int slot) net.minecraft.item.ItemStackgetUnmodifiableInvStack(int slot) Methods inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
getChangeValueMethods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
createLimitedFixedInv, extractStack, forceSetInvStack, getExtractable, getGroupedInv, getInsertable, getMappedInv, getSubInv, getTransferable, insertStack, isItemValidForSlot, modifySlot, setInvStack, slotIterableMethods 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:
getInvStackin interfaceFixedItemInv- Specified by:
getInvStackin 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
ItemStackheld in this inventory.
-
getUnmodifiableInvStack
net.minecraft.item.ItemStack getUnmodifiableInvStack(int slot) - Returns:
- The
ItemStackthat is held by this inventory. Modifying the returnedItemStackin any way will (most likely - depending on the implementation) throw an exception (at some point).
-
getSlot
- Specified by:
getSlotin interfaceFixedItemInv- Specified by:
getSlotin interfaceFixedItemInvView- Returns:
- A view of a single slot in this inventory.
-
addListener
Description copied from interface:AbstractItemInvViewAdds 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:
addListenerin interfaceAbstractItemInvViewremovalToken- 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.
-