Skip to content

ArchieItemStorage

@Serializable



(with = ArchieItemStorage.Serializer::class)open class ArchieItemStorage : CommonStorage<ItemResource> , UpdateManager<NbtTag> 

Archie's platform-agnostic item container: a fixed-size list of ArchieItemSlots that implements Common Storage Lib's CommonStorage (resource-based insert/extract for capability interop) and Archie's NBT serialization (via Serializer) for save/load.

Usually created through net.kernelpanicsoft.archie.serialization.NBTHolder.itemField rather than directly. Its public surface is deliberately small; read or mutate the net.minecraft.world.item.ItemStack in a slot through the ArchieItemSlot returned by get, not on the storage itself.

Parameters

  • onUpdate: Invoked by update whenever the storage's contents should be persisted/synced.

Constructors

ArchieItemStorage

constructor(
    size: Int, 
    filter: Predicate<ItemResource> = Predicate { true }, 
    onUpdate: () -> Unit = {}
)

Creates a storage with size empty slots.

Types

Serializer

object Serializer : KSerializer<ArchieItemStorage> 

Serializes an ArchieItemStorage as the plain list of its ArchieItemSlots.

Functions

allowsExtraction

allowsInsertion

open fun allowsInsertion(): Boolean

createSnapshot

open override fun createSnapshot(): NbtTag

extract

open fun extract(
    index: Int, 
    resource: ItemResource?, 
    amount: Long, 
    simulate: Boolean
): Long
open override fun extract(
    unit: ItemResource, 
    amount: Long, 
    simulate: Boolean
): Long

get

open operator override fun get(slot: Int): ArchieItemSlot

The ArchieItemSlot at slot, for reading/mutating its net.minecraft.world.item.ItemStack.

getAmount

open fun getAmount(index: Int): Long

getContents

open fun getContents(index: Int): ResourceStack<ItemResource?>?

getLimit

open fun getLimit(index: Int, resource: ItemResource?): Long

getResource

open fun getResource(index: Int): ItemResource?

insert

open fun insert(
    index: Int, 
    resource: ItemResource?, 
    amount: Long, 
    simulate: Boolean
): Long
open override fun insert(
    unit: ItemResource, 
    amount: Long, 
    simulate: Boolean
): Long

isResourceValid

open fun isResourceValid(index: Int, resource: ItemResource?): Boolean

readSnapshot

open override fun readSnapshot(snapshot: NbtTag)

size

open override fun size(): Int

The number of slots in this storage.

update

open override fun update()