物品
索引
包括物品属性的接口,物品的生成与获取见玩家/背包,实体/背包,方块/容器,物品实体的生成与获取见世界/实体管理
| 接口 | 描述 | |
|---|---|---|
| BindItemToMinecraftModel | 客户端 | 将指定物品作为附作物动态挂接到实体原版模型上,在实体原版模型上渲染指定物品。 |
| BindItemToSkeletonModel | 客户端 | 将指定物品作为附作物动态挂接到实体的网易版骨骼模型,在实体的网易版骨骼模型上指定骨骼渲染指定物品。 |
| CancelShearsDestroyBlockSpeed | 服务端 | 取消剪刀对某一方块的破坏速度设置 |
| CancelShearsDestroyBlockSpeedAll | 服务端 | 取消剪刀对全部方块的破坏速度设置 |
| ChangeArmorTextures | 客户端 | 修改盔甲在场景中显示和在UI中显示的贴图 |
| ChangeItemTexture | 客户端 | 替换物品的贴图,修改后所有用到该贴图的物品都会被改变,后续创建的此类物品也会被改变。会同时修改物品在UI界面上的显示,手持时候的显示与场景掉落的显示。 |
| GetAllEnchantsInfo | 服务端 | 获取目前已注册的所有附魔信息 |
| GetAllEnchantsInfo | 客户端 | 获取目前已注册的所有附魔信息 |
| GetBindBoneForBindItem | 客户端 | 查询获取实体上已绑定的物品附着物所绑定的骨骼名称。 |
| GetBindItemOffset | 客户端 | 查询获取实体上的物品附着物相对骨骼的位置偏移。 |
| GetBindItemRotation | 客户端 | 查询获取实体上的物品附着物相对骨骼的旋转角度。 |
| GetBindItemScale | 客户端 | 查询获取实体上的物品附着物的缩放比例。 |
| GetCustomName | 服务端 | 获取物品的自定义名称,与铁砧修改的名称一致 |
| GetFishingLineColor | 服务端 | 获取服务端当前设置的钓鱼线颜色 |
| GetFishingLineColor | 客户端 | 获取钓鱼线的颜色 |
| GetFishingLineMax | 服务端 | 获取服务端当前设置的钓鱼线最大长度 |
| GetFishingLineMax | 客户端 | 获取钓鱼线的最大长度 |
| GetIconInfo | 客户端 | 获取物品图标纹理在图集中的UV坐标位置与尺寸信息 |
| GetItemBasicInfo | 服务端 | 获取物品的基础信息 |
| GetItemBasicInfo | 客户端 | 获取物品的基础信息 |
| GetItemDefenceAngle | 服务端 | 获取盾牌物品的抵挡角度范围 |
| GetItemDurability | 服务端 | 获取指定槽位的物品耐久 |
| GetItemEffectName | 客户端 | 获取物品的状态描述,如:§7保护 0§r |
| GetItemFormattedHoverText | 客户端 | 获取物品的格式化hover文本,如:§f灾厄旗帜§r |
| GetItemHoverName | 客户端 | 获取物品的hover名称,如:灾厄旗帜§r |
| GetItemInfoByBlockName | 服务端 | 通过方块名称及aux值获取物品信息 |
| GetItemLayer | 服务端 | 获取物品的叠加贴图。物品叠加贴图详见SetItemLayer |
| GetItemMaxDurability | 服务端 | 获取指定槽位的物品耐最大耐久 |
| GetItemTags | 服务端 | 获取物品的tags列表,包含原版minecraft:tags中定义的tags,以及netease_tags中注册并挂载到物品上的自定义标签 |
| GetItemTags | 客户端 | 获取物品的tags列表,包含原版minecraft:tags中定义的tags,以及netease_tags中注册并挂载到物品上的自定义标签 |
| GetItemTexture | 客户端 | 获取item_texture.json中物品的贴图路径。 |
| GetLoadItems | 服务端 | 获取已经加载的物品id |
| GetUserDataInEvent | 服务端 | 使物品相关服务端事件的物品信息字典参数带有userData。在mod初始化时调用即可 |
| GetUserDataInEvent | 客户端 | 使物品相关客户端事件的物品信息字典参数带有userData。在mod初始化时调用即可 |
| LookupItemByName | 服务端 | 判定指定identifier的物品是否存在 |
| LookupItemsByItemTag | 服务端 | 根据netease_tags中注册的物品tag名,查找该tag下所有物品,支持#引用的标签自动展开;同一tag名被多个模组注册时自动合并去重;未注册的原版tag可直接查询 |
| LookupItemsByItemTag | 客户端 | 根据netease_tags中注册的物品tag名,查找该tag下所有物品,支持#引用的标签自动展开;同一tag名被多个模组注册时自动合并去重;未注册的原版tag可直接查询 |
| RemoveItemLayer | 服务端 | 移除物品的叠加贴图。物品叠加贴图详见SetItemLayer |
| SetAttackDamage | 服务端 | 设置物品的攻击伤害值 |
| SetBindBoneForBindItem | 客户端 | 改变实体上已绑定的物品附着物所绑定的骨骼,又或者移除该物品附着物。 |
| SetBindItemOffset | 客户端 | 设置实体上的物品附着物相对骨骼的位置偏移。 |
| SetBindItemRotation | 客户端 | 设置实体上的物品附着物相对骨骼的旋转角度。 |
| SetBindItemScale | 客户端 | 设置实体上的物品附着物的缩放比例。 |
| SetCompassEntity | 客户端 | 设置指南针朝向的实体 |
| SetCompassTarget | 客户端 | 设置指南针的朝向位置 |
| SetCustomName | 服务端 | 设置物品的自定义名称,与使用铁砧重命名一致 |
| SetFishingLineColor | 服务端 | 设置钓鱼线的颜色,设置后会自动同步到所有客户端。 |
| SetFishingLineMax | 服务端 | 设置钓鱼线的最大长度(超过此长度会断线),设置后会自动同步到所有客户端。 |
| SetItemDefenceAngle | 服务端 | 设置盾牌物品的抵挡角度范围 |
| SetItemDurability | 服务端 | 设置物品的耐久值 |
| SetItemLayer | 服务端 | 设置物品的叠加贴图,可以在物品的上层与下层叠加自定义贴图。具体使用可参考CustomItemsMod示例。 |
| SetItemMaxDurability | 服务端 | 设置物品的最大耐久值 |
| SetItemTierLevel | 服务端 | 设置工具类物品的挖掘等级 |
| SetItemTierSpeed | 服务端 | 设置工具类物品的挖掘速度(可通过userData中的ModTierSpeed获取挖掘速度) |
| SetMaxStackSize | 服务端 | 设置物品的最大堆叠数量(存档) |
| SetShearsDestroyBlockSpeed | 服务端 | 设置剪刀对某一方块的破坏速度 |
BindItemToMinecraftModel
客户端开发补充
把物品作为附着物挂到实体原版模型上显示。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
将指定物品作为附作物动态挂接到实体原版模型上,在实体原版模型上渲染指定物品。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要挂接到的实体的id。 |
| itemDict | dict | 需要挂接的物品的信息字典。 |
| boneName | str | 需要挂接到的骨骼名称(不区分大小写),默认值为"root" |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
| offset | tuple(float,float,float) | 绑定物品的偏移量,相对绑定entity脚下中心,默认值为(0, 0, 0) |
| rotation | tuple(float,float,float) | 绑定物品的三维旋转(单位为度,按照ZYX顺序旋转),默认值为(0, 0, 0) |
| scale | float | 绑定物品的缩放比例。默认值为1.0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 绑定成功后,返回创建的物品模型id。失败则返回-1 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)BindItemToSkeletonModel
客户端开发补充
能力:骨骼绑定 · 实体 · 物品
作用对象:实体
把物品挂到实体网易骨骼模型的指定骨骼上。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
将指定物品作为附作物动态挂接到实体的网易版骨骼模型,在实体的网易版骨骼模型上指定骨骼渲染指定物品。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要挂接到的实体的id。 |
| itemDict | dict | 需要挂接的物品的信息字典。 |
| boneName | str | 需要挂接到的骨骼名称(不区分大小写),默认值为"root" |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
| offset | tuple(float,float,float) | 绑定物品的偏移量,相对绑定的骨骼中心,默认值为(0, 0, 0) |
| rotation | tuple(float,float,float) | 绑定物品的三维旋转(单位为度,按照ZYX顺序旋转),默认值为(0, 0, 0) |
| scale | float | 绑定物品的缩放比例。默认值为1.0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 绑定成功后,返回创建的物品模型id。失败则返回-1 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头顶绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToSkeletonModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)CancelShearsDestroyBlockSpeed
服务端开发补充
取消剪刀对指定方块的破坏速度覆盖。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
取消剪刀对某一方块的破坏速度设置
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| blockName | str | 方块名称,包含命名空间 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(entityId)
comp.CancelShearsDestroyBlockSpeed("minecraft:obsidian")CancelShearsDestroyBlockSpeedAll
服务端开发补充
取消剪刀对全部方块的破坏速度覆盖。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
取消剪刀对全部方块的破坏速度设置
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(entityId)
comp.CancelShearsDestroyBlockSpeedAll()ChangeArmorTextures
客户端开发补充
替换盔甲在世界和界面中的显示贴图。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
修改盔甲在场景中显示和在UI中显示的贴图
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| armorIdentifier | str | 盔甲标识符,格式[namespace:name:auxvalue],auxvalue默认为0 |
| texturesDict | dict | 场景中目标贴图的映射表,格式可参考"definitions/attachables/diamond_helmet.json"配置 |
| uiIconTexture | str | 盔甲UI图标的贴图, 为None或者""的话表示不修改UI上的图标 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 修改是否成功(因为采用延迟加载,此处返回成功不代表参数中的贴图路径正确,路径错误会导致渲染时贴图丢失显示异常) |
备注
无法跟物品的贴图动画同时使用
有一定性能消耗,不建议频繁调用
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
# 修改钻石头盔的显示为黄金头盔
textureDict = {
"default": "textures/models/armor/gold_1",
"enchanted": "textures/misc/enchanted_item_glint"
}
print(comp.ChangeArmorTextures("minecraft:diamond_helmet", textureDict, "textures/items/gold_helmet"))ChangeItemTexture
客户端开发补充
替换物品共享贴图,影响界面、手持和掉落显示。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
替换物品的贴图,修改后所有用到该贴图的物品都会被改变,后续创建的此类物品也会被改变。会同时修改物品在UI界面上的显示,手持时候的显示与场景掉落的显示。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| identifier | str | 物品标识符,格式[namespace:name:auxvalue],auxvalue默认为0 |
| texturePath | str | 贴图路径 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否修改成功(因为采用延迟加载,此处返回成功不代表贴图路径正确,路径错误会导致渲染时贴图丢失显示异常) |
备注
因为会同时修改用到此贴图的所有物品,所以使用的时候尽量谨慎,不建议改原版的物品,建议只用于修改用到自定义新贴图的物品。
序列帧贴图物品暂不支持动态修改贴图
部分物品有特殊逻辑无法修改:箱子,旗帜,生物头颅,盾牌,三叉戟,鱼杆
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
print(comp.ChangeItemTexture("mytool:hatchet_1:0", "textures/items/hatchet_1"))GetAllEnchantsInfo
服务端开发补充
读取当前已注册的全部附魔信息。
客户端开发补充
读取当前已注册的全部附魔信息。
服务端客户端
服务端接口
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取目前已注册的所有附魔信息
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(dict) | 附魔信息字典附魔信息字典 |
备注
1.目前能获取原生及自定义附魔信息 2.由于原生附魔的消耗存在不相同的计算规则,目前不提供原生附魔的costs信息
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetAllEnchantsInfo()客户端接口
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取目前已注册的所有附魔信息
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(dict) | 附魔信息字典附魔信息字典 |
备注
1.目前能获取原生及自定义附魔信息 2.由于原生附魔的消耗存在不相同的计算规则,目前不提供原生附魔的costs信息
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetAllEnchantsInfo()GetBindBoneForBindItem
客户端开发补充
读取物品附着的绑定骨骼。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
查询获取实体上已绑定的物品附着物所绑定的骨骼名称。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要查询的实体的id。 |
| itemModelId | int | 需要查询的物品模型id。 |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 绑定的骨骼名称。查询失败返回None |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)
# 使这个苹果绑定到手部
comp.SetBindBoneForBindItem(player_id, itemModelId, "rightarm")
# 获取当前绑定的骨骼名称
boneName = comp.GetBindBoneForBindItem(player_id, itemModelId)
print("The bone name of the bind item is:", boneName)GetBindItemOffset
客户端开发补充
读取物品附着的位置偏移。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
查询获取实体上的物品附着物相对骨骼的位置偏移。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要查询的实体的id。 |
| itemModelId | int | 需要查询的物品模型id。 |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float) | 物品的位置偏移,查询如果失败返回None |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)
# 使这个苹果往x方向偏移10个单位
offset = comp.GetBindItemOffset(player_id, itemModelId)
print("offset is:", offset)GetBindItemRotation
客户端开发补充
读取物品附着的旋转角度。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
查询获取实体上的物品附着物相对骨骼的旋转角度。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要查询的实体的id。 |
| itemModelId | int | 需要查询物品模型id。 |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float) | 返回物品的三维旋转,查询如果失败返回None |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"enchantData" : [], # 附魔信息
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)
# 获取这个苹果旋转角度
rotation = comp.GetBindItemRotation(player_id, itemModelId)
print("rotation is:", rotation)GetBindItemScale
客户端开发补充
读取物品附着的缩放比例。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
查询获取实体上的物品附着物的缩放比例。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要查询的实体的id。 |
| itemModelId | int | 需要查询的物品模型id。 |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 绑定物品的缩放比例。查询如果失败返回None |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)
# 使这个苹果变大1.5倍
scale = comp.GetBindItemScale(player_id, itemModelId)
print("scale is:", scale)GetCustomName
服务端开发补充
读取物品自定义名称,与铁砧重命名对应。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取物品的自定义名称,与铁砧修改的名称一致
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典。如果是接口获取的itemDict,应该包含userData,即getUserData应该为True |
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 自定义名称 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
name = comp.GetCustomName(itemDict)GetFishingLineColor
服务端开发补充
读取当前钓鱼线颜色。
关联接口:SetFishingLineColor (server) · SetFishingLineColor (server)
客户端开发补充
读取当前钓鱼线颜色。
服务端客户端
服务端接口
method in mod.server.component.fishingLineCompServer.FishingLineCompServer
- 描述
获取服务端当前设置的钓鱼线颜色
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 鱼竿物品的完整名称,如 "minecraft:fishing_rod" 或自定义鱼竿名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float) | rgb颜色值,每个分量0.0-1.0 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFishingLine(playerId)
color = comp.GetFishingLineColor("mymod:custom_fishing_rod")
print color客户端接口
method in mod.client.component.fishingLineCompClient.FishingLineCompClient
- 描述
获取钓鱼线的颜色
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 鱼竿物品的完整名称,如 "minecraft:fishing_rod" 或自定义鱼竿名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float) | rgb颜色值,每个分量0.0-1.0 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateFishingLine(playerId)
color = comp.GetFishingLineColor("mymod:custom_fishing_rod")
print colorGetFishingLineMax
服务端开发补充
读取钓鱼线最大长度。
关联接口:SetFishingLineMax (server) · SetFishingLineMax (server)
客户端开发补充
读取钓鱼线最大长度。
服务端客户端
服务端接口
method in mod.server.component.fishingLineCompServer.FishingLineCompServer
- 描述
获取服务端当前设置的钓鱼线最大长度
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 鱼竿物品的完整名称,如 "minecraft:fishing_rod" 或自定义鱼竿名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 最大长度,单位为格 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFishingLine(playerId)
maxLen = comp.GetFishingLineMax("mymod:custom_fishing_rod")客户端接口
method in mod.client.component.fishingLineCompClient.FishingLineCompClient
- 描述
获取钓鱼线的最大长度
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 鱼竿物品的完整名称,如 "minecraft:fishing_rod" 或自定义鱼竿名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 最大长度,单位为格 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateFishingLine(playerId)
maxLen = comp.GetFishingLineMax("mymod:custom_fishing_rod")GetIconInfo
客户端开发补充
能力:图集UV
按物品名与附加值读取物品图标在图集中的归一化UV与尺寸;方块类物品在atlas.terrain、普通物品在atlas.items。按贴图键查方块贴图用GetTextureAtlasUV。
- 返回值不含图集名:方块类物品图标位于atlas.terrain,普通物品位于atlas.items。
- 获取失败返回None。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取物品图标纹理在图集中的UV坐标位置与尺寸信息
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典,格式 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float,float) | 物品图标在图集中的UV坐标与尺寸(u0,v0,w,h),u0,v0为左上角归一化UV坐标,w为纹理宽度,h为纹理高度。获取失败返回None |
备注
获取的是物品图标所在图集的UV信息,方块类物品的图标位于atlas.terrain图集,普通物品图标位于atlas.items图集,两者返回的均为归一化UV坐标
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
uv = comp.GetIconInfo({"itemName": "minecraft:apple", "auxValue": 0})
# uv = (0.1064453125, 0.0009765625, 0.015625, 0.015625)GetItemBasicInfo
服务端开发补充
能力:攻击力 · 物品 · 堆叠上限
读取物品基础信息。
客户端开发补充
能力:攻击力 · 物品 · 堆叠上限
读取物品基础信息。
服务端客户端
服务端接口
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取物品的基础信息
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxvalue,默认为0 |
| isEnchanted | bool | 是否附魔,默认为False。用于返回的id_aux |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 基础信息,详见备注 |
备注
auxValue默认值是0,可以不设置。如果物品不存在,返回值为None
| 关键字 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 本地化的物品名字 |
| maxStackSize | int | 物品最大堆叠数目 |
| maxDurability | int | 物品最大耐久值 |
| id_aux | int | 主要用于客户端的ui绑定,详见客户端接口 |
| tierDict | dict | 自定义方块定义的挖掘相关的属性 netease:tier,没有设置时返回None |
| itemCategory | str | 创造栏分类 |
| itemType | str | 物品类型 |
| customItemType | str | 自定义物品类型 |
| tags | list(str) | 物品的tags列表,如['minecraft:is_food'] |
| customTips | str | 自定义物品/方块tips |
| itemTierLevel | int | 工具等级 |
| fuelDuration | float | 燃料时长 |
| foodNutrition | int | 食物营养值 |
| foodSaturation | float | 食物饱食度 |
| weaponDamage | int | 武器攻击力 |
| armorDefense | int | 防具防御力 |
| armorSlot | int | 防具槽位 |
| armorToughness | int | 防具韧性 |
| armorKnockbackResistance | float | 防具击退抗性 |
| enchant_slot_type | int | 附魔槽位枚举标志 自定义附魔文档 |
部分原版物品较为特殊,获取不到个别字段的返回值 方块类燃料获取不到燃料时长,弓、弩获取不到武器攻击力,蛋糕获取不到营养值和饱食度,马铠获取不到防具防御力,上述物品获取对应字段返回值为0
创造栏分类说明
| 创造栏分类 | 意义 |
|---|---|
| construction | 建筑 |
| nature | 自然 |
| equipment | 装备 |
| items | 物品 |
| custom | 自定义 |
| 空字符串 | 不在创造栏 |
- 物品类型,值为空字符串或者下列类型名之一:
| 类型名 | 意义 |
|---|---|
| book | 书 |
| sword | 剑 |
| shears | 剪刀 |
| axe | 斧头 |
| clock | 时钟 |
| bucket | 桶 |
| fishing_rod | 钓鱼竿 |
| hoe | 锄头 |
| shovel | 锹 |
| pickaxe | 镐 |
| dye | 骨粉 |
| food | 食物 |
| block | 方块 |
| armor | 盔甲 |
| custom_ranged_weapon | 自定义远程武器 |
| compass | 指南针 |
| trident | 三叉戟 |
| potion | 药水 |
| crossbow | 弩 |
自定义物品类型物品类型,值为行为包里minecraft:item内description的custom_item_type字段值
工具等级代表不同的材质,没有工具等级时为值-1,工具等级与材质对应关系如下
| 工具等级 | 材质 |
|---|---|
| 0 | 木制/金制工具 |
| 1 | 石制工具 |
| 2 | 铁制工具 |
| 3 | 钻石工具 |
| 4 | 合金工具 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
info = comp.GetItemBasicInfo("minecraft:bow")
enchant_slot_type = info["enchant_slot_type"]
support_sword = (enchant_slot_type & EnchantSlotType.SWORD) > 0客户端接口
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取物品的基础信息
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxvalue,默认为0 |
| isEnchanted | bool | 是否附魔,默认为False。用于返回的id_aux |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 基础信息字典,见备注 |
备注
auxValue默认值是0,可以不设置。如果物品不存在,返回值为None
| 关键字 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 本地化的物品名字 |
| maxStackSize | int | 物品最大堆叠数目 |
| maxDurability | int | 物品最大耐久值 |
| id_aux | int | 用于给UI的inventory_item_renderer类型控件绑定#item_id_aux字段,详见备注 |
| tierDict | dict | 自定义方块定义的挖掘相关的属性 netease:tier,没有设置时返回None |
| itemCategory | str | 创造栏分类 |
| itemType | str | 物品类型 |
| customItemType | str | 自定义物品类型 |
| tags | list(str) | 物品的tags列表,如['minecraft:is_food'] |
| customTips | str | 自定义物品/方块tips |
| itemTierLevel | int | 工具等级 |
| fuelDuration | float | 燃料时长 |
| foodNutrition | int | 食物营养值 |
| foodSaturation | float | 食物饱食度 |
| weaponDamage | int | 武器攻击力 |
| armorDefense | int | 防具防御力 |
| armorSlot | int | 防具槽位 |
| armorToughness | int | 防具韧性 |
| armorKnockbackResistance | float | 防具击退抗性 |
| enchant_slot_type | int | 附魔槽位枚举标志 自定义附魔文档 |
部分原版物品较为特殊,获取不到个别字段的返回值 方块类燃料获取不到燃料时长,弓、弩获取不到武器攻击力,蛋糕获取不到营养值和饱食度,马铠获取不到防具防御力,上述物品获取对应字段返回值为0
id_aux字段的示例: 在ui中添加一个inventory_item_renderer控件以及#item_id_aux的绑定
"my_item_renderer": {
"type": "custom",
"renderer": "inventory_item_renderer",
"size": [ 160, 160 ],
"bindings" : [
{
"binding_condition" : "always_when_visible",
"binding_name" : "#GetItemIdAux",
"binding_name_override" : "#item_id_aux"
}
]
}然后在python中添加绑定回调
@ViewBinder.binding(ViewBinder.BF_BindInt, "#GetItemIdAux")
def OnStarkGridResize(self):
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
info = comp.GetItemBasicInfo("minecraft:bow", 0, True)
return info['id_aux']- 创造栏分类说明
| 创造栏分类 | 意义 |
|---|---|
| construction | 建筑 |
| nature | 自然 |
| equipment | 装备 |
| items | 物品 |
| custom | 自定义 |
- 物品类型,值为空字符串或者下列类型名之一:
| 类型名 | 意义 |
|---|---|
| book | 书 |
| sword | 剑 |
| shears | 剪刀 |
| axe | 斧头 |
| clock | 时钟 |
| bucket | 桶 |
| fishing_rod | 钓鱼竿 |
| hoe | 锄头 |
| shovel | 锹 |
| pickaxe | 镐 |
| dye | 骨粉 |
| food | 食物 |
| block | 方块 |
| armor | 盔甲 |
| custom_ranged_weapon | 自定义远程武器 |
| compass | 指南针 |
| trident | 三叉戟 |
| potion | 药水 |
| crossbow | 弩 |
自定义物品类型物品类型,值为行为包里minecraft::item内的custom_item_type字段值
工具等级代表不同的材质,没有工具等级时为值-1,工具等级与材质对应关系如下
| 工具等级 | 材质 |
|---|---|
| 0 | 木制/金制工具 |
| 1 | 石制工具 |
| 2 | 铁制工具 |
| 3 | 钻石工具 |
| 4 | 合金工具 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
info = comp.GetItemBasicInfo("minecraft:bow")
enchant_slot_type = info["enchant_slot_type"]
support_sword = (enchant_slot_type & EnchantSlotType.SWORD) > 0GetItemDefenceAngle
服务端开发补充
读取盾牌格挡的抵挡角度。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取盾牌物品的抵挡角度范围
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| posType | int | ItemPosType枚举 |
| slotPos | int | 槽位 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(float) | 角度范围 |
备注
当传入的玩家id不正确,玩家手里没手持盾牌,传入不存在的槽位时,会返回空列表
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.GetItemDefenceAngle(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 0)GetItemDurability
服务端开发补充
能力:耐久度 · 物品
读取指定物品位置的当前耐久;修改耐久时需另行计算目标值并写入。
- 槽位对背包和盔甲栏才有意义;读取当前耐久不等于读取最大耐久。
关联接口:SetItemDurability (server) · GetPlayerItem (server) · ItemPosType (common)
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取指定槽位的物品耐久
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| posType | int | ItemPosType枚举 |
| slotPos | int | 槽位,当posType为ItemPosType.INVENTORY或ItemPosType.ARMOR时才有意义 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 物品的耐久值 |
备注
posType设置成serverApi.GetMinecraftEnum().ItemPosType.INVENTORY可替代GetInvItemDurability;posType设置成serverApi.GetMinecraftEnum().ItemPosType.ARMOR可替代GetEquItemDurability;
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.GetItemDurability(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 1)
#替代GetInvItemDurability的方法
comp.GetItemDurability(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 1)
#替代GetEquItemDurability的方法
comp.GetItemDurability(serverApi.GetMinecraftEnum().ItemPosType.ARMOR, 1)GetItemEffectName
客户端开发补充
读取物品状态效果描述文字。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取物品的状态描述,如:§7保护 0§r
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxValue,默认为不指定auxValue(0) |
| userData | dict | 物品userData,默认为None |
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 物品的状态描述 |
- 示例
# 灾厄旗帜
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetItemEffectName("minecraft:banner", 15, {'Type': 1})GetItemFormattedHoverText
客户端开发补充
读取带格式的物品悬浮说明。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取物品的格式化hover文本,如:§f灾厄旗帜§r
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxValue,默认为不指定auxValue(0) |
| showCategory | bool | 是否包括item的类别信息,默认False |
| userData | dict | 物品userData,默认为None |
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 物品的格式化hover文本 |
- 示例
# 灾厄旗帜
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetItemFormattedHoverText("minecraft:banner", 15, True, {'Type': 1})GetItemHoverName
客户端开发补充
读取物品显示用的悬浮名称。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取物品的hover名称,如:灾厄旗帜§r
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxValue,默认为不指定auxValue(0) |
| userData | dict | 物品userData,默认为None |
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 物品hover名称 |
- 示例
# 灾厄旗帜
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetItemHoverName("minecraft:banner", 15, {'Type': 1})GetItemInfoByBlockName
服务端开发补充
根据方块名称和附加值查询对应物品信息。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
通过方块名称及aux值获取物品信息
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| blockName | str | 方块identifier |
| auxValue | int | aux值 |
| isLegacy | bool | 方块是否为原生方块,默认为True,即使用旧版aux对应的state |
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 物品信息字典 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
blockDict = comp.GetItemInfoByBlockName("minecraft:stone")GetItemLayer
服务端开发补充
读取物品叠加贴图层。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取物品的叠加贴图。物品叠加贴图详见SetItemLayer
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| layer | int | 贴图的层级。可以为-2,-1,1,2,3。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 贴图的名字,不存在返回None |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
texture = comp.GetItemLayer(itemDict, 1)GetItemMaxDurability
服务端开发补充
读取指定槽位物品的最大耐久。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取指定槽位的物品耐最大耐久
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| posType | int | ItemPosType枚举 |
| slotPos | int | 槽位,当posType为ItemPosType.INVENTORY或ItemPosType.ARMOR时才有意义 |
| isUserData | bool | 如果为True,则只尝试获取该物品userData特殊设置的值,没有特殊设置过则返回0。如果为False,则会先尝试获取userData中的值,没有的话获取该类物品通用值。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 物品的最大耐久 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.GetItemMaxDurability(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 1, False)GetItemTags
服务端开发补充
读取物品资源中定义的标签列表。
客户端开发补充
读取物品资源中定义的标签列表。
服务端客户端
服务端接口
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取物品的tags列表,包含原版minecraft:tags中定义的tags,以及netease_tags中注册并挂载到物品上的自定义标签
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxValue,默认为不指定auxValue(0) |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(str) | 物品tags列表 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetItemTags("minecraft:apple")客户端接口
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取物品的tags列表,包含原版minecraft:tags中定义的tags,以及netease_tags中注册并挂载到物品上的自定义标签
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxValue,默认为不指定auxValue(0) |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(str) | 物品tags列表 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetItemTags("minecraft:apple")GetItemTexture
客户端开发补充
读取物品纹理定义中的贴图路径。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取item_texture.json中物品的贴图路径。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| identifier | str | 物品标识符,格式[namespace:name:auxvalue],auxvalue默认为0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 物品的贴图路径 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
print(comp.GetItemTexture("mytool:hatchet_1:0"))GetLoadItems
服务端开发补充
列出已加载的物品类型标识。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取已经加载的物品id
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| flag | bool | True获取所有物品,False仅获取注册到创造栏的物品,默认为True |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(str) | 物品id列表 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
itemName = comp.GetLoadItems(True)GetUserDataInEvent
服务端开发补充
在模组初始化时启用物品事件参数中的附加数据。
客户端开发补充
在模组初始化时启用物品事件参数中的附加数据。
服务端客户端
服务端接口
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
使物品相关服务端事件的物品信息字典参数带有userData。在mod初始化时调用即可
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| eventName | str | 引擎事件名 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
# 这样调用之后,PlayerEatFoodServerEvent事件的itemDict参数会带有userData字段
comp.GetUserDataInEvent("PlayerEatFoodServerEvent")客户端接口
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
使物品相关客户端事件的物品信息字典参数带有userData。在mod初始化时调用即可
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| eventName | str | 引擎事件名 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 这样调用之后,ActorAcquiredItemClientEvent事件的itemDict参数会带有userData字段
comp.GetUserDataInEvent("ActorAcquiredItemClientEvent")LookupItemByName
服务端开发补充
判断指定物品标识是否存在。
服务端
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
判定指定identifier的物品是否存在
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 物品的identifier。类似"minecraft:bed",支持自定义物品 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | True为对应的物品存在,False为对应物品不存在 |
- 示例
import mod.server.extraServerApi as serverApi
gameComp = serverApi.GetEngineCompFactory().CreateGame(levelId)
exist = gameComp.LookupItemByName("minecraft:bed")LookupItemsByItemTag
服务端开发补充
服务端按物品标签名列出该标签下全部物品名,自动展开#引用并合并多模组注册,原版标签也可查;反向查某物品有哪些标签用GetItemTags。
- 返回list(dict),每项为含itemName键的物品名。
- 物品标签与方块标签相互独立,identifier相同也不互通。
客户端开发补充
客户端按物品标签名列出该标签下全部物品名,自动展开#引用并合并多模组注册,原版标签也可查;反向查某物品有哪些标签用GetItemTags。
- 返回list(dict),每项为含itemName键的物品名。
- 物品标签与方块标签相互独立,identifier相同也不互通。
服务端客户端
服务端接口
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
根据netease_tags中注册的物品tag名,查找该tag下所有物品,支持#引用的标签自动展开;同一tag名被多个模组注册时自动合并去重;未注册的原版tag可直接查询
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemTag | str | 物品tag名,如 common:apple |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(dict) | 物品字典列表,dict包含itemName键 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
comp.LookupItemsByItemTag("common:apple")客户端接口
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
根据netease_tags中注册的物品tag名,查找该tag下所有物品,支持#引用的标签自动展开;同一tag名被多个模组注册时自动合并去重;未注册的原版tag可直接查询
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemTag | str | 物品tag名,如 common:apple |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(dict) | 物品字典列表,dict包含itemName键 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
comp.LookupItemsByItemTag("common:apple")RemoveItemLayer
服务端开发补充
移除物品叠加贴图。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
移除物品的叠加贴图。物品叠加贴图详见SetItemLayer
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| layer | int | 贴图的层级。可以为-2,-1,1,2,3。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
success = comp.RemoveItemLayer(itemDict, 1)
if success:
comp.SpawnItemToPlayerCarried(itemDict, playerId)SetAttackDamage
服务端开发补充
设置物品的攻击伤害值。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置物品的攻击伤害值
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| attackDamage | int | 攻击伤害值 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
success = comp.SetAttackDamage(itemDict, 5)
if success:
comp.SpawnItemToPlayerCarried(itemDict, playerId)SetBindBoneForBindItem
客户端开发补充
设置物品附着的绑定骨骼。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
改变实体上已绑定的物品附着物所绑定的骨骼,又或者移除该物品附着物。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要设置的实体的id。 |
| itemModelId | int | 需要设置的物品模型id。 |
| boneName | str | 需要挂接到的骨骼名称(不区分大小写)。如果传入空字符串,则移除该物品附着物。 |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 操作成功后返回True |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)
# 使这个苹果绑定到手部
comp.SetBindBoneForBindItem(player_id, itemModelId, "rightarm")
# 移除这个苹果
comp.SetBindBoneForBindItem(player_id, itemModelId, "")SetBindItemOffset
客户端开发补充
设置物品附着的位置偏移。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
设置实体上的物品附着物相对骨骼的位置偏移。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要设置的实体的id。 |
| itemModelId | int | 需要设置的物品模型id。 |
| offset | tuple(float,float,float) | 需要设置物品的位置偏移 |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True |
备注
1.物品的偏移方向是相对于骨骼的,因此对于不同的骨骼,其偏移方向可能不同。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)
# 使这个苹果往y方向偏移0.5个单位
comp.SetBindItemOffset(player_id, itemModelId, (0, 0.5, 0))SetBindItemRotation
客户端开发补充
设置物品附着的旋转角度。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
设置实体上的物品附着物相对骨骼的旋转角度。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要设置的实体的id。 |
| itemModelId | int | 需要设置的物品模型id。 |
| rotation | tuple(float,float,float) | 需要设置物品的三维旋转(单位为度,按照ZYX顺序旋转) |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)
# 使这个苹果绕y轴旋转90度
comp.SetBindItemRotation(player_id, itemModelId, (0, 90, 0))SetBindItemScale
客户端开发补充
设置物品附着的缩放比例。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
设置实体上的物品附着物的缩放比例。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 需要设置的实体的id。 |
| itemModelId | int | 需要设置的物品模型id。 |
| scale | float | 绑定物品的缩放比例。 |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
# 在玩家的头部绑定一个附魔的金苹果
# 物品信息字典主要需要以下4个字段
itemDict = {
"newItemName" : "minecraft:apple", # 物品的identifier
"newAuxValue" : 0, # 物品的auxvalue
"isEnchanted" : True, # 是否附魔
"userData":{} # 物品的userData,用于旗帜等物品
}
player_id = clientApi.GetLocalPlayerId()
itemModelId = comp.BindItemToMinecraftModel(player_id, itemDict, "head", False, (0,0,0), (0,0,0), 1.0)
print("Successfully bind item with id:", itemModelId)
# 使这个苹果变大1.5倍
comp.SetBindItemScale(player_id, itemModelId, 1.5)SetCompassEntity
客户端开发补充
设置指南针指向的实体。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
设置指南针朝向的实体
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 实体id |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(playerId)
comp.SetCompassEntity(entityId)SetCompassTarget
客户端开发补充
设置指南针指向的位置。
客户端
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
设置指南针的朝向位置
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| x | int | 方块x坐标 |
| y | int | 方块y坐标 |
| z | int | 方块z坐标 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(playerId)
comp.SetCompassTarget(x,y,z)SetCustomName
服务端开发补充
修改物品自定义名称,与铁砧重命名对应。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置物品的自定义名称,与使用铁砧重命名一致
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| name | str | 物品名称。支持unicode |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
comp.SetCustomName(itemDict, '史蒂夫')
comp.SpawnItemToPlayerCarried(itemDict, playerId)SetFishingLineColor
服务端开发补充
修改钓鱼线颜色,并同步到客户端。
关联接口:GetFishingLineColor (server) · GetFishingLineColor (server)
服务端
method in mod.server.component.fishingLineCompServer.FishingLineCompServer
- 描述
设置钓鱼线的颜色,设置后会自动同步到所有客户端。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 鱼竿物品的完整名称,如 "minecraft:fishing_rod" 或自定义鱼竿名称 |
| color | tuple(float,float,float) | 鱼线颜色rgb,取值[0, 1] |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFishingLine(playerId)
comp.SetFishingLineColor("mymod:custom_fishing_rod", (1.0, 0.0, 0.0))SetFishingLineMax
服务端开发补充
修改钓鱼线最大长度并同步到客户端;超过长度时会断线。
关联接口:GetFishingLineMax (server) · GetFishingLineMax (server)
服务端
method in mod.server.component.fishingLineCompServer.FishingLineCompServer
- 描述
设置钓鱼线的最大长度(超过此长度会断线),设置后会自动同步到所有客户端。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemName | str | 鱼竿物品的完整名称,如 "minecraft:fishing_rod" 或自定义鱼竿名称 |
| maxLength | float | 最大长度,单位为格,钓鱼竿默认值为32.0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFishingLine(playerId)
comp.SetFishingLineMax("mymod:custom_fishing_rod", 64.0)SetItemDefenceAngle
服务端开发补充
设置盾牌格挡的抵挡角度。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置盾牌物品的抵挡角度范围
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| posType | int | ItemPosType枚举 |
| slotPos | int | 槽位 |
| angleLeft | float | 左边的范围,不想设置左范围传None,取值范围是[-180,180] |
| angleRight | float | 右边的范围,不想设置右范围传None,取值范围是[-180,180],且angleLeft<angleRight |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
备注
当设置的物品不是盾牌物品时,返回False;原生盾牌会返回True但是仍然走原生的逻辑
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.SetItemDefenceAngle(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 0, -60, 70)SetItemDurability
服务端开发补充
设置物品耐久的目标值;增减耐久需先读取当前值,使用物品事件中的写入宜延后执行。
- 这是赋值而非自动扣减;数值会限制在零至最大耐久之间。
- 原文建议在使用物品事件中通过 AddTimer 延迟设置,否则可能失效。
关联接口:GetItemDurability (server) · AddTimer (server) · ItemPosType (common)
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置物品的耐久值
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| posType | int | ItemPosType枚举 |
| slotPos | int | 槽位,当posType为ItemPosType.INVENTORY或ItemPosType.ARMOR时才有意义 |
| durability | int | 耐久值 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
备注
在使用物品事件中调用这个接口时,建议使用AddTimer延迟一下,不然接口设置可能会失效
设置的耐久值超过物品的最大耐久值时,使用最大耐久值;最小耐久值为0。
posType设置成serverApi.GetMinecraftEnum().ItemPosType.INVENTORY时可以代替SetInvItemDurability;posType设置成serverApi.GetMinecraftEnum().ItemPosType.ARMOR时可以代替SetEquItemDurability;
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.SetItemDurability(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 0, 5)
#替代SetInvItemDurability的方法
comp.SetItemDurability(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 0, 5)
#替代SetEquItemDurability的方法
comp.SetItemDurability(serverApi.GetMinecraftEnum().ItemPosType.ARMOR, 0, 5)SetItemLayer
服务端开发补充
在物品贴图的上层或下层叠加自定义纹理。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置物品的叠加贴图,可以在物品的上层与下层叠加自定义贴图。具体使用可参考CustomItemsMod示例。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| layer | int | 贴图的层级。可以为-2,-1,1,2,3。负数层级显示在物品下方,正数的层级显示在物品上方。层级大的显示在层级小的上方。 |
| texture | str | 贴图的名字,对应item_texture.json中的key。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
备注
如果需要在自定义ui中显示叠加贴图,需要在您的物品渲染控件下添加top_layer_3,top_layer_2,top_layer_1,bottom_layer_1,bottom_layer_2共5个图片控件,即可使用SetUiItem显示叠加贴图。可参考CustomFurnaceMod示例
"customItemLayer@common.item_renderer_additional_layer": {
"bindings": [
{
"binding_name": "#visible",
"binding_condition": "always"
},
{
"binding_name": "#uv",
"binding_condition": "always_when_visible"
},
{
"binding_name": "#uv_size",
"binding_condition": "always_when_visible"
},
{
"binding_name": "#texture",
"binding_condition": "always_when_visible"
}
]
},
"itemImg" : {
"anchor_from" : "center",
"anchor_to" : "center",
"controls" : [
{
"top_layer_3@neteaseCommonUI.customItemLayer": {
"$item_renderer_additional_layer_layer": 3
}
},
{
"top_layer_2@neteaseCommonUI.customItemLayer": {
"$item_renderer_additional_layer_layer": 2
}
},
{
"top_layer_1@neteaseCommonUI.customItemLayer": {
"$item_renderer_additional_layer_layer": 1
}
},
{
"bottom_layer_1@neteaseCommonUI.customItemLayer": {
"$item_renderer_additional_layer_layer": -1
}
},
{
"bottom_layer_2@neteaseCommonUI.customItemLayer": {
"$item_renderer_additional_layer_layer": -2
}
},
{
"itemNum@neteaseCommonUI.itemNum" : {}
}
],
"layer" : 3,
"offset" : [ 0, 0 ],
"renderer" : "inventory_item_renderer",
"size" : [ 24, 24 ],
"type" : "custom",
"visible" : true
}需要为5层叠加贴图预留ui层级,让他可以显示在背包背景之上,物品数量之下。例如在CustomFurnaceMod示例中,itemBtn中的default/hover/pressed贴图的层级为2,物品渲染控件itemImg的层级为5,五个叠加贴图的层级分别为3/4/6/7/8,selectedImg的层级为9,itemNum的层级为10,durabilityBar的层级为11。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
success = comp.SetItemLayer(itemDict, 1, 'wooden_door')
if success:
comp.SpawnItemToPlayerCarried(itemDict, playerId)SetItemMaxDurability
服务端开发补充
修改物品最大耐久值。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置物品的最大耐久值
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| posType | int | ItemPosType枚举 |
| slotPos | int | 槽位,当posType为ItemPosType.INVENTORY或ItemPosType.ARMOR时才有意义 |
| maxDurability | int | 最大耐久值,可设为0~32767 |
| isUserData | bool | 如果为True,则该设置只对指定物品生效,如果为False,则对同一类所有物品生效 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
备注
若物品堆叠数量大于1时,耐久度的变更对整一叠的物品生效。并且耐久度为0后,每次消耗耐久度的行为会使数量减一
为物品设置的userData最大耐久度在计算时优先级最高,userData数据存盘。
在砂轮或背包合并时,若两个物品都有userData,只会保留其中一个。在铁砧中修复时,最大耐久取被修复物品的耐久。
当最大耐久值被更改时,当前耐久度也会按比例修复。
对同一类所有物品设置的最大耐久度不存盘,每次重启世界都会重新初始化,可以通过对应item json的
minecraft:max_damage组件设置初始化最大耐久度如果设置的是背包物品,当slot值为-1时,设置左手物品的最大耐久值
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
comp.SetItemMaxDurability(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 0, 5, False)SetItemTierLevel
服务端开发补充
能力:主手物品 · 挖掘等级
适用限定:挖掘等级
修改工具物品的挖掘等级。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置工具类物品的挖掘等级
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| level | int | 挖掘等级 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
备注
对于不总是可以破坏的方块(包括方块材质为Stone,Metal,TopSnow,Snow,Web),需要使用不同挖掘等级(level)的工具才能破坏并产生掉落物。
| level | 类型 |
|---|---|
| 0 | 木 |
| 1 | 石 |
| 2 | 铁 |
| 3 | 钻石 |
| 4 | 下界 |
剑和剪刀都可以对蜘蛛网进行破坏并产生掉落物; 铲可以对雪和顶层雪进行破坏并产生掉落物; 镐是否可以破坏判断: 1)对于黑曜石、下界类方块、远古残骸,需要Level大于等于3的镐才能破坏并产生掉落物; 2)对于钻石块、钻石矿石、绿宝石块、绿宝石矿石、金块、金矿石、红石矿石、发光的红石矿石,需要Level大于等于2的镐才能破坏并产生掉落物; 3)对于铁块、铁矿石、青金石块、青金石矿石,需要Level大于等于1的镐才能破坏并产生掉落物; 4)对于其他Stone和Metal材质的方块,需要Level大于等于0的镐才能破坏并产生掉落物。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
success = comp.SetItemTierLevel(itemDict, 5)
if success:
comp.SpawnItemToPlayerCarried(itemDict, playerId)SetItemTierSpeed
服务端开发补充
修改工具物品的挖掘速度。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置工具类物品的挖掘速度(可通过userData中的ModTierSpeed获取挖掘速度)
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| speed | float | 挖掘速度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
success = comp.SetItemTierSpeed(itemDict, 32)
if success:
comp.SpawnItemToPlayerCarried(itemDict, playerId)SetMaxStackSize
服务端开发补充
设置物品最大堆叠数量;设置会保存到存档。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置物品的最大堆叠数量(存档)
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| itemDict | dict | 物品信息字典 |
| maxStackSize | int | 最大堆叠数量,不能超过64,如果该值小于物品的堆叠数量,会返回失败 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(playerId)
itemDict = comp.GetPlayerItem(serverApi.GetMinecraftEnum().ItemPosType.CARRIED, 0, True)
success = comp.SetMaxStackSize(itemDict, 32)
if success:
comp.SpawnItemToPlayerCarried(itemDict, playerId)SetShearsDestroyBlockSpeed
服务端开发补充
设置剪刀对指定方块的破坏速度。
服务端
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置剪刀对某一方块的破坏速度
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| blockName | str | 方块名称,包含命名空间 |
| speed | float | 破坏速度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
备注
设置的速度最终会加上剪刀的附魔:效率计算
原版剪刀对蜘蛛网的破坏速度为15,羊毛的破坏速度为5,也可以用该接口重写对这两个方块的破坏速度
设置的速度必须大于1,否则该接口返回False
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(entityId)
comp.SetShearsDestroyBlockSpeed("minecraft:obsidian", 100)