# 合成配方

合成即我们在工作台中的合成。在任意物品配置文件中添加如下内容：

```
recipes:
  crafting_table:
    deadmau5_hat:
      permission: myitems.deadmau5_hat
      enabled: true
      pattern:
      - BXB
      - XBX
      - XXX
      ingredients:
        B: LIGHT_BLUE_WOOL
      result:
        item: myitems:deadmau5_hat
        amount: 1
```

`crafting_table` 指的是下面的这些配方为合成配方，即工作台中的配方。

* permission：使用该配方需要的权限。可以不添加该选项。
* enabled：是否启用该配方。
* pattern：该合成配方的纹路，必须为 **3x3**（即所给示例的样式）。
* ingredients：解释合成配方的纹路，在所给示例中，我们解释了纹路中的 **B** 代表 `LIGHT_BLUE_WOOL`，即原版的深蓝色羊毛，你也可以使用 `namespace:id` 的格式来指代 **IA** 内的物品。
* result：配方的输出物品，其中 `item` 为物品id，`amount` 为物品数量。

配方的配置不需要和物品配置在一起，你可以分开以便于配置与管理。

### 2 x 2 合成配方

将 `pattern` 中的第一行全部为 **XXX**，且 `ingredients` 中未对 **X** 做出解释，即可创建一个 **2 x 2** 的合成配方。

![一个 2x2 的合成配方](https://1341925849-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M28TcKgSDvuFN510qye%2F-MSTgrBSWlCPnl2sB-As%2F-MSThYGI11wu0bA7tPYh%2Fimmagine.png?alt=media\&token=2a9e1c88-9cc3-4c08-b7f5-7c7c6b294119)

### 多合成配方

你可以为一个配方设置多个合成 **pattern**（即合成配方），只需要添加带 `pattern` 开头的选项即可，例如：

```
  pattern_2:
  - XXX
  - XRX
  - XSX
```

整体效果示例：

```
turquoise_sword:
  permission: itemsadder.turquoise_sword
  enabled: true
  pattern:
  - XRX
  - XRX
  - XSX
  pattern_2:
  - XXX
  - XRX
  - XSX
  ingredients:
    R: itemsadder:turquoise
    S: STICK
  result:
    item: itemsadder:turquoise_sword
    amount: 1
```

### 可选属性

每个合成配方还可以设置如下的可选属性：

```
      return_items:
        decrement_durability:
          knife:
            item: knife
            amount: 1
        play_sound:
          name: itemsadder:item.knife.use
          volume: 1
          pitch: 1
```

其中 `decrement_durability` 代表消耗合成配方中某个物品的耐久度，`play_sound` 代表播放音效。

这样做到的合成配方如图所示：

![一个消耗物品耐久的合成配方](https://1341925849-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M28TcKgSDvuFN510qye%2F-M3Mh3ZBfQxNpacgzAEG%2F-M3Mkbai517Vr7pjaV2P%2Fimage.png?alt=media\&token=92f0151d-2856-4699-93b2-c003555b1411)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.superiormc.cn/itemsadder-doc/pei-fang/he-cheng-pei-fang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
