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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(net.minecraft.world.item.ItemStack stack, int size, boolean rebuilding, boolean batched) Adds a stack to the cache.void
addListener
(IStorageCacheListener<net.minecraft.world.item.ItemStack> listener) Adds a listener to be called when this storage cache changes.void
flush()
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()
void
invalidate
(InvalidateCause cause) Invalidates the cache.void
Re-attaches all listeners.void
remove
(net.minecraft.world.item.ItemStack stack, int size, boolean batched) Removes a stack from the cache.void
removeListener
(IStorageCacheListener<net.minecraft.world.item.ItemStack> listener) Removes a listener from the storage cache.void
sort()
Resorts the storages in this cache according to their priority.
-
Field Details
-
INVALIDATE_ACTION
-
-
Constructor Details
-
ItemStorageCache
-
-
Method Details
-
invalidate
Description copied from interface:IStorageCache
Invalidates the cache. Will also callIStorageCache.sort()
to sort the storages correctly. Typically called when aIStorageProvider
is added or removed from the network.- Specified by:
invalidate
in 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: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 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: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 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:IStorageCache
Notifies storage cache listeners about batched up storage cache changes.- Specified by:
flush
in interfaceIStorageCache<net.minecraft.world.item.ItemStack>
-
addListener
Description copied from interface:IStorageCache
Adds a listener to be called when this storage cache changes.- Specified by:
addListener
in interfaceIStorageCache<net.minecraft.world.item.ItemStack>
- Parameters:
listener
- the listener
-
removeListener
Description copied from interface:IStorageCache
Removes a listener from the storage cache.- Specified by:
removeListener
in interfaceIStorageCache<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 aIStorageCacheListener.onAttached()
call.- Specified by:
reAttachListeners
in interfaceIStorageCache<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 interfaceIStorageCache<net.minecraft.world.item.ItemStack>
-
getList
- Specified by:
getList
in interfaceIStorageCache<net.minecraft.world.item.ItemStack>
- Returns:
- the list behind this cache
-
getCraftablesList
- Specified by:
getCraftablesList
in interfaceIStorageCache<net.minecraft.world.item.ItemStack>
- Returns:
- a list of craftables
-
getGridStacks
- Specified by:
getGridStacks
in interfaceIStorageCache<net.minecraft.world.item.ItemStack>
- Returns:
- grid stacks to sync initially
-
getStorages
- Specified by:
getStorages
in interfaceIStorageCache<net.minecraft.world.item.ItemStack>
- Returns:
- the storages connected to this network
-