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
public interface GroupedItemInvView extends AbstractItemInvView
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
Nested Classes Modifier and Type Interface Description static classGroupedItemInvView.ItemInvStatisticStatistics associated with a singleItemFilterin a given inventory.Nested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
AbstractItemInvView.DefaultChangeTracker -
Method Summary
Modifier and Type Method Description default 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(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 intgetAmount(ItemFilter filter)default intgetAmount(net.minecraft.item.ItemStack stack)default intgetCapacity(net.minecraft.item.ItemStack stack)default GroupedItemInvViewgetGroupedView()default intgetSpace(net.minecraft.item.ItemStack stack)GroupedItemInvView.ItemInvStatisticgetStatistics(ItemFilter filter)default GroupedItemInvView.ItemInvStatisticgetStatistics(net.minecraft.item.ItemStack stack)java.util.Set<net.minecraft.item.ItemStack>getStoredStacks()intgetTotalCapacity()default booleanisEmpty()
-
Method Details
-
getStoredStacks
java.util.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 inItemStackCollectionsotherwise 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
ItemStackthat 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- TheItemStackto 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
default ListenerToken addListener(InvMarkDirtyListener listener, ListenerRemovalToken removalToken)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(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.
-