Class ItemStorageCache
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(net.minecraft.world.item.ItemStack stack, int size, boolean rebuilding, boolean batched) Adds a stack to the cache.voidaddListener(IStorageCacheListener<net.minecraft.world.item.ItemStack> listener) Adds a listener to be called when this storage cache changes.voidflush()Notifies storage cache listeners about batched up storage cache changes.IStackList<net.minecraft.world.item.ItemStack>List<? extends IGridStack>IStackList<net.minecraft.world.item.ItemStack>getList()voidinvalidate(InvalidateCause cause) Invalidates the cache.voidRe-attaches all listeners.voidremove(net.minecraft.world.item.ItemStack stack, int size, boolean batched) Removes a stack from the cache.voidremoveListener(IStorageCacheListener<net.minecraft.world.item.ItemStack> listener) Removes a listener from the storage cache.voidsort()Resorts the storages in this cache according to their priority.
-
Field Details
-
INVALIDATE_ACTION
-
-
Constructor Details
-
ItemStorageCache
-
-
Method Details
-
invalidate
Description copied from interface:IStorageCacheInvalidates the cache. Will also callIStorageCache.sort()to sort the storages correctly. Typically called when aIStorageProvideris added or removed from the network.- Specified by:
invalidatein interfaceIStorageCache<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:IStorageCacheAdds 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:
addin interfaceIStorageCache<net.minecraft.world.item.ItemStack>- Parameters:
stack- the stack to add, do NOT modifysize- the size to addrebuilding- true if this method is called while rebuilding, false otherwisebatched- 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:IStorageCacheRemoves 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:
removein interfaceIStorageCache<net.minecraft.world.item.ItemStack>- Parameters:
stack- the stack to remove, do NOT modifysize- the size to removebatched- true if this change needs to be batched, false otherwise
-
flush
public void flush()Description copied from interface:IStorageCacheNotifies storage cache listeners about batched up storage cache changes.- Specified by:
flushin interfaceIStorageCache<net.minecraft.world.item.ItemStack>
-
addListener
Description copied from interface:IStorageCacheAdds a listener to be called when this storage cache changes.- Specified by:
addListenerin interfaceIStorageCache<net.minecraft.world.item.ItemStack>- Parameters:
listener- the listener
-
removeListener
Description copied from interface:IStorageCacheRemoves a listener from the storage cache.- Specified by:
removeListenerin interfaceIStorageCache<net.minecraft.world.item.ItemStack>- Parameters:
listener- the listener
-
reAttachListeners
public void reAttachListeners()Description copied from interface:IStorageCacheRe-attaches all listeners. In practice this means that all listeners will get aIStorageCacheListener.onAttached()call.- Specified by:
reAttachListenersin interfaceIStorageCache<net.minecraft.world.item.ItemStack>
-
sort
public void sort()Description copied from interface:IStorageCacheResorts the storages in this cache according to their priority. This needs to be called when the priority of a storage changes.- Specified by:
sortin interfaceIStorageCache<net.minecraft.world.item.ItemStack>
-
getList
- Specified by:
getListin interfaceIStorageCache<net.minecraft.world.item.ItemStack>- Returns:
- the list behind this cache
-
getCraftablesList
- Specified by:
getCraftablesListin interfaceIStorageCache<net.minecraft.world.item.ItemStack>- Returns:
- a list of craftables
-
getGridStacks
- Specified by:
getGridStacksin interfaceIStorageCache<net.minecraft.world.item.ItemStack>- Returns:
- grid stacks to sync initially
-
getStorages
- Specified by:
getStoragesin interfaceIStorageCache<net.minecraft.world.item.ItemStack>- Returns:
- the storages connected to this network
-