使い方と制約
アイテム・液体・化学物質を扱う物理機械用です。燃料・電力以外の全処理タンクとスロットを記録し、正確な量と副産物を維持します。消費済み入力を返却してはいけません。
- 検出能力とレシピを読む
- 計画正確な資源を予約する
- 実行実際の所有者へ転送する
- 復旧保存された受領記録を読む
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 }) }
}
ソース
src/main/kotlin/dev/nebulastorage/api/platform/NebulaPhysicalResourceMachine.kt; editorial/ja.json
43b4d12d69e6033c24fa8c39dac383ef2429b446