Verwendung und Grenzen

Adaptiert einen einzelnen Behälter mit vollständig in Komponenten gespeicherten Inhalten. Befüllen verbraucht reale Ressourcen. emptyContainer benennt einen zu beschaffenden Gegenstand, keinen Gratisbehälter.

NebulaResourceContainer

NebulaResourceContainer
package dev.nebulastorage.api.platform

import dev.nebulastorage.api.resource.ResourceKey
import dev.nebulastorage.api.resource.ResourceStack
import dev.nebulastorage.api.resource.ResourceTypeId
import net.minecraft.world.item.ItemStack

/** Resolve only finite item-owned storage. Nebula supplies a detached, single-item copy; no world or external owner may be accessed. */
fun interface NebulaResourceContainerAdapter {
    fun resolve(container: ItemStack): NebulaResourceContainer?

    /** A fresh empty, finite container for this identity, or EMPTY. The caller must acquire or craft the real item before filling it. */
    fun emptyContainer(resource: ResourceKey): ItemStack = ItemStack.EMPTY
}

/** All state must live in [container]'s components. Simulations are read-only and transfers affect only the exact requested identity. */
interface NebulaResourceContainer {
    val container: ItemStack
    val resourceType: ResourceTypeId
    fun contents(): Map<ResourceKey, Long>
    fun insert(request: ResourceStack, simulate: Boolean): Long
    fun extract(request: ResourceStack, simulate: Boolean): Long
}
Quelle

src/main/kotlin/dev/nebulastorage/api/platform/NebulaResourceContainer.kt; editorial/de.json

43b4d12d69e6033c24fa8c39dac383ef2429b446