Interface AbstractItemInvView

All Known Subinterfaces:
FixedItemInv, FixedItemInv.CopyingFixedItemInv, FixedItemInv.ModifiableFixedItemInv, FixedItemInvView, GroupedItemInv, GroupedItemInvView, LimitedFixedItemInv, LimitedGroupedItemInv
All Known Implementing Classes:
AbstractPartialFixedItemInvView, CombinedFixedItemInv, CombinedFixedItemInv.OfCopying, CombinedFixedItemInv.OfModifiable, CombinedFixedItemInvView, CombinedGroupedItemInv, CombinedGroupedItemInvView, DelegatingFixedItemInv, DelegatingFixedItemInv.OfCopying, DelegatingFixedItemInv.OfModifiable, DelegatingGroupedItemInv, DirectFixedItemInv, EmptyFixedItemInv, EmptyGroupedItemInv, FixedInventoryVanillaWrapper, FixedInventoryViewVanillaWrapper, FixedSidedInventoryVanillaWrapper, FullFixedItemInv, GroupedItemInvFixedWrapper, GroupedItemInvViewFixedWrapper, MappedFixedItemInv, MappedFixedItemInv.OfCopying, MappedFixedItemInv.OfModifiable, MappedFixedItemInvView, SimpleFixedItemInv, SimpleGroupedItemInv, SimpleLimitedFixedItemInv, SimpleLimitedFixedItemInv.OfCopying, SimpleLimitedFixedItemInv.OfModifiable, SimpleLimitedGroupedItemInv, SubFixedItemInv, SubFixedItemInv.OfCopying, SubFixedItemInv.OfModifiable, SubFixedItemInvView

public interface AbstractItemInvView
Base interface for FixedItemInvView and GroupedItemInvView.
  • Method Details

    • getChangeValue

      default int getChangeValue()
      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 registered InvMarkDirtyListener.

      The default implementation returns an ever-increasing value.

    • addListener

      @Nullable default ListenerToken addListener(InvMarkDirtyListener listener, ListenerRemovalToken removalToken)
      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 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!

      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.