Skip to content

API Recipes

Piggo41 edited this page Oct 16, 2026 · 13 revisions

Recipes

Lua API / Recipes

On this page

betamoon.recipes:add(definition)

Registers a native or custom recipe and returns a recipe reference. Required type selects a registered recipe type. Native aliases: shaped, shapeless, smelting (also minecraft:shaped, minecraft:shapeless, minecraft:smelting). Custom types accept a type handle or name.

Field definitions

Shaped declaration

Required output stack, pattern and ingredients. Pattern must be exactly two rows of two characters or three rows of three characters. Spaces are empty cells. Every non-space character must have a mapping. key is an accepted alias for ingredients when ingredients is absent.

local recipe = betamoon.recipes:add {
    type = "shaped", output = betamoon.stack(4, 4),
    pattern = { "SS", "SS" },
    ingredients = { S = 1 }
}

Ingredient mapping keys are one-character strings; values are native stack inputs. Item counts on native ingredients do not require multiple items per grid cell.

Shapeless declaration

Required output stack and ingredients list with 1–9 entries. Each entry occupies one crafting input; count is ignored for ingredient quantities. Damage can constrain variants.

betamoon.recipes:add {
    type = "shapeless", output = betamoon.stack(4),
    ingredients = { 1 }
}

Smelting declaration

Required input ID/reference or ID-bearing table and output stack. Native smelting lookup uses input ID, not damage-specific recipe selection. Processing duration and fuel belong to the furnace/machine.

betamoon.recipes:add { type = "smelting", input = 3, output = betamoon.stack(4) }

Custom declaration

Defines a recipe for a registered custom recipe type.

betamoon.recipes:add {
    key = "mymod:recipe/compress_stone", type = pressing,
    input = { item = 4, count = 4 },
    output = betamoon.stack(1),
    data = { duration = 40 }
}
Field Type Default / meaning
type name/type handle Required registered custom type.
key string Optional explicit qualified identity; omitted generates one. minecraft namespace is reserved.
ingredients map Ingredient role values conforming to the type.
input ingredient Alias only for a type with exactly one item ingredient role; cannot coexist with ingredients.
outputs map Output role stacks/lists.
output stack Alias for primary output; cannot duplicate that output in outputs.
data map Values validated against type data fields; omitted values use declared defaults.
conditions map Context-field equality values or numeric min/max ranges.
priority integer 0; higher priority recipes are considered first.
enabled boolean True; false excludes from matching.

Required roles must be supplied; omitted optional ingredient roles require their bound input to be empty. Optional outputs may be omitted. Every output stack must fit its item/inventory constraints. See ingredient formats.

Recipe data does not create automatic machine processing: the machine decides how duration or other fields are used. Native declarations do not accept the entire custom schema.

Recipe lookup

betamoon.recipes:get(key)

Returns a recipe reference by exact registry key, or nil. Use the key returned by a reference; native keys are generated registry identities, not display names or output IDs.

local recipe = betamoon.recipes:get("mymod:recipe/compress_stone")

betamoon.recipes:getRequired(key)

Same lookup, but raises a Lua error when missing.

local recipe = betamoon.recipes:getRequired("mymod:recipe/compress_stone")

betamoon.recipes:find(criteria)

Returns a result list of matching recipes. Criteria default to {}, which selects enabled recipes.

local recipes = betamoon.recipes:find { type = "smelting", output = 265 }

betamoon.recipes:first(criteria)

Returns first matching recipe or nil; multiple results allowed. Criteria default to {}. Do not use registry query order as machine candidate priority.

local recipe = betamoon.recipes:first { type = "smelting", input = 15 }

betamoon.recipes:one(criteria)

Returns sole matching recipe, nil for none, or raises an error for multiple. Criteria default to {}.

local recipe = betamoon.recipes:one { type = "smelting", input = 15 }

Recipe query criteria

Field Meaning
type Type name/handle or list of types; native unknown recipes can be queried with unknown.
input Stack criterion matching an input.
output Primary output criterion.
ingredients Role-specific ingredient criteria.
outputs Role-specific output criteria.
data Exact data values or numeric { min, max } bounds.
owner Exact owner filename or minecraft for untracked native recipes.
enabled Boolean, default true. Use false to find disabled recipes.

Stack criteria accept IDs/stack forms and damage = "any" for wildcard damage. Input criteria match an ingredient by identity/damage, independently of its required count. Output criteria match count exactly; count = 0 matches any output count. For the native top-level output criterion, count = 0 also ignores damage. Custom outputs and role-specific smelting outputs use damage = "any" to ignore damage. A pool/grid role criterion matches any ingredient requirement in that role; an output-pool criterion matches any stack in the pool. Role-specific native ingredient/output maps are supported for smelting using input/output roles.

Unknown query fields and invalid predicates raise errors.

Recipe reference

All references expose these live properties:

Property Meaning
key Stable registry identity.
type Native short name or custom qualified type name.
output Detached primary output stack.
owner Declaring script filename, or minecraft for untracked native recipes.
exists Whether the registration still exists.
enabled Whether the effective registration participates in matching.
recipeType Type reference for custom and recognized native recipes; nil for unknown third-party native implementations.

Native references additionally expose input. A shaped input is { pattern = {...}, key = {...} }, a shapeless input is a dense ingredient list, and a smelting input is one ingredient descriptor. Returned tables are detached.

Custom references additionally expose ingredients, outputs, data, conditions, and priority. These describe the effective declaration; returned custom definition tables are copies.

recipe:override(definition)

Applies a reversible patch and returns an override handle.

Native changes: output, enabled, and input for recognized shaped, shapeless, and smelting recipes. Shaped input uses { pattern = {...}, key = {...} }; shapeless input is a dense ingredient list; smelting input is one ingredient. Input replacement keeps the recipe reference identity. Unknown third-party recipes support only output and enabled.

Custom changes: ingredients, outputs, output, data, conditions, enabled, and priority inside changes. Schema/identity/type cannot be changed. Custom patches are validated after combination with the existing definition.

Envelope options: changes, priority (patch precedence, default 0), when.owner, when.type, when.properties. A failed condition creates an inactive handle. Output property conditions use stack matching; other custom properties use structural comparison.

local patch = recipe:override { changes = { output = betamoon.stack(265, 2) } }

recipe:disable()

Shorthand for an enabled=false override. Returns a removable handle; does not permanently delete the registration.

local disabled = recipe:disable()

betamoon.recipes:match(query)

Direct matching against supplied ingredient snapshots. See Recipe matching. Supports custom types and native smelting.

Examples: Native recipes, queries.

Clone this wiki locally