AdjacentRecipe

class AdjacentRecipe @JvmOverloads constructor(val name: String, matters: List<CMatter>, val relationType: AdjacentRecipe.RelationType = RelationType.BOTH, customPredicates: List<CRecipePredicate>? = null, val results: List<ResultSupplier>? = null) : CRecipe

A semi-shaped recipe that sits between fully shaped and fully shapeless recipes.

Like a shapeless recipe, items may be placed anywhere in the crafting grid with no fixed positional constraints. Unlike a shapeless recipe, the directions in which neighbouring items may appear are restricted by RelationType:

  • RelationType.CROSS: all neighbouring items must be directly above, below, left, or right; diagonally adjacent items are forbidden (↑ ↓ ← → only).

  • RelationType.DIAGONAL: all neighbouring items must be at a diagonal corner; cross-adjacent items are forbidden (↖ ↗ ↙ ↘ only).

  • RelationType.BOTH: all eight surrounding directions are allowed; no restriction is applied.

Two items are considered "neighbours" if both their x-distance and y-distance are ≤ 1 (i.e. they fall inside the 3×3 area centred on either item). The predicate fails if any item has a neighbour in a direction not included in the chosen RelationType.

Example — RelationType.CROSS

Valid (no pair of items is diagonally adjacent):

_ _ # _ _ _
_ _ # _ _ _
_ _ # # # _
_ _ _ _ _ _
_ _ _ _ _ _
_ _ _ _ _ _

Invalid (the # at (0,0) and the # at (1,1) are diagonal neighbours):

# _ _ _ _ _    ← (0,0)
# # _ _ _ _ ← (0,1) and (1,1): (0,0) is diagonal to (1,1) → forbidden for CROSS
_ _ _ _ _ _
_ _ _ _ _ _
_ _ _ _ _ _
_ _ _ _ _ _

At least 2 items are required; isValidRecipe rejects recipes with fewer items.

Since

5.1.0

Parameters

name

Unique identifier for this recipe.

matters

List of CMatter entries that make up the ingredients. Placement order within the grid is unconstrained (shapeless matching).

relationType

Adjacency rule applied to every placed item. Defaults to RelationType.BOTH.

customPredicates

Additional CRecipePredicate conditions evaluated before the adjacency check. Pass null or omit to apply no extra conditions.

results

ResultSupplier list that produces the craft output. null yields no result.

See also

Constructors

Link copied to clipboard
constructor(name: String, matters: List<CMatter>, relationType: AdjacentRecipe.RelationType = RelationType.BOTH, customPredicates: List<CRecipePredicate>? = null, results: List<ResultSupplier>? = null)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Defines which neighbouring directions are permitted between placed items.

Properties

Link copied to clipboard
open override val items: Map<CoordinateComponent, CMatter>

Mapping of CMatter to their coordinates on the crafting slots.

Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val predicates: List<CRecipePredicate>

List of CRecipePredicate that run during recipe matching. null or empty means no additional conditions.

Link copied to clipboard
Link copied to clipboard
open override val results: List<ResultSupplier>?
Link copied to clipboard
open override val type: CRecipe.Type

Type of this recipe. See CRecipe.Type.

Functions

Link copied to clipboard

Returns CRecipePredicate inspection result on async.

Link copied to clipboard

Returns results of suppliers made asynchronously.

Link copied to clipboard
open fun getRecipePredicateResults(context: CRecipePredicate.Context, whenEmptyDefault: Boolean = true): Boolean

Returns CRecipePredicate inspection result

Link copied to clipboard

Returns results of suppliers made

Link copied to clipboard
open fun getTimes(map: Map<CoordinateComponent, ItemStack>, relation: MappedRelation, shift: Boolean, withoutMass: Boolean = true): Int

Returns the minimum craft count calculated from input item amounts and recipe requirements.

Link copied to clipboard
open override fun isValidRecipe(): Result<Unit>

Validates this recipe's configuration.

Link copied to clipboard

Maximum requires input items amount. Inclusive

Link copied to clipboard

Minimal requires input items amount