容器
GetBrewingStandSlotItem
服务端开发补充
读取酿造台指定槽位的物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取酿造台指定槽位物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| slot | int | 槽位,详见枚举酿造台槽位 |
| pos | tuple(int,int,int) | 容器位置 |
| dimensionId | int | 方块所在维度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 物品信息字典,没有物品则返回None |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.GetBrewingStandSlotItem(serverApi.GetMinecraftEnum().BrewingStandSlotType.SLOT_FUEL, (x, y, z), 0)GetChestBoxSize
服务端开发补充
读取箱子容量。
服务端
method in mod.server.component.chestContainerCompServer.ChestContainerCompServer
- 描述
获取箱子容量大小
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| playerId | None | 该参数已废弃 |
| pos | tuple(int,int,int) | 箱子位置 |
| dimensionId | int | 箱子所在维度,可获取对应维度的常加载区块内箱子容量 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 箱子大小,错误值-1 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateChestBlock(levelId)
comp.GetChestBoxSize(None, (x, y, z), 0)GetChestPairedPosition
服务端开发补充
读取与指定箱子合并成大箱子的另一半位置。
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
获取与箱子A合并成一个大箱子的箱子B的坐标
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pos | tuple(int,int,int) | 箱子A的位置坐标 |
| dimensionId | int | 箱子A所在维度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(int,int,int)或None | 箱子B的位置坐标,假如输入的箱子A坐标上的方块不是箱子类方块或者没有和其他箱子方块组合成一个大箱子,就会返回None |
备注
如果dimensionId不传或传入负值,该接口使用创建组件时的playerId来定位具体维度,且仅可获取玩家附近的方块,若方块位置离玩家太远,可能无法获取到正确的返回信息。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId)
pos = (-1, 4, 34)
dimensionId = 0
otherPos = comp.GetChestPairedPosition(pos, dimensionId)
if otherPos:
print "GetChestPairedPosition success pos=%s otherPos=%s" % (str(pos), str(otherPos))
else:
print "GetChestPairedPosition failed pos=%s" % (str(pos), )GetContainerItem
服务端开发补充
能力:方块容器 · 容器物品 · 物品
作用对象:方块容器
按维度、方块坐标和槽位读取容器物品。
- 仅适用于原文列举的容器,不支持末影箱;需要附加数据时开启 getUserData。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取容器内的物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pos | tuple(int,int,int) | 容器位置 |
| slotPos | int | 容器槽位 |
| dimensionId | int | 方块所在维度 |
| getUserData | bool | 是否获取userData,默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 物品信息字典,没有物品则返回None |
备注
容器的具体类型包括:箱子,陷阱箱,潜影盒,漏斗,木桶,投掷器,发射器
此接口不支持末影箱。对应的末影箱接口请参考 GetEnderChestItem
3.8新增的收纳袋的userdata与箱子类的Items列表不同,它的格式为 {'bundle_weight': {'type': 3, 'value': 7}, 'storage_item_component_content': []} 其中bundle_weight表示收纳袋当前的重量值,示例表示它里面有7个普通可堆叠物品,而storage_item_component_content与箱子的Items类似,但即使槽位为空,它也包含64个元素
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetContainerItem((x,y,z), 0, 2)GetContainerSize
服务端开发补充
能力:容量 · 方块容器
作用对象:方块容器
读取指定容器可用槽位的容量。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取容器容量大小
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pos | tuple(int,int,int) | 箱子位置 |
| dimensionId | int | 容器所在维度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 箱子大小,错误值-1 |
备注
此接口不支持末影箱,因为末影箱的size固定为27。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetContainerSize((x, y, z), 0)GetEnderChestItem
服务端开发补充
能力:末影箱 · 物品
读取玩家末影箱中的物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取末影箱内的物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| playerId | str | 玩家id |
| slotPos | int | 容器槽位 |
| getUserData | bool | 是否获取userData,默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 物品信息字典,没有物品则返回None |
备注
3.8新增的收纳袋的userdata与箱子类的Items列表不同,它的格式为 {'bundle_weight': {'type': 3, 'value': 7}, 'storage_item_component_content': []} 其中bundle_weight表示收纳袋当前的重量值,示例表示它里面有7个普通可堆叠物品,而storage_item_component_content与箱子的Items类似,但即使槽位为空,它也包含64个元素
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.GetEnderChestItem(playerId, 0)GetInputSlotItem
服务端开发补充
读取熔炉输入栏物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取熔炉输入栏物品, 支持使用下面参数清空特定槽位:itemDict为空,为{}, 或itemName为minecraft:air,或者count为0
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pos | tuple(int,int,int) | 容器位置 |
| dimensionId | int | 方块所在维度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 物品信息字典,没有物品则返回None |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
itemName = comp.GetInputSlotItem((x, y, z), 1)GetOpenContainerItem
服务端开发补充
读取开放容器的指定物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取开放容器的物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| playerId | str | 玩家id |
| containerId | int | 开放容器Id枚举 |
| getUserData | bool | 是否获取userData,默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 物品信息字典,没有物品则返回None |
备注
需要在事件CraftItemOutputChangeServerEvent的监听函数里面才能获取正确的结果
开放容器为临时容器,用来保存交互过程中的物品,如铁砧输入位,砂轮输入位
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.GetOpenContainerItem(playerId,serverApi.GetMinecraftEnum().OpenContainerId.AnvilInputContainer, True)GetOutputSlotItem
服务端开发补充
读取熔炉输出栏物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取熔炉输出栏物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pos | tuple(int,int,int) | 容器位置 |
| dimensionId | int | 方块所在维度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 物品信息字典,没有物品则返回None |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
itemName = comp.GetOutputSlotItem((x, y, z), 1)GetPlayerUIItem
服务端开发补充
读取玩家合成容器中的物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取合成容器的物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| playerId | str | 玩家id |
| slot | int | 容器槽位。在isNeteaseUI为True时代表netease_ui_container中对应槽位;isNeteaseUI为False时含义见:容器类型枚举 |
| getUserData | bool | 是否获取userData,默认为False |
| isNeteaseUI | bool | 默认为false,true时获取netease_ui_container的物品 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 物品信息字典,没有物品则返回None |
备注
合成容器包括工作台、铁砧、附魔台、织布机、砂轮、切石机、制图台、锻造台。
所有合成容器槽位共享,不会根据不同容器重新排列。网易ui容器独立于原版合成容器,不同自定义容器中的netease_ui_container共享槽位。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.GetPlayerUIItem(playerId, slot, True)SetBrewingStandSlotItem
服务端开发补充
写入酿造台指定槽位的物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置酿造台指定槽位物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品字典信息, 包含三种key: itemName, auxValue, count |
| slot | int | 槽位,详见枚举酿造台槽位 |
| pos | tuple(int,int,int) | 容器位置 |
| dimensionId | int | 方块所在维度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功设置 |
备注
该接口仅可设置酿造台支持放入的物品
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = {"itemName": "minecraft:blaze_powder", "auxValue": 0, "count": 64}
comp.SetBrewingStandSlotItem(itemDict, serverApi.GetMinecraftEnum().BrewingStandSlotType.SLOT_FUEL, (x, y, z), 0)SetChestBoxItemExchange
服务端开发补充
能力:方块容器 · 容器物品 · 槽位交换
适用限定:槽位交换
交换箱子内两个物品槽位。
服务端
method in mod.server.component.chestContainerCompServer.ChestContainerCompServer
- 描述
交换箱子里物品的槽位
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| playerId | str | 玩家id |
| pos | tuple(int,int,int) | 箱子位置 |
| slotPos1 | int | 箱子槽位1 |
| slotPos2 | int | 箱子槽位2 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置成功返回True,失败返回False |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateChestBlock(playerId)
comp.SetChestBoxItemExchange(playerId, (x,y,z), 0, 1)SetChestBoxItemNum
服务端开发补充
能力:方块容器 · 容器物品 · 数量
作用对象:方块容器
适用限定:数量
设置箱子指定槽位的物品数量。
- 只有数量参数,不能写入或更换槽位里的物品;写入物品用 SpawnItemToContainer。
服务端
method in mod.server.component.chestContainerCompServer.ChestContainerCompServer
- 描述
设置箱子槽位物品数目
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| playerId | None | 该参数已废弃 |
| pos | tuple(int,int,int) | 箱子位置 |
| slotPos | int | 箱子槽位 |
| num | int | 物品数目 |
| dimensionId | int | 方块所在维度,可在对应维度的常加载区块设置方块 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateChestBlock(levelId)
comp.SetChestBoxItemNum(None, (x,y,z), 0, 10, 0)SetInputSlotItem
服务端开发补充
设置熔炉输入栏物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置熔炉输入栏物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品字典信息, 包含三种key: itemName, auxValue, count |
| pos | tuple(int,int,int) | 容器位置 |
| dimensionId | int | 方块所在维度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功设置 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.SetInputSlotItem({"itemName": "minecraft:iron_ore", "auxValue": 0, "count": 1}, (x, y, z), 1)SetPlayerUIItem
服务端开发补充
写入玩家合成容器的物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置合成容器的物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| playerId | str | 玩家id |
| slot | int | 容器槽位。在isNeteaseUI为True时代表netease_ui_container中对应槽位;isNeteaseUI为False时含义见:容器类型枚举 |
| itemDict | dict | 物品信息字典,没有物品则返回None |
| needBack | bool | 是否将容器槽位的已有物品放回至玩家背包中,默认为True。设置为False时,则会直接用itemDict中的物品覆盖容器槽位的已有物品。 |
| isNeteaseUI | bool | 默认为false,true时设置netease_ui_container的物品 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
备注
合成容器包括工作台、铁砧、附魔台、织布机、砂轮、切石机、制图台、锻造台。
如果原槽位有物品,则会将原有物品放入玩家背包。如果玩家背包已满,则会在世界中玩家当前的位置生成对应的物品掉落物。
注意,所有合成容器槽位共享,不会根据不同容器重新排列,没有打开容器或者打开了别的容器,该接口会返回False。
如果设置的是netease_ui_container,即使没有打开容器也能设置成功,所有netease_ui_container槽位共享。
下面情况视为清空特定槽位:itemDict为None,为{}, 或itemName为minecraft:air,或者count为0,同时needBack参数为False
由于创造输出物品生成位比较特殊,该接口已经屏蔽了slot = 50的情况,即无法设置创造输出位的物品。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = {
'itemName': 'minecraft:bow',
'count': 1, # 可填入0达到删除某槽位物品的效果
'auxValue': 0,
}
comp.SetPlayerUIItem(playerId, slot, itemDict)
# 也可以直接使用 comp.SetPlayerUIItem(playerId, slot, None, False) 来清空物品SpawnItemToContainer
服务端开发补充
能力:方块容器 · 容器物品 · 物品
作用对象:方块容器
向容器方块的物品栏生成物品。
- 不支持末影箱,末影箱用 SpawnItemToEnderChest。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
生成物品到容器方块的物品栏
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| slotPos | int | 箱子槽位 |
| blockPos | tuple(int,int,int) | 箱子位置 |
| dimensionId | int | 容器所在维度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
备注
此接口不支持末影箱。对应的末影箱接口请参考 SpawnItemToEnderChest
下面情况视为清空特定槽位:itemDict为空,为{}, 或itemName为minecraft:air,或者count为0
目前该接口支持的容器类型方块:箱子、潜影盒、漏斗、木桶、投掷器、发射器、自定义容器
示例
import mod.server.extraServerApi as serverApi
itemDict = {
'itemName': 'minecraft:bow',
'count': 1, # 可填入0达到删除某槽位物品的效果
'enchantData': [(serverApi.GetMinecraftEnum().EnchantType.BowDamage, 1),],
'auxValue': 0,
'customTips':'§c new item §r',
'extraId': 'abc',
'userData': { },
}
# 生成物品到容器的0号槽位,容器位于维度0,坐标为(x,y,z)
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
comp.SpawnItemToContainer(itemDict, 0, (x,y,z), 0)SpawnItemToEnderChest
服务端开发补充
向末影箱生成物品。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
生成物品到末影箱
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| slotPos | int | 末影箱槽位 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
备注
下面情况视为清空特定槽位:itemDict为空,为{}, 或itemName为minecraft:air,或者count为0
示例
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.SpawnItemToEnderChest(itemDict, 0)