更新3.3

This commit is contained in:
boybook
2025-03-18 14:46:12 +08:00
parent e0e8ad3192
commit 481c844a80
11938 changed files with 149901 additions and 23781 deletions

View File

@@ -15,6 +15,8 @@ sidebarDepth: 1
| [CancelShearsDestoryBlockSpeedAll](物品.md#cancelshearsdestoryblockspeedall) | <span style="display:inline;color:#ff5555">服务端</span> | 取消剪刀对全部方块的破坏速度设置 |
| [ChangeArmorTextures](物品.md#changearmortextures) | <span style="display:inline;color:#7575f9">客户端</span> | 修改盔甲在场景中显示和在UI中显示的贴图 |
| [ChangeItemTexture](物品.md#changeitemtexture) | <span style="display:inline;color:#7575f9">客户端</span> | 替换物品的贴图修改后所有用到该贴图的物品都会被改变后续创建的此类物品也会被改变。会同时修改物品在UI界面上的显示手持时候的显示与场景掉落的显示。 |
| [GetAllEnchantsInfo](物品.md#getallenchantsinfo) | <span style="display:inline;color:#ff5555">服务端</span> | 获取目前已注册的所有附魔信息 |
| [GetAllEnchantsInfo](物品.md#getallenchantsinfo) | <span style="display:inline;color:#7575f9">客户端</span> | 获取目前已注册的所有附魔信息 |
| [GetCustomName](物品.md#getcustomname) | <span style="display:inline;color:#ff5555">服务端</span> | 获取物品的自定义名称,与铁砧修改的名称一致 |
| [GetItemBasicInfo](物品.md#getitembasicinfo) | <span style="display:inline;color:#ff5555">服务端</span> | 获取物品的基础信息 |
| [GetItemBasicInfo](物品.md#getitembasicinfo) | <span style="display:inline;color:#7575f9">客户端</span> | 获取物品的基础信息 |
@@ -23,17 +25,27 @@ sidebarDepth: 1
| [GetItemEffectName](物品.md#getitemeffectname) | <span style="display:inline;color:#7575f9">客户端</span> | 获取物品的状态描述§7保护 0§r |
| [GetItemFormattedHoverText](物品.md#getitemformattedhovertext) | <span style="display:inline;color:#7575f9">客户端</span> | 获取物品的格式化hover文本§f灾厄旗帜§r |
| [GetItemHoverName](物品.md#getitemhovername) | <span style="display:inline;color:#7575f9">客户端</span> | 获取物品的hover名称灾厄旗帜§r |
| [GetItemInfoByBlockName](物品.md#getiteminfobyblockname) | <span style="display:inline;color:#ff5555">服务端</span> | 通过方块名称及aux值获取物品信息 |
| [GetItemLayer](物品.md#getitemlayer) | <span style="display:inline;color:#ff5555">服务端</span> | 获取物品的叠加贴图。物品叠加贴图详见SetItemLayer |
| [GetItemMaxDurability](物品.md#getitemmaxdurability) | <span style="display:inline;color:#ff5555">服务端</span> | 获取指定槽位的物品耐最大耐久 |
| [GetItemTags](物品.md#getitemtags) | <span style="display:inline;color:#ff5555">服务端</span> | 获取物品在minecraft:tags中定义的tags列表 |
| [GetItemTags](物品.md#getitemtags) | <span style="display:inline;color:#7575f9">客户端</span> | 获取物品在minecraft:tags中定义的tags列表 |
| [GetItemTexture](物品.md#getitemtexture) | <span style="display:inline;color:#7575f9">客户端</span> | 获取item_texture.json中物品的贴图路径。 |
| [GetLoadItems](物品.md#getloaditems) | <span style="display:inline;color:#ff5555">服务端</span> | 获取已经加载的物品id |
| [GetUserDataInEvent](物品.md#getuserdatainevent) | <span style="display:inline;color:#ff5555">服务端</span> | 使物品相关服务端事件的<a href="../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a>参数带有userData。在mod初始化时调用即可 |
| [GetUserDataInEvent](物品.md#getuserdatainevent) | <span style="display:inline;color:#7575f9">客户端</span> | 使物品相关客户端事件的<a href="../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a>参数带有userData。在mod初始化时调用即可 |
| [LookupItemByName](物品.md#lookupitembyname) | <span style="display:inline;color:#ff5555">服务端</span> | 判定指定identifier的物品是否存在 |
| [RemoveItemLayer](物品.md#removeitemlayer) | <span style="display:inline;color:#ff5555">服务端</span> | 移除物品的叠加贴图。物品叠加贴图详见SetItemLayer |
| [SetAttackDamage](物品.md#setattackdamage) | <span style="display:inline;color:#ff5555">服务端</span> | 设置物品的攻击伤害值 |
| [SetCompassEntity](物品.md#setcompassentity) | <span style="display:inline;color:#7575f9">客户端</span> | 设置指南针朝向的实体 |
| [SetCompassTarget](物品.md#setcompasstarget) | <span style="display:inline;color:#7575f9">客户端</span> | 设置指南针的朝向位置 |
| [SetCustomName](物品.md#setcustomname) | <span style="display:inline;color:#ff5555">服务端</span> | 设置物品的自定义名称,与使用铁砧重命名一致 |
| [SetItemDefenceAngle](物品.md#setitemdefenceangle) | <span style="display:inline;color:#ff5555">服务端</span> | 设置盾牌物品的抵挡角度范围 |
| [SetItemDurability](物品.md#setitemdurability) | <span style="display:inline;color:#ff5555">服务端</span> | 设置物品的耐久值 |
| [SetItemLayer](物品.md#setitemlayer) | <span style="display:inline;color:#ff5555">服务端</span> | 设置物品的叠加贴图可以在物品的上层与下层叠加自定义贴图。具体使用可参考CustomItemsMod示例。 |
| [SetItemMaxDurability](物品.md#setitemmaxdurability) | <span style="display:inline;color:#ff5555">服务端</span> | 设置物品的最大耐久值 |
| [SetItemTierLevel](物品.md#setitemtierlevel) | <span style="display:inline;color:#ff5555">服务端</span> | 设置工具类物品的挖掘等级 |
| [SetItemTierSpeed](物品.md#setitemtierspeed) | <span style="display:inline;color:#ff5555">服务端</span> | 设置工具类物品的挖掘速度 |
| [SetItemTierSpeed](物品.md#setitemtierspeed) | <span style="display:inline;color:#ff5555">服务端</span> | 设置工具类物品的挖掘速度(可通过userData中的ModTierSpeed获取挖掘速度) |
| [SetMaxStackSize](物品.md#setmaxstacksize) | <span style="display:inline;color:#ff5555">服务端</span> | 设置物品的最大堆叠数量(存档) |
| [SetShearsDestoryBlockSpeed](物品.md#setshearsdestoryblockspeed) | <span style="display:inline;color:#ff5555">服务端</span> | 设置剪刀对某一方块的破坏速度 |
@@ -166,7 +178,7 @@ method in mod.client.component.itemCompClient.ItemCompClient
| bool | 是否修改成功(因为采用延迟加载,此处返回成功不代表贴图路径正确,路径错误会导致渲染时贴图丢失显示异常) |
- 备注
- 因为会同时修改用到此贴图的所有物品,所以使用的时候尽量谨慎,不建议改原版的物品,建议只用于修改用到自定义新贴图的物品。
- 因为会同时修改用到此贴图的所有物品,所以使用的时候尽量谨慎,不建议改原版的物品,建议只用于修改用到自定义新贴图的物品。
- 序列帧贴图物品暂不支持动态修改贴图
- 部分物品有特殊逻辑无法修改:箱子,旗帜,生物头颅,盾牌,三叉戟,鱼杆
@@ -180,6 +192,76 @@ print(comp.ChangeItemTexture("mytool:hatchet_1:0", "textures/items/hatchet_1"))
## GetAllEnchantsInfo
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
### 服务端接口
<span id="s0"></span>
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取目前已注册的所有附魔信息
- 参数
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(dict) | 附魔信息字典<a href="../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#附魔信息字典#附魔信息字典">附魔信息字典</a> |
- 备注
- 1.目前能获取原生及自定义附魔信息
2.由于原生附魔的消耗存在不相同的计算规则目前不提供原生附魔的costs信息
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetAllEnchantsInfo()
```
### 客户端接口
<span id="c0"></span>
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取目前已注册的所有附魔信息
- 参数
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(dict) | 附魔信息字典<a href="../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#附魔信息字典#附魔信息字典">附魔信息字典</a> |
- 备注
- 1.目前能获取原生及自定义附魔信息
2.由于原生附魔的消耗存在不相同的计算规则目前不提供原生附魔的costs信息
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetAllEnchantsInfo()
```
## GetCustomName
<span style="display:inline;color:#ff5555">服务端</span>
@@ -232,7 +314,7 @@ method in mod.server.component.itemCompServer.ItemCompServer
| :--- | :--- | :--- |
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxvalue默认为0 |
| isEnchanted | bool | 是否附魔默认为False。用于返回的id_Aux |
| isEnchanted | bool | 是否附魔默认为False。用于返回的id_aux |
- 返回值
@@ -247,18 +329,23 @@ method in mod.server.component.itemCompServer.ItemCompServer
| itemName | str | 本地化的物品名字 |
| maxStackSize |int| 物品最大堆叠数目 |
| maxDurability |int| 物品最大耐久值 |
| id_Aux |int| 主要用于客户端的ui绑定详见客户端接口 |
| id_aux |int| 主要用于客户端的ui绑定详见客户端接口 |
| tierDict |dict| 自定义方块定义的挖掘相关的属性 netease:tier,没有设置时返回None |
| itemCategory |str| 创造栏分类 |
| itemType |str| 物品类型 |
| customItemType |str| 自定义物品类型 |
| customTips |str| 自定义物品/方块tips |
| itemTierLevel |int| 工具等级 |
| fuelDuration |float| 燃料时长 |
| foodNutrition |int| 食物营养值 |
| foodSaturation |float| 食物饱食度 |
| weaponDamage |int| 武器攻击力 |
| armorDefense |int| 防具防御力 |
| armorSlot |int| 防具槽位 |
| armorToughness |int| 防具韧性 |
| armorKnockbackResistance |float| 防具击退抗性 |
- 部分原版物品较为特殊,获取不到个别字段的返回值
方块类燃料获取不到燃料时长,弓、驽、三叉戟获取不到武器攻击力蛋糕获取不到营养值和饱食度马铠获取不到防具防御力上述物品获取对应字段返回值为0
方块类燃料获取不到燃料时长,弓、获取不到武器攻击力蛋糕获取不到营养值和饱食度马铠获取不到防具防御力上述物品获取对应字段返回值为0
- 创造栏分类说明
| 创造栏分类 | 意义 |
| --------- | -----|
@@ -282,6 +369,15 @@ method in mod.server.component.itemCompServer.ItemCompServer
| shovel | 锹 |
| pickaxe | 镐 |
| dye | 骨粉 |
| food | 食物 |
| block | 方块 |
| armor | 盔甲 |
| custom_ranged_weapon | 自定义远程武器 |
| compass | 指南针 |
| trident | 三叉戟 |
| potion | 药水 |
| crossbow | 弩 |
- 自定义物品类型物品类型值为行为包里minecraft:item内description的custom_item_type字段值
- 工具等级代表不同的材质,没有工具等级时为值-1工具等级与材质对应关系如下
| 工具等级 | 材质 |
| ------- | ---- |
@@ -289,6 +385,7 @@ method in mod.server.component.itemCompServer.ItemCompServer
| 1 | 石制工具 |
| 2 | 铁制工具 |
| 3 | 钻石工具 |
| 4 | 合金工具 |
- 示例
@@ -315,7 +412,7 @@ method in mod.client.component.itemCompClient.ItemCompClient
| :--- | :--- | :--- |
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxvalue默认为0 |
| isEnchanted | bool | 是否附魔默认为False。用于返回的id_Aux |
| isEnchanted | bool | 是否附魔默认为False。用于返回的id_aux |
- 返回值
@@ -330,19 +427,24 @@ method in mod.client.component.itemCompClient.ItemCompClient
| itemName | str | 本地化的物品名字 |
| maxStackSize |int| 物品最大堆叠数目 |
| maxDurability |int| 物品最大耐久值 |
| id_Aux |int| 用于给UI的inventory_item_renderer类型控件绑定#item_id_aux字段,详见备注 |
| id_aux |int| 用于给UI的inventory_item_renderer类型控件绑定#item_id_aux字段,详见备注 |
| tierDict |dict| 自定义方块定义的挖掘相关的属性 netease:tier,没有设置时返回None |
| itemCategory |str| 创造栏分类 |
| itemType |str| 物品类型 |
| customItemType |str| 自定义物品类型 |
| customTips |str| 自定义物品/方块tips |
| itemTierLevel |int| 工具等级 |
| fuelDuration |float| 燃料时长 |
| foodNutrition |int| 食物营养值 |
| foodSaturation |float| 食物饱食度 |
| weaponDamage |int| 武器攻击力 |
| armorDefense |int| 防具防御力 |
| armorSlot |int| 防具槽位 |
| armorToughness |int| 防具韧性 |
| armorKnockbackResistance |float| 防具击退抗性 |
- 部分原版物品较为特殊,获取不到个别字段的返回值
方块类燃料获取不到燃料时长,弓、驽、三叉戟获取不到武器攻击力蛋糕获取不到营养值和饱食度马铠获取不到防具防御力上述物品获取对应字段返回值为0
- id_Aux字段的示例
方块类燃料获取不到燃料时长,弓、获取不到武器攻击力蛋糕获取不到营养值和饱食度马铠获取不到防具防御力上述物品获取对应字段返回值为0
- id_aux字段的示例
在ui中添加一个inventory_item_renderer控件以及#item_id_aux的绑定
```json
"my_item_renderer": {
@@ -389,6 +491,15 @@ method in mod.client.component.itemCompClient.ItemCompClient
| shovel | 锹 |
| pickaxe | 镐 |
| dye | 骨粉 |
| food | 食物 |
| block | 方块 |
| armor | 盔甲 |
| custom_ranged_weapon | 自定义远程武器 |
| compass | 指南针 |
| trident | 三叉戟 |
| potion | 药水 |
| crossbow | 弩 |
- 自定义物品类型物品类型值为行为包里minecraft::item内的custom_item_type字段值
- 工具等级代表不同的材质,没有工具等级时为值-1工具等级与材质对应关系如下
| 工具等级 | 材质 |
| ------- | ---- |
@@ -396,6 +507,7 @@ method in mod.client.component.itemCompClient.ItemCompClient
| 1 | 石制工具 |
| 2 | 铁制工具 |
| 3 | 钻石工具 |
| 4 | 合金工具 |
- 示例
@@ -591,6 +703,74 @@ comp.GetItemHoverName("minecraft:banner", 15, {'Type': 1})
## GetItemInfoByBlockName
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
通过方块名称及aux值获取物品信息
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| blockName | str | 方块identifier |
| auxValue | int | aux值 |
| isLegacy | bool | 方块是否为原生方块默认为True即使用旧版aux对应的state |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| dict | <a href="../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a> |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
blockDict = comp.GetItemInfoByBlockName("minecraft:stone")
```
## GetItemLayer
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取物品的叠加贴图。物品叠加贴图详见SetItemLayer
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| itemDict | dict | <a href="../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a> |
| layer | int | 贴图的层级。可以为-2-1123。 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| str | 贴图的名字不存在返回None |
- 示例
```python
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
<span style="display:inline;color:#ff5555">服务端</span>
@@ -625,6 +805,138 @@ comp.GetItemMaxDurability(serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 1,
## GetItemTags
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
### 服务端接口
<span id="s0"></span>
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取物品在minecraft:tags中定义的tags列表
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxValue默认为不指定auxValue0 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(str) | 物品tags列表 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetItemTags("minecraft:apple")
```
### 客户端接口
<span id="c0"></span>
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取物品在minecraft:tags中定义的tags列表
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| itemName | str | item的identifier |
| auxValue | int | 物品的附加值auxValue默认为不指定auxValue0 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(str) | 物品tags列表 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
comp.GetItemTags("minecraft:apple")
```
## GetItemTexture
<span style="display:inline;color:#7575f9">客户端</span>
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
获取item_texture.json中物品的贴图路径。
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| identifier | str | 物品标识符,格式[namespace:name:auxvalue]auxvalue默认为0 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| str | 物品的贴图路径 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(levelId)
print(comp.GetItemTexture("mytool:hatchet_1:0"))
```
## GetLoadItems
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
获取已经加载的物品id
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| flag | bool | True获取所有物品False仅获取注册到创造栏的物品默认为True |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| list(str) | 物品id列表 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateItem(levelId)
itemName = comp.GetLoadItems(True)
```
## GetUserDataInEvent
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
@@ -713,7 +1025,7 @@ method in mod.server.component.gameCompServer.GameComponentServer
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | exist True为对应的物品存在False为对应物品不存在 |
| bool | True为对应的物品存在False为对应物品不存在 |
- 示例
@@ -725,6 +1037,42 @@ exist = gameComp.LookupItemByName("minecraft:bed")
## RemoveItemLayer
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
移除物品的叠加贴图。物品叠加贴图详见SetItemLayer
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| itemDict | dict | <a href="../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a> |
| layer | int | 贴图的层级。可以为-2-1123。 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否成功 |
- 示例
```python
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
<span style="display:inline;color:#ff5555">服务端</span>
@@ -761,6 +1109,72 @@ if success:
## SetCompassEntity
<span style="display:inline;color:#7575f9">客户端</span>
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
设置指南针朝向的实体
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| entityId | str | 实体id |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(playerId)
comp.SetCompassEntity(entityId)
```
## SetCompassTarget
<span style="display:inline;color:#7575f9">客户端</span>
method in mod.client.component.itemCompClient.ItemCompClient
- 描述
设置指南针的朝向位置
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| x | int | 方块x坐标 |
| y | int | 方块y坐标 |
| z | int | 方块z坐标 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateItem(playerId)
comp.SetCompassTarget(x,y,z)
```
## SetCustomName
<span style="display:inline;color:#ff5555">服务端</span>
@@ -859,6 +1273,7 @@ method in mod.server.component.itemCompServer.ItemCompServer
| bool | 设置结果 |
- 备注
- 在使用物品事件中调用这个接口时建议使用AddTimer延迟一下不然接口设置可能会失效
- 设置的耐久值超过物品的最大耐久值时使用最大耐久值最小耐久值为0。
- posType设置成serverApi.GetMinecraftEnum().ItemPosType.INVENTORY时可以代替SetInvItemDurabilityposType设置成serverApi.GetMinecraftEnum().ItemPosType.ARMOR时可以代替SetEquItemDurability
@@ -877,6 +1292,109 @@ comp.SetItemDurability(serverApi.GetMinecraftEnum().ItemPosType.ARMOR, 0, 5)
## SetItemLayer
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置物品的叠加贴图可以在物品的上层与下层叠加自定义贴图。具体使用可参考CustomItemsMod示例。
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| itemDict | dict | <a href="../../../mcguide/20-玩法开发/10-基本概念/1-我的世界基础概念.html#物品信息字典#物品信息字典">物品信息字典</a> |
| layer | int | 贴图的层级。可以为-2-1123。负数层级显示在物品下方正数的层级显示在物品上方。层级大的显示在层级小的上方。 |
| texture | str | 贴图的名字对应item_texture.json中的key。 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 备注
- 如果需要在自定义ui中显示叠加贴图需要在您的物品渲染控件下添加top_layer_3top_layer_2top_layer_1bottom_layer_1bottom_layer_2共5个图片控件即可使用SetUiItem显示叠加贴图。可参考CustomFurnaceMod示例
```json
"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/8selectedImg的层级为9itemNum的层级为10durabilityBar的层级为11。
- 示例
```python
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
<span style="display:inline;color:#ff5555">服务端</span>
@@ -981,7 +1499,7 @@ method in mod.server.component.itemCompServer.ItemCompServer
- 描述
设置工具类物品的挖掘速度
设置工具类物品的挖掘速度(可通过userData中的ModTierSpeed获取挖掘速度)
- 参数