Verwendung und Grenzen

Für physische Maschinen mit Items, Flüssigkeiten und Chemikalien: Alle Verarbeitungstanks und Slots erfassen, ohne Brennstoff und Energie. Exakte Mengen und Nebenprodukte erhalten; verbrauchte Eingaben nie erstatten.

  1. EntdeckenFähigkeiten und Rezepte lesen
  2. PlanenExakte Ressourcen reservieren
  3. AusführenAn realen Besitzer übertragen
  4. FortsetzenGespeicherten Beleg lesen
Entdeckung liest nur. Erst die Ausführung überträgt Besitz; Wiederherstellung erzeugt keine verbrauchten Eingaben neu.

NebulaPhysicalResourceMachine

NebulaPhysicalResourceMachine
package dev.nebulastorage.api.platform

import dev.nebulastorage.api.production.ProductionCapabilityId
import dev.nebulastorage.api.production.ProductionRecipeId
import dev.nebulastorage.api.resource.ResourceKey
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.level.block.entity.BlockEntity

/** A loaded native owner; all processing state and Nebula receipts must persist in its complete block entity NBT. */
interface NebulaPhysicalMachine {
    val entity: BlockEntity
    val capabilities: Set<ProductionCapabilityId>
    fun configurationProblem(): String?
    fun matchesRecipe(id: ProductionRecipeId, inputs: Map<ResourceKey, Long>, outputs: Map<ResourceKey, Long>): Boolean
    fun status(): PhysicalMachineStatus
}

fun interface NebulaPhysicalResourceMachineAdapter {
    /** Resolves on the server thread without loading chunks, changing configuration or moving resources. */
    fun resolve(level: ServerLevel, position: BlockPos): NebulaPhysicalResourceMachine?
}

/**
 * One exclusive native process with arbitrary resource types and deterministic outputs.
 * Snapshots include every processing input and output, but exclude energy and container/fuel supply slots.
 * Simulation is read-only. Transfers return actual quantities, never requested or expected quantities.
 * Input delivery must select the exact declared native recipe; no average of an uncertain output is admissible.
 * Cancellation extracts only remaining inputs. Consumed reagents must never be recreated.
 */
interface NebulaPhysicalResourceMachine : NebulaPhysicalMachine {
    val resourceCapabilities: Set<ProductionCapabilityId> get() = capabilities
    fun resources(): PhysicalResourceSnapshot
    /** False while an irreversible or retained native task must finish before its inputs and lease can be released. */
    fun canReturnInputs(): Boolean
    /** Includes internal native tasks, even when exposed input and output inventories are empty. */
    fun isIdle(): Boolean
    fun insertInputs(id: ProductionRecipeId, inputs: Map<ResourceKey, Long>, outputs: Map<ResourceKey, Long>, simulate: Boolean): Map<ResourceKey, Long>
    fun extractInputs(simulate: Boolean): Map<ResourceKey, Long>
    fun extractOutputs(simulate: Boolean): Map<ResourceKey, Long>
}

/**
 * Native local consumables, separate from a job's exact transformation inputs.
 * Supply remains owned by this block after completion/cancellation and is never refunded as unconsumed job input.
 * Requests must be finite, recipe-specific and bounded by the owner's real capacity. Only unreserved stock is eligible.
 */
interface NebulaPhysicalSupplies {
    fun requestedSupply(id: ProductionRecipeId, inputs: Map<ResourceKey, Long>): dev.nebulastorage.api.resource.ResourceStack?
    fun insertSupply(stack: dev.nebulastorage.api.resource.ResourceStack, simulate: Boolean): Long
}

/** Detached positive quantities in each resource type's native unit. Equal keys are summed exactly. */
data class PhysicalResourceSnapshot(val inputs: Map<ResourceKey, Long>, val outputs: Map<ResourceKey, Long>) {
    init { require(inputs.values.all { it > 0 } && outputs.values.all { it > 0 }) }
}
Quelle

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

43b4d12d69e6033c24fa8c39dac383ef2429b446