first commit
This commit is contained in:
247
docs/mcdocs/1-ModAPI/接口/世界/配方.md
Normal file
247
docs/mcdocs/1-ModAPI/接口/世界/配方.md
Normal file
@@ -0,0 +1,247 @@
|
||||
---
|
||||
sidebarDepth: 1
|
||||
---
|
||||
# 配方
|
||||
|
||||
## AddBrewingRecipes
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.recipeCompServer.RecipeCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
添加酿造台配方的接口
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| brewType | str | recipe_brewing_mix或者recipe_brewing_container,recipe_brewing_mix代表混合酿造配方,recipe_brewing_container代表换容酿造配方 |
|
||||
| inputName | str | 该配方接受的物品 |
|
||||
| reagentName | str | 酿造所需要的额外物品 |
|
||||
| outputName | str | 该配方输出的物品 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| 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"))
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetRecipeResult
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.recipeCompServer.RecipeCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
根据配方id获取配方结果。仅支持合成配方
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| recipeId | str | 配方id,对应配方json文件中的identifier字段 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| list(dict) | list的元素resultDict字典见备注 |
|
||||
|
||||
- 备注
|
||||
- resultDict字典内容如下
|
||||
| 关键字 | 数据类型 | 说明 |
|
||||
| ----------| --------------------- | ---------|
|
||||
| itemName | str | 物品名称id |
|
||||
|auxValue| int | 物品附加值 |
|
||||
|num| int | 物品数目 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId())
|
||||
comp.GetRecipeResult(recipe1)
|
||||
comp.GetRecipeResult(recipe2)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetRecipesByInput
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
|
||||
|
||||
### 服务端接口
|
||||
|
||||
<span id="s0"></span>
|
||||
method in mod.server.component.recipeCompServer.RecipeCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
通过输入物品查询配方
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| inputIdentifier | str | 输入物品的标识符 |
|
||||
| tag | str | 对应配方json中的tags字段里面的值 |
|
||||
| aux | int | 输出物品的附加值, 不传参的话默认为0 |
|
||||
| maxResultNum | int | 最大输出条目数,若大于等于0时,结果超过maxResultNum,则只返回maxResultNum条。默认-1,表示返回全部 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| list(dict) | 返回符合条件的配方列表 |
|
||||
|
||||
- 备注
|
||||
- 获取熔炉配方时,若输出物品数量为1时,output使用字符串表示物品identifier及附加值;若输出物品数量大于1时,output为一个dict
|
||||
- 在获取酿造台配方时,不匹配tag标签与aux值,药水的identifier需要输入全称,例如:minecraft:potion_type:long_turtle_master,否则无法获取正确的配方。
|
||||
- 需要遍历较多数据,不建议频繁调用
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId())
|
||||
print(comp.GetRecipesByInput("minecraft:log", "crafting_table", 0, -1))
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 客户端接口
|
||||
|
||||
<span id="c0"></span>
|
||||
method in mod.client.component.recipeCompClient.RecipeCompClient
|
||||
|
||||
- 描述
|
||||
|
||||
通过输入物品查询配方
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| inputIdentifier | str | 输入物品的标识符 |
|
||||
| tag | str | 对应配方json中的tags字段里面的值 |
|
||||
| aux | int | 输出物品的附加值, 不传参的话默认为0 |
|
||||
| maxResultNum | int | 最大输出条目数,若大于等于0时,结果超过maxResultNum,则只返回maxResultNum条。默认-1,表示返回全部 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| list(dict) | 返回符合条件的配方列表 |
|
||||
|
||||
- 备注
|
||||
- 获取熔炉配方时,若输出物品数量为1时,output使用字符串表示物品identifier及附加值;若输出物品数量大于1时,output为一个dict
|
||||
- 在获取酿造台配方时,不匹配tag标签与aux值,药水的identifier需要输入全称,例如:minecraft:potion_type:long_turtle_master,否则无法获取正确的配方。
|
||||
- 需要遍历较多数据,不建议频繁调用
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.client.extraClientApi as clientApi
|
||||
comp = clientApi.GetEngineCompFactory().CreateRecipe(clientApi.GetLevelId())
|
||||
print(comp.GetRecipesByInput("minecraft:log", "crafting_table", 0, -1))
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetRecipesByResult
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
|
||||
|
||||
### 服务端接口
|
||||
|
||||
<span id="s0"></span>
|
||||
method in mod.server.component.recipeCompServer.RecipeCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
通过输出物品查询配方所需要的输入材料
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| resultIdentifier | str | 输出物品的标识符 |
|
||||
| tag | str | 对应配方json中的tags字段里面的值 |
|
||||
| aux | int | 输出物品的附加值, 不传参的话默认为0 |
|
||||
| maxResultNum | int | 最大输出条目数,若大于等于0时,结果超过maxResultNum,则只返回maxResultNum条。默认-1,表示返回全部 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| list(dict) | 返回符合条件的配方列表 |
|
||||
|
||||
- 备注
|
||||
- 获取熔炉配方时,若输出物品数量为1时,output使用字符串表示物品identifier及附加值;若输出物品数量大于1时,output为一个dict
|
||||
- 在获取酿造台配方时,不匹配tag标签与aux值,药水的identifier需要输入全称,例如:minecraft:potion_type:long_turtle_master,否则无法获取正确的配方。
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateRecipe(serverApi.GetLevelId())
|
||||
print(comp.GetRecipesByResult("minecraft:boat", "crafting_table", 4, -1))
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 客户端接口
|
||||
|
||||
<span id="c0"></span>
|
||||
method in mod.client.component.recipeCompClient.RecipeCompClient
|
||||
|
||||
- 描述
|
||||
|
||||
通过输出物品查询配方所需要的输入材料
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| resultIdentifier | str | 输出物品的标识符 |
|
||||
| tag | str | 对应配方json中的tags字段里面的值 |
|
||||
| aux | int | 输出物品的附加值, 不传参的话默认为0 |
|
||||
| maxResultNum | int | 最大输出条目数,若大于等于0时,结果超过maxResultNum,则只返回maxResultNum条。默认-1,表示返回全部 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| list(dict) | 返回符合条件的配方列表 |
|
||||
|
||||
- 备注
|
||||
- 获取熔炉配方时,若输出物品数量为1时,output使用字符串表示物品identifier及附加值;若输出物品数量大于1时,output为一个dict
|
||||
- 在获取酿造台配方时,不匹配tag标签与aux值,药水的identifier需要输入全称,例如:minecraft:potion_type:long_turtle_master,否则无法获取正确的配方。
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.client.extraClientApi as clientApi
|
||||
comp = clientApi.GetEngineCompFactory().CreateRecipe(clientApi.GetLevelId())
|
||||
print(comp.GetRecipesByResult("minecraft:boat", "crafting_table", 4, -1))
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user