Class CombinedGroupedItemInvView
- All Implemented Interfaces:
AbstractItemInvView
,GroupedItemInvView
,Combined
- Direct Known Subclasses:
CombinedGroupedItemInv
GroupedItemInvView
's.-
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.GroupedItemInvView
GroupedItemInvView.ItemInvStatistic
-
Field Summary
Fields inherited from class alexiil.mc.lib.attributes.misc.AbstractCombined
list
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddListener(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.int
getAmount(ItemFilter filter)
int
getAmount(net.minecraft.item.ItemStack stack)
int
getCapacity(net.minecraft.item.ItemStack stack)
int
int
getSpace(net.minecraft.item.ItemStack stack)
getStatistics(ItemFilter filter)
Set<net.minecraft.item.ItemStack>
int
Methods inherited from class alexiil.mc.lib.attributes.misc.AbstractCombined
equals, getSubObject, getSubObjectCount, hashCode, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface alexiil.mc.lib.attributes.item.GroupedItemInvView
addListener, getGroupedView, getStatistics, isEmpty
-
Constructor Details
-
CombinedGroupedItemInvView
-
-
Method Details
-
getAmount
- Specified by:
getAmount
in interfaceGroupedItemInvView
- Returns:
- A count of all the
ItemStack
's that match the given filter.
-
getAmount
public int getAmount(net.minecraft.item.ItemStack stack)- Specified by:
getAmount
in interfaceGroupedItemInvView
- Parameters:
stack
- The stack to check for. Cannot beempty
.- Returns:
- The total amount of the given stack that is stored in this inventory.
-
getSpace
public int getSpace(net.minecraft.item.ItemStack stack)- Specified by:
getSpace
in interfaceGroupedItemInvView
- 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
GroupedItemInvView.getAmount(ItemFilter)
).
-
getCapacity
public int getCapacity(net.minecraft.item.ItemStack stack)- Specified by:
getCapacity
in interfaceGroupedItemInvView
- 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
public int getTotalCapacity()- Specified by:
getTotalCapacity
in interfaceGroupedItemInvView
- 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
GroupedItemInvView.getCapacity(ItemStack)
overGroupedItemInvView.getStoredStacks()
!
-
getStatistics
- Specified by:
getStatistics
in interfaceGroupedItemInvView
- Parameters:
filter
- The filter to check on.- Returns:
- Statistics about the currently stored amount, capacity, and space for everything that matches the given filter.
-
getStoredStacks
- Specified by:
getStoredStacks
in interfaceGroupedItemInvView
- 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!
-
getChangeValue
public int getChangeValue()- Specified by:
getChangeValue
in interfaceAbstractItemInvView
- Returns:
- A value that indicates whether an inventory might have changed if it differs from the last value
returned. This number doesn't have to start at 0, but it must change every time that the inventory is
changed, although it can change even without any observable changes to this inventory.
Inventories that don't support this might increment the change number every time that this is called - so you should never write a loop that depends on the returned value settling down on a particular value.
Inventories that support
listeners
highly encouraged to support this - by definition if an inventory knows when it changed then it should be able to count the number of changes. It is also implied that any changes to this value will also invoke every registeredInvMarkDirtyListener
.The default implementation returns an ever-increasing value.
-
addListener
public ListenerToken addListener(ItemInvAmountChangeListener listener, ListenerRemovalToken removalToken)Description copied from interface:GroupedItemInvView
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!
- Specified by:
addListener
in interfaceGroupedItemInvView
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.
-