--- sidebarDepth: 1 --- # 配方 ## AddBrewingRecipes 服务端 method in mod.server.component.recipeCompServer.RecipeCompServer - 描述 添加酿造台配方的接口 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | brewType | str | recipe_brewing_mix或者recipe_brewing_container,recipe_brewing_mix代表混合酿造配方,recipe_brewing_container代表换容酿造配方 | | inputName | str | 该配方接受的物品 | | reagentName | str | 酿造所需要的额外物品 | | outputName | str | 该配方输出的物品 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否设置成功 | - 备注 - 输出的物品无法和原来的物品堆叠一起 - 对于已有的配方会返回False - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId()) print(comp.AddBrewingRecipes("recipe_brewing_container", "minecraft:potion", "minecraft:gunpowder", "minecraft:splash_potion")) ``` ## AddRecipe 服务端 method in mod.server.component.recipeCompServer.RecipeCompServer - 描述 动态注册配方,支持配方类型详见[配方类型说明] - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | rcp | str或dict | 配方json数据或者配方字典 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否成功 | - 备注 - 注意,按照基岩版1.20的酿造台特性,每个药水槽内一次只能放进一个物品,无法一次放入两个及以上的数量的物品。目前该接口无法在联机大厅生效,后续会修复 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId()) dictData = { "minecraft:recipe_brewing_container": { "description": { "identifier": "netease:splash_to_normal" }, "tags": ["brewing_stand"], "input": "minecraft:splash_potion", "reagent": "minecraft:apple", "output": "minecraft:potion" } } jsonData = '{ "minecraft:recipe_furnace": { "description": { "identifier": "netease:diamond_to_apple" }, "tags": ["furnace"], "input": { "item": "minecraft:diamond", "count": 1 }, "output": { "item": "minecraft:apple" } } }' print "dictionary data:", comp.AddRecipe(dictData) print "json str data:", comp.AddRecipe(jsonData) ``` ## GetRecipeResult 服务端 method in mod.server.component.recipeCompServer.RecipeCompServer - 描述 根据配方id获取配方结果。仅支持合成配方 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | recipeId | str | 配方id,对应配方json文件中的identifier字段 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | list(dict) | list的元素resultDict字典见备注 | - 备注 - resultDict字典内容如下 | 关键字 | 数据类型 | 说明 | | ----------| --------------------- | ---------| | fullItemName | str | 物品的identifier | |auxValue| int | 物品附加值 | |num| int | 物品数目 | - 在基岩版1.20更新后,配方里的部分物品不再是对应单一物品,而是对应某种类型的物品。即'item‘字段所对应的物品有可能是列表类型(list),也可能为字符串类型(str)。如果是字符串类型,则为这个物品的identifier,如果为列表类型,则包含了符合同种类型的所有物品的identifier。例如,木板类型的物品,’item'则会返回包含'minecraft:mangrove_planks', 'minecraft:planks', 'minecraft:warped_planks'等木板在内的列表。 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId()) comp.GetRecipeResult("minecraft:boat") ``` ## GetRecipesByInput 服务端客户端 ### 服务端接口 method in mod.server.component.recipeCompServer.RecipeCompServer - 描述 通过输入物品查询配方 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | inputIdentifier | str | 输入物品的标识符 | | tag | str | 对应配方json中的tags字段里面的值 | | aux | int | 输入物品的附加值, 不传参的话默认为0 | | maxResultNum | int | 最大输出条目数,若大于等于0时,结果超过maxResultNum,则只返回maxResultNum条。默认-1,表示返回全部 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | list(dict) | 返回符合条件的配方列表 | - 备注 - 获取熔炉配方时,若输出物品数量为1时,output使用字符串表示物品identifier及附加值;若输出物品数量大于1时,output为一个dict - 在获取酿造台配方时,不匹配tag标签与aux值,药水的identifier需要输入全称,例如:minecraft:potion_type:long_turtle_master,否则无法获取正确的配方。 - 需要遍历较多数据,不建议频繁调用 - 在基岩版1.20更新后,配方里的部分物品不再是对应单一物品,而是对应某种类型的物品。即'item‘字段所对应的物品有可能是列表类型(list),也可能为字符串类型(str)。如果是字符串类型,则为这个物品的identifier,如果为列表类型,则包含了符合同种类型的所有物品的identifier。例如,木板类型的物品,’item'则会返回包含'minecraft:mangrove_planks', 'minecraft:planks', 'minecraft:warped_planks'等木板在内的列表。 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId()) print(comp.GetRecipesByInput("minecraft:log", "crafting_table", 0, -1)) ``` ### 客户端接口 method in mod.client.component.recipeCompClient.RecipeCompClient - 描述 通过输入物品查询配方 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | inputIdentifier | str | 输入物品的标识符 | | tag | str | 对应配方json中的tags字段里面的值 | | aux | int | 输出物品的附加值, 不传参的话默认为0 | | maxResultNum | int | 最大输出条目数,若大于等于0时,结果超过maxResultNum,则只返回maxResultNum条。默认-1,表示返回全部 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | list(dict) | 返回符合条件的配方列表 | - 备注 - 获取熔炉配方时,若输出物品数量为1时,output使用字符串表示物品identifier及附加值;若输出物品数量大于1时,output为一个dict - 在获取酿造台配方时,不匹配tag标签与aux值,药水的identifier需要输入全称,例如:minecraft:potion_type:long_turtle_master,否则无法获取正确的配方。 - 需要遍历较多数据,不建议频繁调用 - 在基岩版1.20更新后,配方里的部分物品不再是对应单一物品,而是对应某种类型的物品。即'item‘字段所对应的物品有可能是列表类型(list),也可能为字符串类型(str)。如果是字符串类型,则为这个物品的identifier,如果为列表类型,则包含了符合同种类型的所有物品的identifier。例如,木板类型的物品,’item'则会返回包含'minecraft:mangrove_planks', 'minecraft:planks', 'minecraft:warped_planks'等木板在内的列表。 - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateRecipe(clientApi.GetLevelId()) print(comp.GetRecipesByInput("minecraft:log", "crafting_table", 0, -1)) ``` ## GetRecipesByResult 服务端客户端 ### 服务端接口 method in mod.server.component.recipeCompServer.RecipeCompServer - 描述 通过输出物品查询配方所需要的输入材料 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | resultIdentifier | str | 输出物品的标识符 | | tag | str | 对应配方json中的tags字段里面的值 | | aux | int | 输出物品的附加值, 不传参的话默认为0 | | maxResultNum | int | 最大输出条目数,若大于等于0时,结果超过maxResultNum,则只返回maxResultNum条。默认-1,表示返回全部 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | list(dict) | 返回符合条件的配方列表 | - 备注 - 获取熔炉配方时,若输出物品数量为1时,output使用字符串表示物品identifier及附加值;若输出物品数量大于1时,output为一个dict - 在获取酿造台配方时,不匹配tag标签与aux值,药水的identifier需要输入全称,例如:minecraft:potion_type:long_turtle_master,否则无法获取正确的配方。 - 在基岩版1.20更新后,配方里的部分物品不再是对应单一物品,而是对应某种类型的物品。即'item‘字段所对应的物品有可能是列表类型(list),也可能为字符串类型(str)。如果是字符串类型,则为这个物品的identifier,如果为列表类型,则包含了符合同种类型的所有物品的identifier。例如,木板类型的物品,’item'则会返回包含'minecraft:mangrove_planks', 'minecraft:planks', 'minecraft:warped_planks'等木板在内的列表。 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId()) print(comp.GetRecipesByResult("minecraft:boat", "crafting_table", 4, -1)) ``` ### 客户端接口 method in mod.client.component.recipeCompClient.RecipeCompClient - 描述 通过输出物品查询配方所需要的输入材料 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | resultIdentifier | str | 输出物品的标识符 | | tag | str | 对应配方json中的tags字段里面的值 | | aux | int | 输出物品的附加值, 不传参的话默认为0 | | maxResultNum | int | 最大输出条目数,若大于等于0时,结果超过maxResultNum,则只返回maxResultNum条。默认-1,表示返回全部 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | list(dict) | 返回符合条件的配方列表 | - 备注 - 获取熔炉配方时,若输出物品数量为1时,output使用字符串表示物品identifier及附加值;若输出物品数量大于1时,output为一个dict - 在获取酿造台配方时,不匹配tag标签与aux值,药水的identifier需要输入全称,例如:minecraft:potion_type:long_turtle_master,否则无法获取正确的配方。 - 在基岩版1.20更新后,配方里的部分物品不再是对应单一物品,而是对应某种类型的物品。即'item‘字段所对应的物品有可能是列表类型(list),也可能为字符串类型(str)。如果是字符串类型,则为这个物品的identifier,如果为列表类型,则包含了符合同种类型的所有物品的identifier。例如,木板类型的物品,’item'则会返回包含'minecraft:mangrove_planks', 'minecraft:planks', 'minecraft:warped_planks'等木板在内的列表。 - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateRecipe(clientApi.GetLevelId()) print(comp.GetRecipesByResult("minecraft:boat", "crafting_table", 4, -1)) ``` ## RemoveRecipe 服务端 method in mod.server.component.recipeCompServer.RecipeCompServer - 描述 动态禁用配方 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | rcpIdentifier | str | 配方identifier | | rcpTypeStr | str | 配方类型,省略前缀"minecraft"。详见[配方类型说明] | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否成功 | - 备注 - 目前动态移除配方接口不支持移除原生配方 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId()) comp.RemoveRecipe("netease:splash_to_normal", "recipe_brewing_container") comp.RemoveRecipe("netease:diamond_to_apple", "recipe_furnace") ```