java.lang.Object
com.refinedmods.refinedstorage.apiimpl.storage.cache.ItemStorageCache
All Implemented Interfaces:
IStorageCache<net.minecraft.world.item.ItemStack>

public class ItemStorageCache extends Object implements IStorageCache<net.minecraft.world.item.ItemStack>
  • Field Details

  • Constructor Details

    • ItemStorageCache

      public ItemStorageCache(INetwork network)
  • Method Details

    • invalidate

      public void invalidate(InvalidateCause cause)
      Description copied from interface: IStorageCache
      Invalidates the cache. Will also call IStorageCache.sort() to sort the storages correctly. Typically called when a IStorageProvider is added or removed from the network.
      Specified by:
      invalidate in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Parameters:
      cause - the cause of the invalidate
    • add

      public void add(@Nonnull net.minecraft.world.item.ItemStack stack, int size, boolean rebuilding, boolean batched)
      Description copied from interface: IStorageCache
      Adds a stack to the cache.

      Note that this doesn't modify any of the connected storages, but just modifies the cache. Use IStorage.insert(Object, int, Action) to add a stack to an actual storage.

      Will merge it with another stack if it already exists.

      Specified by:
      add in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Parameters:
      stack - the stack to add, do NOT modify
      size - the size to add
      rebuilding - true if this method is called while rebuilding, false otherwise
      batched - true if this change needs to be batched
    • remove

      public void remove(@Nonnull net.minecraft.world.item.ItemStack stack, int size, boolean batched)
      Description copied from interface: IStorageCache
      Removes a stack from the cache.

      Note that this doesn't modify any of the connected storages, but just modifies the cache. Use IStorage.extract(Object, int, int, Action) to remove a stack from an actual storage.

      Specified by:
      remove in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Parameters:
      stack - the stack to remove, do NOT modify
      size - the size to remove
      batched - true if this change needs to be batched, false otherwise
    • flush

      public void flush()
      Description copied from interface: IStorageCache
      Notifies storage cache listeners about batched up storage cache changes.
      Specified by:
      flush in interface IStorageCache<net.minecraft.world.item.ItemStack>
    • addListener

      public void addListener(IStorageCacheListener<net.minecraft.world.item.ItemStack> listener)
      Description copied from interface: IStorageCache
      Adds a listener to be called when this storage cache changes.
      Specified by:
      addListener in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Parameters:
      listener - the listener
    • removeListener

      public void removeListener(IStorageCacheListener<net.minecraft.world.item.ItemStack> listener)
      Description copied from interface: IStorageCache
      Removes a listener from the storage cache.
      Specified by:
      removeListener in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Parameters:
      listener - the listener
    • reAttachListeners

      public void reAttachListeners()
      Description copied from interface: IStorageCache
      Re-attaches all listeners. In practice this means that all listeners will get a IStorageCacheListener.onAttached() call.
      Specified by:
      reAttachListeners in interface IStorageCache<net.minecraft.world.item.ItemStack>
    • sort

      public void sort()
      Description copied from interface: IStorageCache
      Resorts the storages in this cache according to their priority. This needs to be called when the priority of a storage changes.
      Specified by:
      sort in interface IStorageCache<net.minecraft.world.item.ItemStack>
    • getList

      public IStackList<net.minecraft.world.item.ItemStack> getList()
      Specified by:
      getList in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Returns:
      the list behind this cache
    • getCraftablesList

      public IStackList<net.minecraft.world.item.ItemStack> getCraftablesList()
      Specified by:
      getCraftablesList in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Returns:
      a list of craftables
    • getGridStacks

      public List<? extends IGridStack> getGridStacks()
      Specified by:
      getGridStacks in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Returns:
      grid stacks to sync initially
    • getStorages

      public List<IStorage<net.minecraft.world.item.ItemStack>> getStorages()
      Specified by:
      getStorages in interface IStorageCache<net.minecraft.world.item.ItemStack>
      Returns:
      the storages connected to this network