hytale-crafting-recipes
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHytale Crafting Recipes
Hytale合成配方
Complete guide for creating custom crafting recipes including standard crafting, processing (furnace), blueprint, and structural recipes.
本文是创建自定义合成配方的完整指南,涵盖标准合成、加工(熔炉)、蓝图和结构配方。
When to use this skill
何时使用此技能
Use this skill when:
- Adding new crafting recipes for custom items
- Creating processing/smelting recipes
- Implementing blueprint-based crafting
- Setting up recipe requirements and knowledge
- Registering recipes through plugins
- Managing recipe learning/unlocking
在以下场景使用此技能:
- 为自定义物品添加新的合成配方
- 创建加工/熔炼配方
- 实现基于蓝图的合成
- 设置配方要求与解锁条件
- 通过插件注册配方
- 管理配方的学习/解锁
Recipe Architecture Overview
配方架构概述
Hytale uses a JSON-based recipe system with multiple bench types. Recipes are defined in asset files and registered through the CraftingPlugin.
Hytale采用基于JSON的配方系统,支持多种工作台类型。配方定义在资源文件中,并通过CraftingPlugin进行注册。
Bench Types
工作台类型
| BenchType | Description | Example |
|---|---|---|
| Standard grid-based crafting | Crafting Table |
| Time-based conversion with fuel | Furnace, Smelter |
| Blueprint/schematic crafting | Advanced Workbench |
| Multi-block construction | Building Bench |
| Pocket crafting (no bench) | Player inventory |
| BenchType | 说明 | 示例 |
|---|---|---|
| 标准网格合成 | 工作台 |
| 基于时间的燃料转化 | 熔炉、冶炼炉 |
| 蓝图/原理图合成 | 高级工作台 |
| 多结构建造 | 建筑工作台 |
| 随身合成(无需工作台) | 玩家背包 |
Recipe Flow
配方流程
Recipe JSON → CraftingPlugin → BenchRecipeRegistry → Available in Bench UIRecipe JSON → CraftingPlugin → BenchRecipeRegistry → 在工作台UI中可用Recipe JSON Format
配方JSON格式
Basic Structure
基本结构
json
{
"Input": [...],
"Output": [...],
"PrimaryOutput": "hytale:iron_sword",
"BenchRequirement": [...],
"TimeSeconds": 0,
"KnowledgeRequired": false
}json
{
"Input": [...],
"Output": [...],
"PrimaryOutput": "hytale:iron_sword",
"BenchRequirement": [...],
"TimeSeconds": 0,
"KnowledgeRequired": false
}Fields Reference
字段参考
| Field | Required | Type | Description |
|---|---|---|---|
| Yes | Array | Required materials |
| Yes | Array | Resulting items |
| No | String | Main output item ID |
| No | Array | Required bench types |
| No | Number | Processing time (for Processing type) |
| No | Boolean | Must be learned first |
| No | String | Recipe category for UI |
| 字段 | 是否必填 | 类型 | 说明 |
|---|---|---|---|
| 是 | 数组 | 所需材料 |
| 是 | 数组 | 产出物品 |
| 否 | 字符串 | 主要产出物品ID |
| 否 | 数组 | 所需工作台类型 |
| 否 | 数字 | 加工时间(仅适用于Processing类型) |
| 否 | 布尔值 | 是否需要先学习该配方 |
| 否 | 字符串 | 配方在UI中的分类 |
Material Quantity Format
材料数量格式
Materials can be specified in three ways:
材料可通过三种方式指定:
By Item ID
通过物品ID
json
{
"ItemId": "hytale:iron_ingot",
"Quantity": 3
}json
{
"ItemId": "hytale:iron_ingot",
"Quantity": 3
}By Resource Type
通过资源类型
json
{
"ResourceTypeId": "hytale:ore",
"Quantity": 2
}json
{
"ResourceTypeId": "hytale:ore",
"Quantity": 2
}By Item Tag
通过物品标签
json
{
"ItemTag": "wood_planks",
"Quantity": 4
}json
{
"ItemTag": "wood_planks",
"Quantity": 4
}Standard Crafting Recipes
标准合成配方
Shapeless Recipe
无形状配方
Items can be placed anywhere in the grid:
json
{
"Input": [
{ "ItemId": "hytale:iron_ingot", "Quantity": 2 },
{ "ItemId": "hytale:stick", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:iron_sword", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Crafting" }
]
}物品可放置在网格的任意位置:
json
{
"Input": [
{ "ItemId": "hytale:iron_ingot", "Quantity": 2 },
{ "ItemId": "hytale:stick", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:iron_sword", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Crafting" }
]
}Shaped Recipe
有形状配方
Pattern-based placement:
json
{
"Pattern": [
" I ",
" I ",
" S "
],
"Key": {
"I": { "ItemId": "hytale:iron_ingot" },
"S": { "ItemId": "hytale:stick" }
},
"Output": [
{ "ItemId": "hytale:iron_sword", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Crafting" }
]
}基于图案的放置:
json
{
"Pattern": [
" I ",
" I ",
" S "
],
"Key": {
"I": { "ItemId": "hytale:iron_ingot" },
"S": { "ItemId": "hytale:stick" }
},
"Output": [
{ "ItemId": "hytale:iron_sword", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Crafting" }
]
}With Categories
带分类的配方
json
{
"Input": [
{ "ItemId": "hytale:diamond", "Quantity": 2 },
{ "ItemId": "hytale:stick", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:diamond_sword", "Quantity": 1 }
],
"Category": "Weapons",
"BenchRequirement": [
{ "BenchType": "Crafting" }
]
}json
{
"Input": [
{ "ItemId": "hytale:diamond", "Quantity": 2 },
{ "ItemId": "hytale:stick", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:diamond_sword", "Quantity": 1 }
],
"Category": "Weapons",
"BenchRequirement": [
{ "BenchType": "Crafting" }
]
}Fieldcraft (Pocket Crafting)
随身合成(Fieldcraft)
Recipes available without a bench (2x2 grid):
json
{
"Input": [
{ "ItemTag": "log", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:wooden_planks", "Quantity": 4 }
],
"BenchRequirement": [
{ "BenchType": "Fieldcraft" }
]
}Fieldcraft recipes are limited to 2x2 grid and simple combinations.
无需工作台即可使用的配方(2x2网格):
json
{
"Input": [
{ "ItemTag": "log", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:wooden_planks", "Quantity": 4 }
],
"BenchRequirement": [
{ "BenchType": "Fieldcraft" }
]
}随身合成配方限制为2x2网格,仅支持简单组合。
Processing Recipes (Furnace)
加工配方(熔炉)
Time-based conversion with fuel requirement:
json
{
"Input": [
{ "ItemId": "hytale:iron_ore", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:iron_ingot", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Processing" }
],
"TimeSeconds": 10
}基于时间的转化,需要燃料:
json
{
"Input": [
{ "ItemId": "hytale:iron_ore", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:iron_ingot", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Processing" }
],
"TimeSeconds": 10
}Processing with Multiple Outputs
多产出加工配方
json
{
"Input": [
{ "ItemId": "hytale:raw_meat", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:cooked_meat", "Quantity": 1 },
{ "ItemId": "hytale:bone", "Quantity": 1, "Chance": 0.25 }
],
"BenchRequirement": [
{ "BenchType": "Processing" }
],
"TimeSeconds": 8
}json
{
"Input": [
{ "ItemId": "hytale:raw_meat", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:cooked_meat", "Quantity": 1 },
{ "ItemId": "hytale:bone", "Quantity": 1, "Chance": 0.25 }
],
"BenchRequirement": [
{ "BenchType": "Processing" }
],
"TimeSeconds": 8
}Fuel Configuration
燃料配置
Fuel values are defined separately in bench configuration:
json
{
"FuelItems": [
{ "ItemId": "hytale:coal", "BurnTime": 1600 },
{ "ItemId": "hytale:wood", "BurnTime": 300 },
{ "ItemTag": "planks", "BurnTime": 200 }
]
}燃料值在工作台配置中单独定义:
json
{
"FuelItems": [
{ "ItemId": "hytale:coal", "BurnTime": 1600 },
{ "ItemId": "hytale:wood", "BurnTime": 300 },
{ "ItemTag": "planks", "BurnTime": 200 }
]
}Diagram Crafting (Blueprints)
蓝图合成(Diagram Crafting)
Complex recipes that require learning:
json
{
"Input": [
{ "ItemId": "hytale:refined_iron", "Quantity": 5 },
{ "ItemId": "hytale:leather", "Quantity": 3 },
{ "ItemId": "hytale:ruby", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:enhanced_armor", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "DiagramCrafting" }
],
"KnowledgeRequired": true,
"DiagramId": "hytale:enhanced_armor_blueprint"
}需要学习的复杂配方:
json
{
"Input": [
{ "ItemId": "hytale:refined_iron", "Quantity": 5 },
{ "ItemId": "hytale:leather", "Quantity": 3 },
{ "ItemId": "hytale:ruby", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:enhanced_armor", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "DiagramCrafting" }
],
"KnowledgeRequired": true,
"DiagramId": "hytale:enhanced_armor_blueprint"
}Learning Blueprints
学习蓝图
Players must learn diagrams before crafting:
java
// Grant blueprint knowledge
player.getKnowledgeManager().learn("hytale:enhanced_armor_blueprint");
// Check if player knows recipe
boolean knows = player.getKnowledgeManager().hasKnowledge("hytale:enhanced_armor_blueprint");
// Remove knowledge
player.getKnowledgeManager().forget("hytale:enhanced_armor_blueprint");玩家必须先学习蓝图才能进行合成:
java
// 授予蓝图知识
player.getKnowledgeManager().learn("hytale:enhanced_armor_blueprint");
// 检查玩家是否知晓该配方
boolean knows = player.getKnowledgeManager().hasKnowledge("hytale:enhanced_armor_blueprint");
// 移除知识
player.getKnowledgeManager().forget("hytale:enhanced_armor_blueprint");Structural Crafting
结构合成
Multi-block construction recipes:
json
{
"Input": [
{ "ItemId": "hytale:stone_brick", "Quantity": 20 },
{ "ItemId": "hytale:iron_ingot", "Quantity": 4 },
{ "ItemId": "hytale:wooden_door", "Quantity": 1 }
],
"Output": [
{ "StructureId": "hytale:small_house" }
],
"BenchRequirement": [
{ "BenchType": "StructuralCrafting" }
],
"Preview": "structures/small_house_preview.json"
}多结构建造配方:
json
{
"Input": [
{ "ItemId": "hytale:stone_brick", "Quantity": 20 },
{ "ItemId": "hytale:iron_ingot", "Quantity": 4 },
{ "ItemId": "hytale:wooden_door", "Quantity": 1 }
],
"Output": [
{ "StructureId": "hytale:small_house" }
],
"BenchRequirement": [
{ "BenchType": "StructuralCrafting" }
],
"Preview": "structures/small_house_preview.json"
}Bench Requirements
工作台要求
Specify which benches can craft the recipe:
指定可用于合成该配方的工作台:
Single Bench Type
单一工作台类型
json
"BenchRequirement": [
{ "BenchType": "Crafting" }
]json
"BenchRequirement": [
{ "BenchType": "Crafting" }
]Multiple Bench Options
多种工作台选项
json
"BenchRequirement": [
{ "BenchType": "Crafting" },
{ "BenchType": "DiagramCrafting" }
]json
"BenchRequirement": [
{ "BenchType": "Crafting" },
{ "BenchType": "DiagramCrafting" }
]Specific Bench Block
指定工作台方块
json
"BenchRequirement": [
{
"BenchType": "Processing",
"BlockId": "hytale:blast_furnace"
}
]json
"BenchRequirement": [
{
"BenchType": "Processing",
"BlockId": "hytale:blast_furnace"
}
]Tiered Benches
分级工作台
json
"BenchRequirement": [
{
"BenchType": "Crafting",
"MinTier": 2
}
]json
"BenchRequirement": [
{
"BenchType": "Crafting",
"MinTier": 2
}
]Recipe Registration
配方注册
Via JSON Assets
通过JSON资源
Place recipe files in your plugin's asset pack:
assets/
└── Server/
└── Content/
└── Recipes/
├── crafting/
│ ├── iron_sword.json
│ └── iron_pickaxe.json
├── processing/
│ └── iron_smelting.json
└── diagrams/
└── enhanced_armor.json将配方文件放置在插件的资源包中:
assets/
└── Server/
└── Content/
└── Recipes/
├── crafting/
│ ├── iron_sword.json
│ └── iron_pickaxe.json
├── processing/
│ └── iron_smelting.json
└── diagrams/
└── enhanced_armor.jsonVia Plugin Code
通过插件代码
java
public class MyPlugin extends JavaPlugin {
public MyPlugin(JavaPluginInit init) {
super(init);
}
@Override
protected void setup() {
// Get the crafting registry
CraftingRecipeRegistry registry = getCraftingRecipeRegistry();
// Register a recipe programmatically
CraftingRecipe recipe = CraftingRecipe.builder()
.input(ItemId.of("hytale:diamond"), 2)
.input(ItemId.of("hytale:stick"), 1)
.output(ItemId.of("hytale:diamond_sword"), 1)
.benchType(BenchType.Crafting)
.category("Weapons")
.build();
registry.register(recipe);
}
}java
public class MyPlugin extends JavaPlugin {
public MyPlugin(JavaPluginInit init) {
super(init);
}
@Override
protected void setup() {
// 获取合成配方注册器
CraftingRecipeRegistry registry = getCraftingRecipeRegistry();
// 以编程方式注册配方
CraftingRecipe recipe = CraftingRecipe.builder()
.input(ItemId.of("hytale:diamond"), 2)
.input(ItemId.of("hytale:stick"), 1)
.output(ItemId.of("hytale:diamond_sword"), 1)
.benchType(BenchType.Crafting)
.category("Weapons")
.build();
registry.register(recipe);
}
}Recipe Builder API
配方构建器API
java
CraftingRecipe recipe = CraftingRecipe.builder()
// Input materials
.input(ItemId.of("hytale:iron_ingot"), 5)
.input(ItemTag.of("gems"), 2)
.input(ResourceTypeId.of("hytale:magic_essence"), 1)
// Output items
.output(ItemId.of("hytale:magic_sword"), 1)
.secondaryOutput(ItemId.of("hytale:magic_dust"), 1, 0.5f) // 50% chance
// Requirements
.benchType(BenchType.DiagramCrafting)
.requiresKnowledge(true)
.category("Magic Weapons")
// Processing-specific
.processingTime(Duration.ofSeconds(15))
.build();java
CraftingRecipe recipe = CraftingRecipe.builder()
// 输入材料
.input(ItemId.of("hytale:iron_ingot"), 5)
.input(ItemTag.of("gems"), 2)
.input(ResourceTypeId.of("hytale:magic_essence"), 1)
// 产出物品
.output(ItemId.of("hytale:magic_sword"), 1)
.secondaryOutput(ItemId.of("hytale:magic_dust"), 1, 0.5f) // 50%概率
// 要求
.benchType(BenchType.DiagramCrafting)
.requiresKnowledge(true)
.category("Magic Weapons")
// 加工专属设置
.processingTime(Duration.ofSeconds(15))
.build();Knowledge System
知识系统
Recipes can require learning before use:
配方可设置为需要学习后才能使用:
Recipe with Knowledge Requirement
需知识解锁的配方
json
{
"Input": [...],
"Output": [...],
"KnowledgeRequired": true,
"KnowledgeId": "mymod:secret_recipe"
}json
{
"Input": [...],
"Output": [...],
"KnowledgeRequired": true,
"KnowledgeId": "mymod:secret_recipe"
}Managing Player Knowledge
管理玩家知识
java
public class KnowledgeManager {
// Teach recipe from item (like recipe book)
public void teachFromItem(Player player, ItemStack recipeItem) {
if (recipeItem.is(Items.RECIPE_SCROLL)) {
String recipeId = recipeItem.getTag().getString("RecipeId");
player.getKnowledgeManager().learn(recipeId);
player.sendMessage("Learned: " + recipeId);
recipeItem.shrink(1);
}
}
// Teach recipe from NPC
public void teachFromNPC(Player player, String recipeId, int cost) {
if (player.getCurrency() >= cost) {
player.removeCurrency(cost);
player.getKnowledgeManager().learn(recipeId);
player.sendMessage("Purchased recipe knowledge!");
}
}
// Check available recipes for player
public List<CraftingRecipe> getAvailableRecipes(Player player, BenchType bench) {
return CraftingRecipeRegistry.getRecipes(bench).stream()
.filter(r -> !r.requiresKnowledge() ||
player.getKnowledgeManager().hasKnowledge(r.getKnowledgeId()))
.toList();
}
}java
public class KnowledgeManager {
// 通过物品传授配方(如配方卷轴)
public void teachFromItem(Player player, ItemStack recipeItem) {
if (recipeItem.is(Items.RECIPE_SCROLL)) {
String recipeId = recipeItem.getTag().getString("RecipeId");
player.getKnowledgeManager().learn(recipeId);
player.sendMessage("已学习:" + recipeId);
recipeItem.shrink(1);
}
}
// 通过NPC传授配方
public void teachFromNPC(Player player, String recipeId, int cost) {
if (player.getCurrency() >= cost) {
player.removeCurrency(cost);
player.getKnowledgeManager().learn(recipeId);
player.sendMessage("已购买配方知识!");
}
}
// 获取玩家可用的配方
public List<CraftingRecipe> getAvailableRecipes(Player player, BenchType bench) {
return CraftingRecipeRegistry.getRecipes(bench).stream()
.filter(r -> !r.requiresKnowledge() ||
player.getKnowledgeManager().hasKnowledge(r.getKnowledgeId()))
.toList();
}
}Recipe Categories
配方分类
Organize recipes into categories for UI display:
将配方分类以便在UI中展示:
Standard Categories
标准分类
| Category | Description |
|---|---|
| Pickaxes, axes, shovels |
| Swords, bows, staffs |
| Helmets, chestplates, etc. |
| Blocks, decorations |
| Consumables, cooking |
| Intermediate crafting materials |
| Enchanted items, potions |
| Everything else |
| 分类 | 说明 |
|---|---|
| 镐、斧、铲等工具 |
| 剑、弓、法杖等武器 |
| 头盔、胸甲等防具 |
| 方块、装饰物品 |
| 消耗品、烹饪物品 |
| 中间合成材料 |
| 附魔物品、药水 |
| 其他物品 |
Custom Categories
自定义分类
json
{
"Input": [...],
"Output": [...],
"Category": "MyMod:SpecialItems"
}json
{
"Input": [...],
"Output": [...],
"Category": "MyMod:SpecialItems"
}Complete Recipe Examples
完整配方示例
Tiered Armor Set
分级防具套装
json
// Iron Helmet
{
"Pattern": [
"III",
"I I"
],
"Key": {
"I": { "ItemId": "hytale:iron_ingot" }
},
"Output": [
{ "ItemId": "hytale:iron_helmet", "Quantity": 1 }
],
"Category": "Armor",
"BenchRequirement": [
{ "BenchType": "Crafting" }
]
}json
// 铁头盔
{
"Pattern": [
"III",
"I I"
],
"Key": {
"I": { "ItemId": "hytale:iron_ingot" }
},
"Output": [
{ "ItemId": "hytale:iron_helmet", "Quantity": 1 }
],
"Category": "Armor",
"BenchRequirement": [
{ "BenchType": "Crafting" }
]
}Processing Chain
加工链
json
// Step 1: Ore to Raw Metal
{
"Input": [
{ "ItemId": "hytale:iron_ore", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:raw_iron", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Processing", "BlockId": "hytale:crusher" }
],
"TimeSeconds": 5
}
// Step 2: Raw Metal to Ingot
{
"Input": [
{ "ItemId": "hytale:raw_iron", "Quantity": 2 }
],
"Output": [
{ "ItemId": "hytale:iron_ingot", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Processing", "BlockId": "hytale:furnace" }
],
"TimeSeconds": 10
}json
// 步骤1:矿石到原金属
{
"Input": [
{ "ItemId": "hytale:iron_ore", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:raw_iron", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Processing", "BlockId": "hytale:crusher" }
],
"TimeSeconds": 5
}
// 步骤2:原金属到锭
{
"Input": [
{ "ItemId": "hytale:raw_iron", "Quantity": 2 }
],
"Output": [
{ "ItemId": "hytale:iron_ingot", "Quantity": 1 }
],
"BenchRequirement": [
{ "BenchType": "Processing", "BlockId": "hytale:furnace" }
],
"TimeSeconds": 10
}Recipe with Chance Outputs
带概率产出的配方
json
{
"Input": [
{ "ItemId": "hytale:mysterious_ore", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:iron_ingot", "Quantity": 1 },
{ "ItemId": "hytale:gold_nugget", "Quantity": 1, "Chance": 0.3 },
{ "ItemId": "hytale:diamond", "Quantity": 1, "Chance": 0.05 }
],
"BenchRequirement": [
{ "BenchType": "Processing" }
],
"TimeSeconds": 15
}json
{
"Input": [
{ "ItemId": "hytale:mysterious_ore", "Quantity": 1 }
],
"Output": [
{ "ItemId": "hytale:iron_ingot", "Quantity": 1 },
{ "ItemId": "hytale:gold_nugget", "Quantity": 1, "Chance": 0.3 },
{ "ItemId": "hytale:diamond", "Quantity": 1, "Chance": 0.05 }
],
"BenchRequirement": [
{ "BenchType": "Processing" }
],
"TimeSeconds": 15
}Runtime Recipe API
运行时配方API
java
// Get all recipes for a bench type
List<CraftingRecipe> recipes = CraftingRecipeRegistry.getRecipes(BenchType.Crafting);
// Find recipe by output
Optional<CraftingRecipe> recipe = CraftingRecipeRegistry.findByOutput(
ItemId.of("hytale:diamond_sword")
);
// Check if player can craft
boolean canCraft = recipe.map(r -> r.canCraft(player)).orElse(false);
// Execute craft
if (canCraft) {
CraftResult result = recipe.get().craft(player);
if (result.isSuccess()) {
player.getInventory().addItem(result.getOutput());
}
}
// Get recipes by category
List<CraftingRecipe> weapons = CraftingRecipeRegistry.getByCategory("Weapons");
// Check materials
boolean hasMaterials = recipe.get().hasRequiredMaterials(player.getInventory());java
// 获取某工作台类型的所有配方
List<CraftingRecipe> recipes = CraftingRecipeRegistry.getRecipes(BenchType.Crafting);
// 根据产出物品查找配方
Optional<CraftingRecipe> recipe = CraftingRecipeRegistry.findByOutput(
ItemId.of("hytale:diamond_sword")
);
// 检查玩家是否可以合成
boolean canCraft = recipe.map(r -> r.canCraft(player)).orElse(false);
// 执行合成
if (canCraft) {
CraftResult result = recipe.get().craft(player);
if (result.isSuccess()) {
player.getInventory().addItem(result.getOutput());
}
}
// 根据分类获取配方
List<CraftingRecipe> weapons = CraftingRecipeRegistry.getByCategory("Weapons");
// 检查材料是否充足
boolean hasMaterials = recipe.get().hasRequiredMaterials(player.getInventory());Best Practices
最佳实践
Recipe Naming
配方命名
Use consistent, descriptive IDs:
{namespace}:{material}_{item_type}
Examples:
- mymod:iron_sword
- mymod:diamond_pickaxe
- mymod:enchanted_bow使用一致且描述性的ID:
{命名空间}:{材料}_{物品类型}
示例:
- mymod:iron_sword
- mymod:diamond_pickaxe
- mymod:enchanted_bowBalance Considerations
平衡性考量
- Scale input costs with output power
- Consider processing time for valuable items
- Use knowledge requirements for powerful recipes
- Provide recipe progression (basic → advanced)
- 根据产出物品的强度调整输入成本
- 高价值物品需考虑加工时间
- 强力配方使用知识解锁要求
- 提供配方进阶路线(基础→高级)
Testing Recipes
测试配方
java
// Debug command to test recipes
public class RecipeDebugCommand extends CommandBase {
public RecipeDebugCommand() {
super("recipedebug", "Debug recipe information");
}
@Override
protected void execute(CommandContext ctx) {
String recipeId = ctx.get(RECIPE_ID);
Optional<CraftingRecipe> recipe = CraftingRecipeRegistry.get(recipeId);
if (recipe.isEmpty()) {
ctx.sendError("Recipe not found: " + recipeId);
return;
}
CraftingRecipe r = recipe.get();
ctx.sendMessage("Recipe: " + r.getId());
ctx.sendMessage("Bench: " + r.getBenchType());
ctx.sendMessage("Inputs: " + r.getInputs().size());
ctx.sendMessage("Knowledge Required: " + r.requiresKnowledge());
}
}java
// 用于测试配方的调试命令
public class RecipeDebugCommand extends CommandBase {
public RecipeDebugCommand() {
super("recipedebug", "调试配方信息");
}
@Override
protected void execute(CommandContext ctx) {
String recipeId = ctx.get(RECIPE_ID);
Optional<CraftingRecipe> recipe = CraftingRecipeRegistry.get(recipeId);
if (recipe.isEmpty()) {
ctx.sendError("未找到配方:" + recipeId);
return;
}
CraftingRecipe r = recipe.get();
ctx.sendMessage("配方:" + r.getId());
ctx.sendMessage("工作台:" + r.getBenchType());
ctx.sendMessage("输入材料数量:" + r.getInputs().size());
ctx.sendMessage("是否需要知识解锁:" + r.requiresKnowledge());
}
}Troubleshooting
故障排除
Recipe Not Appearing
配方未显示
- Check JSON syntax is valid
- Verify file is in correct asset path
- Ensure BenchType matches the bench being used
- Check if KnowledgeRequired and player has knowledge
- 检查JSON语法是否有效
- 验证文件是否在正确的资源路径中
- 确保BenchType与使用的工作台匹配
- 检查是否设置了KnowledgeRequired且玩家已学习该配方
Crafting Fails
合成失败
- Verify player has all input materials
- Check material quantities match exactly
- Ensure item tags are registered
- Verify bench tier requirements
- 验证玩家是否拥有所有输入材料
- 检查材料数量是否完全匹配
- 确保物品标签已注册
- 验证工作台等级要求
Processing Not Starting
加工未启动
- Check furnace has fuel
- Verify processing time is set
- Ensure input slot has correct item
- Check output slot has space
- 检查熔炉是否有燃料
- 验证是否设置了加工时间
- 确保输入槽中有正确的物品
- 检查输出槽是否有空间
Detailed References
详细参考
For comprehensive documentation:
- - Complete JSON schema for all recipe types
references/recipe-format.md - - Bench configuration and fuel settings
references/bench-configs.md
如需完整文档,请查看:
- - 所有配方类型的完整JSON schema
references/recipe-format.md - - 工作台配置与燃料设置
references/bench-configs.md