Class VirtualStorage
java.lang.Object
com.trevlar.slotkit.api.storage.VirtualStorage
- All Implemented Interfaces:
Storage
Storage backed by a read function and a write function, so a consumer can
bring any external data source into the
Storage interface.
Implements plain Storage, not PersistentStorage: saving is
up to the external source.
Replaces the old MKContainerSource and LiveContainerSource,
where consumers supplied their own read and write callbacks.
-
Constructor Summary
ConstructorsConstructorDescriptionVirtualStorage(int size, IntFunction<net.minecraft.world.item.ItemStack> getter, BiConsumer<Integer, net.minecraft.world.item.ItemStack> setter) With a dirty callback that does nothing.VirtualStorage(int size, IntFunction<net.minecraft.world.item.ItemStack> getter, BiConsumer<Integer, net.minecraft.world.item.ItemStack> setter, Runnable dirtyCallback) -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.ItemStackgetStack(int localIndex) Returns the stack at the given local index.voidMarks this storage as changed.voidsetStack(int localIndex, net.minecraft.world.item.ItemStack stack) Sets the stack at the given local index.intsize()Returns the number of slots in this storage.
-
Constructor Details
-
VirtualStorage
public VirtualStorage(int size, IntFunction<net.minecraft.world.item.ItemStack> getter, BiConsumer<Integer, net.minecraft.world.item.ItemStack> setter, Runnable dirtyCallback) - Parameters:
size- number of slotsgetter- (localIndex) -> stack at that indexsetter- (localIndex, stack) -> write stack at that indexdirtyCallback- called when markDirty() is invoked
-
VirtualStorage
public VirtualStorage(int size, IntFunction<net.minecraft.world.item.ItemStack> getter, BiConsumer<Integer, net.minecraft.world.item.ItemStack> setter) With a dirty callback that does nothing.
-
-
Method Details
-
getStack
-
setStack
-
size
-
markDirty
-