Package alexiil.mc.lib.attributes.item
Interface GroupedItemInvView
- All Superinterfaces:
AbstractItemInvView
- All Known Subinterfaces:
GroupedItemInv
,LimitedGroupedItemInv
- All Known Implementing Classes:
CombinedGroupedItemInv
,CombinedGroupedItemInvView
,DelegatingGroupedItemInv
,DirectFixedItemInv
,EmptyGroupedItemInv
,GroupedItemInvFixedWrapper
,GroupedItemInvViewFixedWrapper
,SimpleGroupedItemInv
,SimpleLimitedGroupedItemInv
An alternative way of storing large numbers of
ItemStack
, without using large numbers of slots in a
FixedItemInvView
. Instead of storing items in a List<ItemStack> this works more like a
Map<ItemStack, int amount>.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
Statistics associated with a singleItemFilter
in a given inventory.Nested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
AbstractItemInvView.DefaultChangeTracker
-
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
(ItemInvAmountChangeListener listener, ListenerRemovalToken removalToken) Adds the given listener to this inventory, such that theItemInvAmountChangeListener.onChange(GroupedItemInvView, ItemStack, int, int)
will be called every time that this inventory changes.default int
getAmount
(ItemFilter filter) default int
getAmount
(net.minecraft.item.ItemStack stack) default int
getCapacity
(net.minecraft.item.ItemStack stack) default GroupedItemInvView
default int
getSpace
(net.minecraft.item.ItemStack stack) getStatistics
(ItemFilter filter) getStatistics
(net.minecraft.item.ItemStack stack) Set<net.minecraft.item.ItemStack>
int
default boolean
isEmpty()
Methods inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
getChangeValue
-
Method Details
-
getStoredStacks
Set<net.minecraft.item.ItemStack> getStoredStacks()- Returns:
- a set containing all of the
ItemStack
's that are stored in the inventory. NOTE: This must return a set using one of theHash.Strategy
's inItemStackCollections
otherwise comparison methods won't work correctly!
-
getAmount
default int getAmount(net.minecraft.item.ItemStack stack) - Parameters:
stack
- The stack to check for. Cannot beempty
.- Returns:
- The total amount of the given stack that is stored in this inventory.
-
getCapacity
default int getCapacity(net.minecraft.item.ItemStack stack) - Parameters:
stack
- The stack to check for. Must not beempty
.- Returns:
- The total space that is available (right now!) to store the given stack.
-
getTotalCapacity
int getTotalCapacity()- Returns:
- The total capacity for every
ItemStack
that can be stored in this inventory.NOTE: This value might not be equal to the sum of
getCapacity(ItemStack)
overgetStoredStacks()
!
-
getSpace
default int getSpace(net.minecraft.item.ItemStack stack) - Returns:
- The total space that could store the given stack, not including space that is currently taken up by the
stack (so this should change with
getAmount(ItemFilter)
).
-
getStatistics
- Parameters:
filter
- The filter to check on.- Returns:
- Statistics about the currently stored amount, capacity, and space for everything that matches the given filter.
-
getStatistics
- Parameters:
stack
- TheItemStack
to check for.- Returns:
- Statistics about the currently stored amount, capacity, and space for everything that matches the given item stack.
-
getAmount
- Returns:
- A count of all the
ItemStack
's that match the given filter.
-
isEmpty
default boolean isEmpty()- Returns:
- True if
getAmount
(ConstantItemFilter.ANYTHING) returns a value greater than 0.
-
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(ItemInvAmountChangeListener listener, ListenerRemovalToken removalToken) Adds the given listener to this inventory, such that theItemInvAmountChangeListener.onChange(GroupedItemInvView, ItemStack, int, int)
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.
-
getGroupedView
- Returns:
- A completely unmodifiable view of this
GroupedItemInvView
.
-