渲染
AddPlayerAnimation
客户端开发补充
能力:动画 · 自定义姿势 · 玩家
向玩家渲染定义添加动画资源。
关联流程:玩家自定义动画接线
需要动画 JSON 和状态驱动;第一人称抬手与现有资源包、模型的组合必须按目标包体核验。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加玩家渲染动画
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| animationKey | str | 动画键 |
| animationName | str | 动画名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
该接口的animationName参数不能传入带有大写字母的字符串,否则动画将注册失败。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerAnimation("move.arms", "animation.player.move.arms_custom")AddPlayerAnimationController
客户端开发补充
能力:动画 · 自定义姿势 · 玩家
为玩家渲染添加动画控制器。
关联流程:玩家自定义动画接线
需要动画 JSON 和状态驱动;第一人称抬手与现有资源包、模型的组合必须按目标包体核验。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加玩家渲染动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| animationControllerKey | str | 动画控制器键 |
| animationControllerName | str | 动画控制器名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerAnimationController("root", "controller.animation.player.root_custom")AddPlayerAnimationIntoState
客户端开发补充
能力:动画 · 自定义姿势 · 玩家
向指定动画控制器状态中添加动画或控制器。
关联流程:玩家自定义动画接线
需要动画 JSON 和状态驱动;第一人称抬手与现有资源包、模型的组合必须按目标包体核验。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
在玩家的动画控制器中的状态添加动画或者动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| animationControllerName | str | 动画控制器名称,如root(controller.animation.player.root) |
| stateName | str | 动画状态名称,如first_person |
| animationName | str | 添加的动画名称或动画控制器名称,如first_person_attack_controller_new |
| condition | str | 动画控制表达式,默认为空,如query.mod.index > 0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerAnimationIntoState("root", "first_person", "first_person_attack_controller_new", "query.mod.index > 0")AddPlayerGeometry
客户端开发补充
添加玩家渲染使用的几何体。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加玩家渲染几何体
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| geometryKey | str | 渲染几何体键,如玩家默认几何体default |
| geometryName | str | 渲染几何体名称,如玩家默认几何体geometry.humanoid.custom |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
动画和贴图都是与几何体密切相关的,改变几何体也需要改变动画与贴图
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerGeometry("default", "geometry.player.custom")AddPlayerParticleEffect
客户端开发补充
添加玩家粒子特效资源定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加玩家特效资源
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| effectKey | str | 特效资源Key,如bee.entity.json中的nectar_dripping |
| effectName | str | 特效资源名称,如minecraft:nectar_drip_particle |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
调用该接口后需要调用RebuildPlayerRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerParticleEffect("nectar_dripping", "minecraft:nectar_drip_particle")AddPlayerRenderController
客户端开发补充
添加玩家渲染控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加玩家渲染控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| renderControllerName | str | 渲染控制器名称 |
| condition | str | 渲染控制器条件 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerRenderController('custom_render_controller_name', 'query.mod.condition')AddPlayerRenderMaterial
客户端开发补充
添加玩家渲染使用的材质。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加玩家渲染需要的材质
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| materialKey | str | 材质key |
| materialName | str | 材质名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerRenderMaterial('custom_material_key', 'custom_material_name')AddPlayerScriptAnimate
客户端开发补充
向玩家客户端定义的动画脚本节点添加动画或控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
在玩家的客户端实体定义(minecraft:client_entity)json中的scripts/animate节点添加动画/动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| animateName | str | 动画/动画控制器名称,如look_at_target |
| condition | str | 动画/动画控制器控制表达式,默认为空,如query.mod.index > 0 |
| autoReplace | bool | 是否覆盖已存在的动画/动画控制器,默认值为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
该接口只对CreateActorRender时传入的playerId起效果
调用该接口后需要调用RebuildPlayerRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerAnimationController("animation_controller_short_name", "controller.animation.player.root_custom")
comp.AddPlayerScriptAnimate("animation_controller_short_name", "query.mod.index > 0")AddPlayerSoundEffect
客户端开发补充
添加玩家音效资源定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加玩家音效资源
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| soundKey | str | 音效资源Key |
| soundName | str | 音效资源名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
调用该接口后需要调用RebuildPlayerRender才会生效
音效在RP/entities/player.entity.json # minecraft:client_entity / description中的定义如下: "sound_effects": { "sound_thunder": "ambient.weather.thunder" # ambient.weather.thunder是sound_definitions中定义 } 如果在动作中同步播放音频,可以在RP/animations/player.animation_controllers.json # animation_controllers / controller.animation.player.root中定义如下: "dripping": { "sound_effects": [ { "effect": "sound_thunder" } ], "transitions": [ { "third_person": "!query.mod.is_powered" } ] },
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerSoundEffect("sound_thunder", "ambient.weather.thunder")AddPlayerTexture
客户端开发补充
添加玩家渲染使用的贴图。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加玩家渲染贴图
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| textureKey | str | 贴图键 |
| textureName | str | 贴图路径 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.AddPlayerTexture("default", "textures/misc/missing_texture")RebuildPlayerRender
客户端开发补充
重建玩家渲染数据,使相关渲染定义重新生效。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
重建玩家的数据渲染器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| clearBindParticle | bool | 是否清除粒子,默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 重建是否成功 |
备注
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.RebuildPlayerRender()RemovePlayerAnimationController
客户端开发补充
移除玩家动画控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
移除玩家渲染动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| animationControllKey | str | 动画控制器键 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.RemovePlayerAnimationController("root")RemovePlayerAnimationFromState
客户端开发补充
从控制器状态中移除动画或动画控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
在玩家的动画控制器中的状态移除动画或者动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| animationControllerName | str | 动画控制器名称,如root(controller.animation.player.root) |
| stateName | str | 动画状态名称,如first_person |
| animationName | str | 要移除的动画名称或动画控制器名称,如first_person_attack_controller_new |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功。controller/state 不存在或参数错误返False;动画不在该state中视为幂等成功,返True。 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.RemovePlayerAnimationFromState("root", "first_person", "first_person_attack_controller_new")RemovePlayerGeometry
客户端开发补充
删除玩家渲染使用的几何体。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除玩家渲染几何体
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| geometryKey | str | 渲染几何体名称键,如玩家默认几何体default |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
动画和贴图都是与几何体密切相关的,改变几何体也需要改变动画与贴图
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
# geometry definition in player.entity.json
"geometry": {
"default": "geometry.humanoid.custom",
"cape": "geometry.cape"
}
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.RemovePlayerGeometry("default")RemovePlayerRenderController
客户端开发补充
删除玩家渲染控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除玩家渲染控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| renderControllerName | str | 渲染控制器名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 删除是否成功 |
备注
调用该接口后需要调用RebuildPlayerRender才会生效
该玩家重新进入视野时仍会生效,引擎会自动重新调用一遍
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
comp.RemovePlayerRenderController('custom_render_controller_name')ResetSkin
客户端开发补充
恢复玩家默认皮肤。
客户端
method in mod.client.component.modelCompClient.ModelComponentClient
- 描述
还原默认皮肤
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| isSteve | bool | 是否还原成Steve默认皮肤, 默认为True。当isSteve为False时,则还原成资源中心中购买并穿戴的皮肤 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
备注
还原后,对玩家使用过的actorRender组件接口(如AddPlayerRenderController依然生效)
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateModel(playerId)
comp.ResetSkin()SetPlayerItemInHandVisible
客户端开发补充
控制玩家手持物品模型是否显示。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
设置是否隐藏玩家的手持物品模型显示
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| visible | bool | 设置是否显示或隐藏,True表示显示,False表示隐藏 |
| mode | int | 设置隐藏手持物品在哪一个视角模式生效。mode=0时,表示第一人称和第三人称下均隐藏手持物品;mode=1时表示仅隐藏第三人称下的手持物品;mode=2时表示仅隐藏第一人称下的手持物品。默认值为0。填入0,1,2以外的数值会被强制设置为0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True,失败返回False。 |
- 示例
import mod.client.extraClientApi as clientApi
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
# 隐藏指定玩家的手持物品模型显示
print actorRenderComp.SetPlayerItemInHandVisible(False, 0)SetSkin
客户端开发补充
更换原版自定义皮肤。
客户端
method in mod.client.component.modelCompClient.ModelComponentClient
- 描述
更换原版自定义皮肤
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| skin | str | 贴图路径,以textures/models为当前路径的相对路径 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
备注
会覆盖原有皮肤(包括4d皮肤)。但会被骨骼模型覆盖
只能修改Steve模型的皮肤,不能修改Alex模型的皮肤
如需修改细手臂模型皮肤,请使用AddPlayerTexture修改default键对应的贴图
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateModel(playerId)
comp.SetSkin("kagura")