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>.
  • 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 the Hash.Strategy's in ItemStackCollections otherwise comparison methods won't work correctly!
    • getAmount

      default int getAmount(net.minecraft.item.ItemStack stack)
      Parameters:
      stack - The stack to check for. Cannot be empty.
      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 be empty.
      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) over getStoredStacks()!

    • 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

      default GroupedItemInvView.ItemInvStatistic getStatistics(net.minecraft.item.ItemStack stack)
      Parameters:
      stack - The ItemStack to check for.
      Returns:
      Statistics about the currently stored amount, capacity, and space for everything that matches the given item stack.
    • getAmount

      default int getAmount(ItemFilter filter)
      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: AbstractItemInvView
      Adds the given listener to this inventory, such that InvMarkDirtyListener.onMarkDirty(AbstractItemInvView) will be called every time that any stored stack is changed (either from FixedItemInv.setInvStack(int, ItemStack, Simulation) or FixedItemInv.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 interface AbstractItemInvView
      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 the ItemInvAmountChangeListener.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 null token.

      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

      default GroupedItemInvView getGroupedView()
      Returns:
      A completely unmodifiable view of this GroupedItemInvView.