mc-recipe · diff

v1.20.1 to v1.14.4

25 added, 25 removed. Audit A to A.

---
name: mc-recipe
- description: Fabric 配方系统。ShapedRecipeJsonBuilder、ShapelessRecipeJsonBuilder。触发词:配方、Recipe、ShapedRecipe、ShapelessRecipe
+ description: Fabric 配方系统。手写 JSON 配方文件。触发词:配方、Recipe、ShapedRecipe、ShapelessRecipe
platform: fabric
- version: "1.20.1"
+ version: "1.14.4"
dependencies: []
mappings: yarn
---
- # 配方系统(Fabric 1.20.1)
+ # 配方系统(Fabric 1.14.4)
## 快速开始
- 通过 DataGen 生成配方(推荐),或手动注册。
+ 本版没有可用的 fabric-datagen 配方 provider(或不应依赖它)。把 JSON 放到数据包目录。
- ### 通过 DataGen(推荐)
+ ### 手写配方 JSON(推荐)
- ```java
- // 在 DataGeneratorInitializer 中
- public class MyRecipeProvider implements DataStreamOutputSupplier.Writer {
- @Override
- public void generate(RegistryWrapper.WrapperLookup registries,
- DataGenerator.GeneratorOutput output,
- ExistingFileHelper existingFileHelper) {
- offerShapedRecipe(output, "my_recipe", MY_ITEM.get(), """
- AAA
- A A
- AAA
- """,
- Map.of('A', Registries.ITEM.getId(Items.DIAMOND))
- );
- }
+ ```json
+ // src/main/resources/data/examplemod/recipes/my_recipe.json
+ {
+ "type": "minecraft:crafting_shaped",
+ "pattern": [
+ "AAA",
+ "A A",
+ "AAA"
+ ],
+ "key": {
+ "A": { "item": "minecraft:diamond" }
+ },
+ "result": {
+ "item": "examplemod:my_item",
+ "count": 1
+ }
}
```
### 手动注册(不推荐)
```java
- // 在 onInitialize() 中
@Override
public void onInitialize() {
- // 手动注册(通常不推荐,数据包更灵活)
+ // 通常不推荐在代码里动态塞原版配方;数据包更灵活
}
```
## Decision: 选择方式
```
IF 使用配方数据
- → DataGen 生成配方 JSON
+ → 手写 JSON 到 data/{modid}/recipes/
IF 在代码中动态创建配方
- → 手动注册(仅用于自定义逻辑)
+ → 仅用于自定义逻辑;不要编造 offerShapedRecipe
```
## 扩展点
| 配合 Skill | 协作说明 |
|-----------|---------|
- | `mc-datagen` | DataGen 生成配方 |
+ | `mc-datagen` | 本版以手写 JSON 为主 |
| `mc-item` | 配方产出物品 |
| `mc-registry` | 配方引用已注册物品 |