first commit
This commit is contained in:
665
docs/mcdocs/1-ModAPI/接口/玩家/背包.md
Normal file
665
docs/mcdocs/1-ModAPI/接口/玩家/背包.md
Normal file
@@ -0,0 +1,665 @@
|
||||
---
|
||||
sidebarDepth: 1
|
||||
---
|
||||
# 背包
|
||||
|
||||
## AddEnchantToInvItem
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
给物品栏的物品添加附魔信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| slotPos | int | 物品栏槽位 |
|
||||
| enchantType | int | 附魔类型,可以查看枚举值文档 |
|
||||
| level | int | 附魔等级 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 设置结果 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.AddEnchantToInvItem(0, serverApi.GetMinecraftEnum().EnchantType.BowDamage, 2)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## AddModEnchantToInvItem
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
给物品栏中物品添加自定义附魔信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| slotPos | int | 物品栏槽位 |
|
||||
| modEnchantId | str | 自定义附魔identifier |
|
||||
| level | int | 自定义附魔等级 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 设置结果 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.AddModEnchantToInvItem(0, "customenchant", 2)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## ChangePlayerItemTipsAndExtraId
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
修改玩家物品的自定义tips和自定义标识符
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| posType | int | [ItemPosType枚举](../../枚举值/ItemPosType.md) |
|
||||
| slotPos | int | 物品栏槽位 |
|
||||
| customTips | str | 物品的自定义tips |
|
||||
| extraId | str | 物品的自定义标识符 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 设置结果 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.ChangePlayerItemTipsAndExtraId(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 0, "自定义tips", "自定义标识符")
|
||||
```
|
||||
|
||||
|
||||
|
||||
## ChangeSelectSlot
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.playerCompServer.PlayerCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
设置玩家当前选中快捷栏物品的index
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| slot | int | 快捷栏物品的index,从0开始,最大为8 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 是否设置成功 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
|
||||
success = comp.ChangeSelectSlot(0)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetCarriedItem
|
||||
|
||||
<span style="display:inline;color:#7575f9">客户端</span>
|
||||
|
||||
method in mod.client.component.itemCompClient.ItemCompClient
|
||||
|
||||
- 描述
|
||||
|
||||
获取右手物品的信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| getUserData | bool | 是否获取物品的userData,默认为False |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| dict | <a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a>,没有物品则返回None |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.client.extraClientApi as clientApi
|
||||
comp = clientApi.GetEngineCompFactory().CreateItem(entityId)
|
||||
carriedData = comp.GetCarriedItem()
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetInvItemEnchantData
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
获取物品栏的物品附魔信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| slotPos | int | 物品栏槽位 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| list(tuple(int,int)) | list中每个tuple由附魔类型([EnchantType枚举](../../枚举值/EnchantType.md))和附魔等级组成。没有附魔则为空list |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.GetInvItemEnchantData(0)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetInvItemModEnchantData
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
获取物品栏的物品自定义附魔信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| slotPos | int | 物品栏槽位 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| list(tuple(str,int)) | list中每个tuple由自定义附魔id和附魔等级组成,没有自定义附魔则为空list |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.GetInvItemModEnchantData(0)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetOffhandItem
|
||||
|
||||
<span style="display:inline;color:#7575f9">客户端</span>
|
||||
|
||||
method in mod.client.component.itemCompClient.ItemCompClient
|
||||
|
||||
- 描述
|
||||
|
||||
获取左手物品的信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| getUserData | bool | 是否获取物品的userData,默认为False |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| dict | <a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a>,没有物品则返回None |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.client.extraClientApi as clientApi
|
||||
comp = clientApi.GetEngineCompFactory().CreateItem(entityId)
|
||||
offhandData = comp.GetOffhandItem()
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetPlayerAllItems
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
获取玩家指定的槽位的批量物品信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| posType | int | [ItemPosType枚举](../../枚举值/ItemPosType.md) |
|
||||
| getUserData | bool | 是否获取userData,默认为False |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| list(dict) | <a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a>的数组,没有物品的位置为None |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.GetPlayerAllItems(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetPlayerItem
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
获取玩家物品,支持获取背包,盔甲栏,副手以及主手物品
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| posType | int | [ItemPosType枚举](../../枚举值/ItemPosType.md) |
|
||||
| slotPos | int | 槽位,获取INVENTORY及ARMOR时需要设置,其他情况写0即可 |
|
||||
| getUserData | bool | 是否获取userData,默认为False |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| dict | <a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a>,没有物品则返回None |
|
||||
|
||||
- 备注
|
||||
- 左右手及装备可以替代GetEntityItem接口获取生物的物品,但背包不行。
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 0)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetSelectSlotId
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
获取玩家当前选中槽位
|
||||
|
||||
- 参数
|
||||
|
||||
无
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| int | 当前槽位,错误时返回-1 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.GetSelectSlotId()
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GetSlotId
|
||||
|
||||
<span style="display:inline;color:#7575f9">客户端</span>
|
||||
|
||||
method in mod.client.component.itemCompClient.ItemCompClient
|
||||
|
||||
- 描述
|
||||
|
||||
获取当前手持的快捷栏的槽id
|
||||
|
||||
- 参数
|
||||
|
||||
无
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| int | 0到8 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.client.extraClientApi as clientApi
|
||||
comp = clientApi.GetEngineCompFactory().CreateItem(entityId)
|
||||
slotId = comp.GetSlotId()
|
||||
```
|
||||
|
||||
|
||||
|
||||
## RemoveEnchantToInvItem
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
给物品栏的物品移除附魔信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| slotPos | int | 物品栏槽位 |
|
||||
| enchantType | int | 附魔类型,可以查看枚举值文档 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 移除结果 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.RemoveEnchantToInvItem(0, serverApi.GetMinecraftEnum().EnchantType.BowDamage)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## RemoveModEnchantToInvItem
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
给物品栏中物品移除自定义附魔信息
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| slotPos | int | 物品栏槽位 |
|
||||
| modEnchantId | str | 自定义附魔identifier |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 移除结果 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.RemoveModEnchantToInvItem(0, "customenchant")
|
||||
```
|
||||
|
||||
|
||||
|
||||
## SetInvItemExchange
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
交换玩家背包物品
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| pos1 | int | 物品位置 |
|
||||
| pos2 | int | 物品位置 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 设置结果 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.SetInvItemExchange(0, 2)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## SetInvItemNum
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
设置玩家背包物品数目
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| slotPos | int | 物品栏槽位 |
|
||||
| num | int | 物品数目,可以通过设置数量为0来达到清除背包物品的效果 |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 设置结果 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.SetInvItemNum(0, 10)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## SetPlayerAllItems
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
添加批量物品信息到指定槽位
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| itemsDictMap | dict | 需要添加的物品的字典,字典的key是tuple([ItemPosType](../../枚举值/ItemPosType.md), slotPos),value是需要添加的<a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a> |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| dict | 设置结果,字典的key是tuple(ItemPosType, slot),value为bool代表该槽位设置是否成功 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
itemsDict = {
|
||||
'itemName': 'minecraft:bow',
|
||||
'count': 1,
|
||||
'enchantData': [(serverApi.GetMinecraftEnum().EnchantType.BowDamage, 1),],
|
||||
'auxValue': 0,
|
||||
'customTips':'§c new item §r',
|
||||
'extraId': 'abc',
|
||||
'userData': { },
|
||||
}
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
itemsDictMap = {}
|
||||
for i in xrange(36):
|
||||
if i % 3 == 0:
|
||||
itemsDictMap[(minecraftEnum.ItemPosType.INVENTORY, i)] = itemsDict
|
||||
itemsDictMap[(minecraftEnum.ItemPosType.CARRIED, 0)] = itemsDict
|
||||
itemsDictMap[(minecraftEnum.ItemPosType.OFFHAND, 0)] = itemsDict
|
||||
comp.SetPlayerAllItems(itemsDictMap)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## SpawnItemToPlayerCarried
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
生成物品到玩家右手
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| itemDict | dict | <a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a> |
|
||||
| playerId | str | 玩家id |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 设置结果 |
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
itemDict = {
|
||||
'itemName': 'minecraft:bow',
|
||||
'count': 1,
|
||||
'enchantData': [(serverApi.GetMinecraftEnum().EnchantType.BowDamage, 1),],
|
||||
'auxValue': 0,
|
||||
'customTips':'§c new item §r',
|
||||
'extraId': 'abc',
|
||||
'userData': { },
|
||||
}
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.SpawnItemToPlayerCarried(itemDict, playerId)
|
||||
```
|
||||
|
||||
|
||||
|
||||
## SpawnItemToPlayerInv
|
||||
|
||||
<span style="display:inline;color:#ff5555">服务端</span>
|
||||
|
||||
method in mod.server.component.itemCompServer.ItemCompServer
|
||||
|
||||
- 描述
|
||||
|
||||
生成物品到玩家背包
|
||||
|
||||
- 参数
|
||||
|
||||
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| itemDict | dict | <a href="../../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a> |
|
||||
| playerId | str | 玩家id |
|
||||
| slotPos | int | 背包槽位(可选) |
|
||||
|
||||
- 返回值
|
||||
|
||||
| <div style="width: 4em">数据类型</div> | 说明 |
|
||||
| :--- | :--- |
|
||||
| bool | 设置结果 |
|
||||
|
||||
- 备注
|
||||
- 当slotPos不设置时,当设置的数量超过单个槽位堆叠的上限时,会将多余的物品设置到另外的空闲槽位.如果生成的物品与背包中有的槽位的物品种类一致,该接口也会将物品增加到这些槽位中。注意:如果背包中剩余的物品数目和增加的物品数目之和大于64,则会生成物品数目到64,但是接口返回失败。
|
||||
|
||||
- 示例
|
||||
|
||||
```python
|
||||
import mod.server.extraServerApi as serverApi
|
||||
itemDict = {
|
||||
'itemName': 'minecraft:bow',
|
||||
'count': 1,
|
||||
'enchantData': [(serverApi.GetMinecraftEnum().EnchantType.BowDamage, 1),],
|
||||
'auxValue': 0,
|
||||
'customTips':'§c new item §r',
|
||||
'extraId': 'abc',
|
||||
'userData': { },
|
||||
}
|
||||
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
|
||||
comp.SpawnItemToPlayerInv(itemDict, playerId, 0)
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user