Class AdjacentRecipe

  • All Implemented Interfaces:
    io.github.sakaki_aruka.customcrafter.recipe.CRecipe

    
    public final class AdjacentRecipe
     implements 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.

    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