渲染
AddActorAnimation
客户端开发补充
向生物渲染定义添加动画。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物渲染动画
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 实体identifier |
| animationKey | str | 动画键 |
| animationName | str | 动画名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
某些动画资源可能用到了molang表达式,在添加动画时请务必确保这些molang表达式也存在。
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddActorAnimation("minecraft:pig", "custom_move", "animation.pig.custom_move")AddActorAnimationController
客户端开发补充
向生物渲染定义添加动画控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物渲染动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物的identifier |
| animationControllerKey | str | 动画控制器键 |
| animationControllerName | str | 动画控制器名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.AddActorAnimationController("minecraft:skeleton", "controller__use_item_progress", "controller.animation.humanoid.use_item_progress")AddActorBlockGeometry
客户端开发补充
能力:附加绑定 · 实体 · 方块几何体
作用对象:方块几何体
为实体添加方块组合生成的几何体模型。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
为实体添加方块几何体模型。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| geometryName | str | 几何体模型的名称,用于标识每个几何体模型,相当于是该模型的id |
| offset | tuple(float,float,float) | 方块几何体模型相对实体的位置偏移值,可选参数,默认为(0, 0, 0)。 |
| rotation | tuple(float,float,float) | 方块几何体模型相对实体的旋转角度,可选参数,默认为(0, 0, 0),分别表示绕x,y,z轴的旋转角度,旋转顺序按z,x,y顺序旋转。 |
| rotateFirst | bool | 控制先旋转后偏移,还是先偏移后旋转。默认是False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功,成功返回True,失败返回False。如果实体已经拥有了相同名称的模型,则也会返回True |
备注
请在确保世界已经初始化完成后(例如,监听UiInitFinished事件)再调用该接口,否则过早调用会导致接口执行失败。
示例
import mod.client.extraClientApi as clientApi
blockGeometryComp = clientApi.GetEngineCompFactory().CreateBlockGeometry(levelId)
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender("-4294967295")
# 合并方块并转换为名叫"my_block_geometry"的方块几何体模型
geometryName = blockGeometryComp.CombineBlockFromPosListToGeometry([(200,64,200),(201,65,202)],"my_block_geometry")
# 添加到实体id为-4294967295的实体中
print actorRenderComp.AddActorBlockGeometry(geometryName)AddActorGeometry
客户端开发补充
向生物渲染定义添加几何体。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物渲染几何体
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物实体identifier |
| geometryKey | str | 渲染几何体的键,如default |
| geometryName | str | 渲染几何体名称,如熊猫几何体geometry.panda |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效 动画和贴图都是与几何体密切相关的,改变几何体也需要改变动画与贴图。建议先修改生物的动画以及动画控制器后再修改生物的几何。
某些生物受初始动画影响,几何体会有初始偏移,会导致修改几何体后表现异常。若修改后的几何体没有当前动画需要的骨骼时,会触发报错。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddActorGeometry("minecraft:sheep", "default", "geometry.panda")AddActorParticleEffect
客户端开发补充
向生物渲染定义添加粒子资源。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物特效资源
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 实体identifier |
| effectKey | str | 特效资源Key,如bee.entity.json中的nectar_dripping |
| effectName | str | 特效资源名称,如minecraft:nectar_drip_particle |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddActorParticleEffect("minecraft:villager", "nectar_dripping", "minecraft:nectar_drip_particle")AddActorRenderController
客户端开发补充
向生物渲染定义添加渲染控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物渲染控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物identifier |
| renderControllerName | str | 渲染控制器名称 |
| condition | str | 渲染控制器条件,当该条件成立时,renderControllerName指向的渲染控制器才会生效 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddActorRenderController('minecraft:villager', 'custom_render_controller_name', 'query.mod.condition')AddActorRenderControllerArray
客户端开发补充
向生物渲染控制器的数组定义添加元素。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物渲染控制器列表中字典arrays元素
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 实体identifier |
| renderControllerName | str | 实体生物渲染控制器名称 |
| arrayType | int | 渲染控制器arrays类型(渲染控制器arrays类型枚举) |
| arrayName | str | 数组名称 |
| expression | str | 待添加元素表达式 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
该接口增加render_controller->arrays—>materials/textures/geometries->array.***中的元素
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.AddActorRenderControllerArray("minecraft:pig", "controller.render.pig", clientApi.GetMinecraftEnum().RenderControllerArrayType.Texture, "Array.skins", "Texture.test")AddActorRenderMaterial
客户端开发补充
向生物渲染定义添加材质。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物渲染需要的材质
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物的identifier |
| materialKey | str | 材质的键 |
| materialName | str | 材质名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddActorRenderMaterial('minecraft:villager', 'custom_material_key', 'custom_material_name')AddActorScriptAnimate
客户端开发补充
向生物渲染定义添加动画脚本。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
在生物的客户端实体定义(minecraft:client_entity)json中的scripts/animate节点添加动画/动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 实体identifier |
| animateName | str | 动画/动画控制器名称,如look_at_target |
| condition | str | 动画/动画控制器控制表达式,默认为空,如query.mod.index > 0 |
| autoReplace | bool | 是否覆盖已存在的动画/动画控制器,默认值为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
对于已经存在的生物,在调用CreateActorRender时需要传生物Id才能马上生效,对于不存在的生物,直接传levelId即可。
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.AddActorAnimationController("minecraft:pig", "animation_controller_short_name", "controller.animation.pig.custom_animation_controller")
comp.AddActorScriptAnimate("minecraft:pig", "animation_controller_short_name", "query.mod.index > 0")AddActorSoundEffect
客户端开发补充
向生物渲染定义添加音效资源。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物音效资源
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 实体identifier |
| soundKey | str | 音效资源Key |
| soundName | str | 音效资源名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
目前只支持在动作(animation)中播放音效,不支持在动作控制器(animation controller)中播放音效。
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddActorSoundEffect("minecraft:villager", "sound_thunder", "ambient.weather.thunder")AddActorTexture
客户端开发补充
向生物渲染定义添加贴图。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物渲染贴图
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物实体identifier |
| textureKey | str | 贴图键 |
| texturePath | str | 贴图路径 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddActorTexture("minecraft:sheep", "default", "textures/entity/panda/panda")AddAnimationControllerToOneActor
客户端开发补充
向单个生物渲染定义添加动画控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加单个生物渲染动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物的entityId |
| animationControllerKey | str | 动画控制器键 |
| animationControllerName | str | 动画控制器名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.AddAnimationControllerToOneActor(entityId, "controller__use_item_progress", "controller.animation.humanoid.use_item_progress")AddAnimationToOneActor
客户端开发补充
向单个生物渲染定义添加动画。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加单个生物渲染动画
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 实体entityId |
| animationKey | str | 动画键 |
| animationName | str | 动画名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
某些动画资源可能用到了molang表达式,在添加动画时请务必确保这些molang表达式也存在。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddAnimationToOneActor(entityId, "custom_move", "animation.armor_stand.default_pose")AddGeometryToOneActor
客户端开发补充
向单个生物渲染定义添加几何体。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加单个生物渲染几何体
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物实体entityId |
| geometryKey | str | 渲染几何体的键,如default |
| geometryName | str | 渲染几何体名称,如熊猫几何体geometry.panda |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效 动画和贴图都是与几何体密切相关的,改变几何体也需要改变动画与贴图。建议先修改生物的动画以及动画控制器后再修改生物的几何。
某些生物受初始动画影响,几何体会有初始偏移,会导致修改几何体后表现异常。若修改后的几何体没有当前动画需要的骨骼时,会触发报错。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddGeometryToOneActor(entityId, "default", "geometry.panda")AddParticleEffectToOneActor
客户端开发补充
向单个生物渲染定义添加粒子资源。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加生物特效资源
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 实体entityId |
| effectKey | str | 特效资源Key,如bee.entity.json中的nectar_dripping |
| effectName | str | 特效资源名称,如minecraft:nectar_drip_particle |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddParticleEffectToOneActor(entityId, "nectar_dripping", "minecraft:nectar_drip_particle")AddRenderControllerToOneActor
客户端开发补充
向单个生物渲染定义添加渲染控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加单个生物的渲染控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物entityId |
| renderControllerName | str | 渲染控制器名称 |
| condition | str | 渲染控制器条件,当该条件成立时,renderControllerName指向的渲染控制器才会生效 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddRenderControllerToOneActor(entityId, 'controller.render.llama', 'query.mod.condition')AddRenderMaterialToOneActor
客户端开发补充
向单个生物渲染定义添加材质。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加单个生物渲染需要的材质
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物的entityId |
| materialKey | str | 材质的键 |
| materialName | str | 材质名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddRenderMaterialToOneActor(entityId, 'custom_material_key', 'custom_material_name')AddScriptAnimateToOneActor
客户端开发补充
向单个生物渲染定义添加动画脚本。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
在单个生物的客户端实体定义(minecraft:client_entity)json中的scripts/animate节点添加动画/动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 实体entityId |
| animateName | str | 动画/动画控制器名称,如look_at_target |
| condition | str | 动画/动画控制器控制表达式,默认为空,如query.mod.index > 0 |
| autoReplace | bool | 是否覆盖已存在的动画/动画控制器,默认值为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.AddAnimationControllerToOneActor(entityId, animation_controller_short_name", "controller.animation.pig.custom_animation_controller")
comp.AddScriptAnimateToOneActor(entityId, "animation_controller_short_name", "query.mod.index > 0")AddSoundEffectToOneActor
客户端开发补充
向单个生物渲染定义添加音效资源。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加单个生物的音效资源
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 实体entityId |
| soundKey | str | 音效资源Key |
| soundName | str | 音效资源名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
目前只支持在动作(animation)中播放音效,不支持在动作控制器(animation controller)中播放音效。
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddSoundEffectToOneActor(entityId, "sound_thunder", "ambient.weather.thunder")AddTextureToOneActor
客户端开发补充
向单个生物渲染定义添加贴图。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
增加单个生物的渲染贴图
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物实体entityId |
| textureKey | str | 贴图键 |
| texturePath | str | 贴图路径 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.AddTextureToOneActor(entityId, "default", "textures/entity/panda/panda")BindEntityToEntity
客户端开发补充
绑定骨骼模型跟随另一实体;绑定本地玩家时摄像机也会跟随。
客户端
method in mod.client.component.modelCompClient.ModelComponentClient
- 描述
绑定骨骼模型跟随其他entity,如果当前entity是本地玩家,摄像机也跟随其他entity
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| bindEntityId | str | 绑定跟随的实体Id |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | False表示失败,True表示成功 |
备注
本接口只实现视觉效果,本质上实体还是在原地,因此需要调用接口设置实体的位置到其他entity的位置上,否则当实体本身不在摄像机范围内的时候就会不进行渲染了。
示例
import mod.client.extraClientApi as clientApi
# 将entityId的实体绑定至bindEntityId的实体
comp = clientApi.GetEngineCompFactory().CreateModel(entityId)
comp.BindEntityToEntity(bindEntityId)ClearActorBlockGeometry
客户端开发补充
删除实体上的全部方块几何体模型。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除实体中所有的方块几何体模型。
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 删除是否成功,成功返回True,失败返回False。 |
- 示例
import mod.client.extraClientApi as clientApi
blockGeometryComp = clientApi.GetEngineCompFactory().CreateBlockGeometry(levelId)
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender("-4294967295")
# 合并方块并转换为名叫"my_block_geometry"的方块几何体模型
geometryName = blockGeometryComp.CombineBlockFromPosListToGeometry([(200,64,200),(201,65,202)],"my_block_geometry")
# 添加到实体id为-4294967295的实体中
print actorRenderComp.AddActorBlockGeometry(geometryName)
# 清空实体中所有的方块几何体
print actorRenderComp.ClearActorBlockGeometry()CopyActorGeometryFromPlayer
客户端开发补充
将玩家几何体复制到指定生物类型的渲染定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
将渲染几何体从某个玩家拷贝到某类生物identifier上
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| fromPlayerId | str | 源玩家id |
| toActorIdentifier | str | 拷贝到的生物identifier |
| fromGeometryKey | str | 源渲染几何体的键 |
| newGeometryKey | str | 拷贝后新渲染几何体的键 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效 动画和贴图都是与几何体密切相关的,改变几何体也需要改变动画与贴图。建议先修改生物的动画以及动画控制器后再修改生物的几何。
某些生物受初始动画影响,几何体会有初始偏移,会导致修改几何体后表现异常。若修改后的几何体没有当前动画需要的骨骼时,会触发报错。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.CopyActorGeometryFromPlayer(playerId, "minecraft:sheep", "default", "default")CopyActorRenderMaterialFromPlayer
客户端开发补充
将玩家材质复制到指定生物类型的渲染定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
将渲染材质从某个玩家拷贝到某类生物identifier上
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| fromPlayerId | str | 源玩家id |
| toActorIdentifier | str | 拷贝到的生物identifier |
| fromMaterialKey | str | 源材质的键 |
| newMaterialKey | str | 拷贝后新材质的键 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.CopyActorRenderMaterialFromPlayer(playerId, 'minecraft:sheep', 'default', 'default')CopyActorTextureFromPlayer
客户端开发补充
将玩家贴图复制到指定生物类型的渲染定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
将贴图从某个玩家拷贝到某类生物identifier上
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| fromPlayerId | str | 源玩家id |
| toActorIdentifier | str | 拷贝到的生物identifier |
| fromTextureKey | str | 贴图键 |
| newTextureKey | str | 拷贝后新贴图的键 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.CopyActorTextureFromPlayer(playerId, "minecraft:sheep", "default", "default")CopyPlayerGeometryToOneActor
客户端开发补充
将玩家几何体复制到单个生物的渲染定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
将渲染几何体从某个玩家拷贝到某个生物上
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| fromPlayerId | str | 源玩家id |
| fromGeometryKey | str | 源渲染几何体的键 |
| newGeometryKey | str | 拷贝后新渲染几何体的键 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效 动画和贴图都是与几何体密切相关的,改变几何体也需要改变动画与贴图。建议先修改生物的动画以及动画控制器后再修改生物的几何。
该接口使用时,会将这类生物当前的客户端数据拷贝一份,独立给这个实体使用(如果这个实体已经独自持有客户端数据则不会再次拷贝)
当生物离开再出现在视野时,不会恢复oneActor类渲染接口的设置,需要开发者监听AddEntityClientEvent再次设置entity类渲染接口进行恢复
某些生物受初始动画影响,几何体会有初始偏移,会导致修改几何体后表现异常。若修改后的几何体没有当前动画需要的骨骼时,会触发报错。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.CopyPlayerGeometryToOneActor(playerId, "default", "default")CopyPlayerRenderMaterialToOneActor
客户端开发补充
将玩家材质复制到单个生物的渲染定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
将渲染材质从某个玩家拷贝到某个生物上
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| fromPlayerId | str | 源玩家id |
| fromMaterialKey | str | 源材质的键 |
| newMaterialKey | str | 拷贝后新材质的键 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 添加是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
该接口使用时,会将这类生物当前的客户端数据拷贝一份,独立给这个实体使用(如果这个实体已经独自持有客户端数据则不会再次拷贝)
当生物离开再出现在视野时,不会恢复oneActor类渲染接口的设置,需要开发者监听AddEntityClientEvent再次设置entity类渲染接口进行恢复
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.CopyPlayerRenderMaterialToOneActor(playerId, 'default', 'default')CopyPlayerTextureToOneActor
客户端开发补充
将玩家贴图复制到单个生物的渲染定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
将贴图从某个玩家拷贝到某个生物上
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| fromPlayerId | str | 源玩家id |
| fromTextureKey | str | 贴图键 |
| newTextureKey | str | 拷贝后新贴图的键 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
该接口使用时,会将这类生物当前的客户端数据拷贝一份,独立给这个实体使用(如果这个实体已经独自持有客户端数据则不会再次拷贝)
当生物离开再出现在视野时,不会恢复oneActor类渲染接口的设置,需要开发者监听AddEntityClientEvent再次设置entity类渲染接口进行恢复
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.CopyPlayerTextureToOneActor(playerId, "default", "default")DeleteActorBlockGeometry
客户端开发补充
删除实体上的指定方块几何体模型。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除实体中指定方块几何体模型。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| geometryName | str | 几何体模型的名称,用于标识每个几何体模型,相当于是该模型的id |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 删除是否成功,成功返回True,失败返回False。 |
- 示例
import mod.client.extraClientApi as clientApi
blockGeometryComp = clientApi.GetEngineCompFactory().CreateBlockGeometry(levelId)
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender("-4294967295")
# 合并方块并转换为名叫"my_block_geometry"的方块几何体模型
geometryName = blockGeometryComp.CombineBlockFromPosListToGeometry([(200,64,200),(201,65,202)],"my_block_geometry")
# 添加到实体id为-4294967295的实体中
print actorRenderComp.AddActorBlockGeometry(geometryName)
# 删除刚才添加的方块几何体
print actorRenderComp.DeleteActorBlockGeometry(geometryName)GetActorRenderParams
客户端开发补充
读取实体渲染参数,包含受支持的玩家参数。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
获取实体(包括玩家)渲染参数
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 实体Id |
| paramTypeStr | str | 渲染参数类型,可选类型有"textures","geometry","materials","animations","render_controllers","particle_effects","sound_effects" |
| getValue | bool | 是否获取详细值,默认为False。该参数对render_controllers无效 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(str) | 参数列表,如获取失败则返回None |
备注
无法用于获取Player的ColorTexture
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
textureKeys = comp.GetActorRenderParams(entityId, "textures")GetEntityExtraUniforms
客户端开发补充
读取实体着色器的自定义向量参数。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
获取在实体shader当中使用的自定义变量的值。该自定义变量包含EXTRA_ACTOR_UNIFORM1,EXTRA_ACTOR_UNIFORM2,EXTRA_ACTOR_UNIFORM3,EXTRA_ACTOR_UNIFORM4,总共4组,每组为一个vec4(float, float, float ,float)类型的向量。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| uniformIndex | int | 需要设置的自定义变量的下标,值范围为1~4。分别对应EXTRA_ACTOR_UNIFORM1,EXTRA_ACTOR_UNIFORM2,EXTRA_ACTOR_UNIFORM3,EXTRA_ACTOR_UNIFORM4。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float,float) | 返回的对应自定义变量的值。获取失败则返回None。 |
备注
此接口是针对使用了原版BB模型的实体,使用了骨骼模型的实体和玩家请使用SetExtraUniformValue接口进行动态设置。
示例
import mod.client.extraClientApi as clientApi
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
# 获取实体id为entityId的实体正在使用的自定义变量EXTRA_ACTOR_UNIFORM2的值
print actorRenderComp.GetEntityExtraUniforms(2)
# 获取实体id为entityId的实体正在使用的自定义变量EXTRA_ACTOR_UNIFORM4的值
print actorRenderComp.GetEntityExtraUniforms(4)GetEntityRenderDistance
客户端开发补充
读取本地玩家周围实体的可渲染距离。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
获取玩家的实体可渲染距离。玩家周围的实体指这个区块内的实体,也包含玩家自身。实体的渲染距离指,实体的位置到玩家相机位置的距离。可渲染距离指,如果实体的渲染距离在可渲染距离之内,则实体会被渲染出来,如果在距离以外,则实体不会被渲染出来。仅对本地玩家有效。
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 实体可渲染距离。如果获取失败,则返回-1 |
- 示例
import mod.client.extraClientApi as clientApi
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
# 获取当前玩家的实体可渲染距离
print actorRenderComp.GetEntityRenderDistance()GetEntityUIExtraUniforms
客户端开发补充
读取纸娃娃控件按类型渲染实体时使用的自定义着色变量。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
获取在实体shader当中使用的UI自定义变量的值,该变量可在微软UI纸娃娃(paperdoll)及网易版纸娃娃(neteasepaperdoll)上使用identifier渲染某一类生物实体时使用。该自定义变量包含EXTRA_ACTOR_UNIFORM1,EXTRA_ACTOR_UNIFORM2,EXTRA_ACTOR_UNIFORM3,EXTRA_ACTOR_UNIFORM4,总共4组,每组为一个vec4(float, float, float ,float)类型的向量。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityIdentifier | str | 需要设置的实体identifier。如果获取玩家,则填写minecraft:player。 |
| uniformIndex | int | 需要设置的自定义变量的下标,值范围为1~4。分别对应EXTRA_ACTOR_UNIFORM1,EXTRA_ACTOR_UNIFORM2,EXTRA_ACTOR_UNIFORM3,EXTRA_ACTOR_UNIFORM4。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float,float) | 返回的对应自定义变量的值。获取失败则返回None。 |
备注
此接口是针对使用了原版BB模型的实体,使用了骨骼模型的实体和玩家请使用SetExtraUniformValue接口进行动态设置。
示例
import mod.client.extraClientApi as clientApi
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender(None)
# 获取苦力怕正在使用的UI自定义变量EXTRA_ACTOR_UNIFORM2的值
print actorRenderComp.GetEntityUIExtraUniforms("minecraft:creeper", 2)
# 获取玩家正在使用的UI自定义变量EXTRA_ACTOR_UNIFORM4的值
print actorRenderComp.GetEntityUIExtraUniforms("minecraft:player",4)GetNotRenderAtAll
客户端开发补充
查询实体是否完全关闭渲染。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
获取实体是否不渲染
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | True表示不渲染 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
notRender = comp.GetNotRenderAtAll()GetQueryableBoneOrientation
客户端开发补充
读取原版模型指定骨骼的矩阵信息。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
获取实体的原版模型指定骨骼的骨骼矩阵信息。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| boneName | str | 骨骼名称 |
| isClientEntity | bool | 是否是客户端实体。如果实体是由CreateClientEntityByTypeStr接口创建的客户端实体,则需要传入True.默认为False |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(tuple(float,float,float,float)) | 获取成功返回对应4x4骨骼矩阵。获取失败则返回None |
- 示例
import mod.client.extraClientApi as clientApi
player_id = clientApi.GetLocalPlayerId()
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender(player_id)
print actorRenderComp.GetQueryableBoneOrientation("head")IsShowName
客户端开发补充
查询名称是否按游戏默认规则显示。
客户端
method in mod.client.component.nameCompClient.NameComponentClient
- 描述
获取生物名字是否按照默认游戏逻辑显示(包括玩家)
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 返回是否按照默认游戏逻辑显示 |
备注
获取的值仅代表实体名字是否显示,但是最终是否显示还会受到全局名字是否显示影响,详见接口HideNameTag
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateName(entityId)
comp.IsShowName()RebuildActorRender
客户端开发补充
重建生物渲染数据;玩家需使用专用重建接口。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
重建生物的数据渲染器(该接口不支持玩家,玩家请使用RebuildPlayerRender)
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 实体identifier |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 重建是否成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.RebuildActorRender('minecraft:villager')RebuildRenderForOneActor
客户端开发补充
应用单个生物的渲染定义修改;不适用于玩家。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
使用完entity类渲染接口后,重建单个生物渲染控制器(该接口不支持玩家,玩家请使用RebuildPlayerRender)
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 重建是否成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.RebuildRenderForOneActor()RemoveActorAnimationController
客户端开发补充
移除生物渲染定义中的动画控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
移除生物渲染动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物的identifier |
| animationControllKey | str | 动画控制器键,注意,该值需要在json中动画控制器键加上前缀“controller__” |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.RemoveActorAnimationController("minecraft:villager", "controller__use_item_progress")RemoveActorGeometry
客户端开发补充
移除生物渲染定义中的几何体。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除生物渲染几何体
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物实体identifier |
| geometryKey | str | 渲染几何体名称,如熊猫几何体geometry.panda |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效 动画和贴图都是与几何体密切相关的,改变几何体也需要改变动画与贴图
示例
import mod.client.extraClientApi as clientApi
# geometry definition in panda.entity.json
# "geometry": {
# "default": "geometry.panda"
# },
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.RemoveActorGeometry("minecraft:panda", "default")RemoveActorRenderController
客户端开发补充
移除生物渲染定义中的渲染控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除生物渲染控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物identifier |
| renderControllerName | str | 渲染控制器名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 删除是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.RemoveActorRenderController('minecraft:villager', 'custom_render_controller_name')RemoveActorTexture
客户端开发补充
移除生物渲染定义中的贴图。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除生物渲染贴图
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物实体identifier |
| textureKey | str | 贴图键,如default |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildActorRender才会生效
示例
import mod.client.extraClientApi as clientApi
# texture definition in panda.entity.json
# "textures": {
# "default": "textures/entity/panda/panda",
# "lazy": "textures/entity/panda/panda_lazy",
# "worried": "textures/entity/panda/panda_worried",
# "playful": "textures/entity/panda/panda_playful",
# "brown": "textures/entity/panda/panda_brown",
# "weak": "textures/entity/panda/panda_sneezy",
# "aggressive": "textures/entity/panda/panda_aggressive"
# }
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.RemoveActorTexture("minecraft:panda", "default")RemoveAnimationControllerForOneActor
客户端开发补充
移除单个生物渲染定义中的动画控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
移除单个生物渲染动画控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物的entityId |
| animationControllKey | str | 动画控制器键,注意,该值需要在json中动画控制器键加上前缀“controller__” |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.RemoveAnimationControllerForOneActor(entityId, "controller__use_item_progress")RemoveGeometryForOneActor
客户端开发补充
移除单个生物渲染定义中的几何体。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除单个生物的渲染几何体
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物实体entityId |
| geometryKey | str | 渲染几何体名称,如熊猫几何体geometry.panda |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效 动画和贴图都是与几何体密切相关的,改变几何体也需要改变动画与贴图
示例
import mod.client.extraClientApi as clientApi
# geometry definition in panda.entity.json
# "geometry": {
# "default": "geometry.panda"
# },
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.RemoveGeometryForOneActor("0", "default")RemoveRenderControllerForOneActor
客户端开发补充
移除单个生物渲染定义中的渲染控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除单个生物的渲染控制器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物entityId |
| renderControllerName | str | 渲染控制器名称 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 删除是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.RemoveRenderControllerForOneActor('0', 'custom_render_controller_name')RemoveTextureForOneActor
客户端开发补充
移除单个生物渲染定义中的贴图。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
删除单个生物的渲染贴图
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物实体entityId |
| textureKey | str | 贴图键,如default |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
调用该接口后需要调用RebuildRenderForOneActor才会生效
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.RemoveTextureForOneActor("0", "default")ResetActorRender
客户端开发补充
重置通过实体渲染接口设置的资源和控制器。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
重置实体渲染接口,包括动画、动画控制器、渲染控制器、贴图、材质、特效资源、音效资源等。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| actorIdentifier | str | 生物的identifier |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功 |
备注
该接口目前只对生物生效,无法对玩家实体生效。只有修改过的实体才能reset成功,并且reset后在有新修改前,都无法reset成功。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(levelId)
comp.ResetActorRender("minecraft:sheep")ResetBindEntity
客户端开发补充
解除实体的跟随绑定。
客户端
method in mod.client.component.modelCompClient.ModelComponentClient
- 描述
取消目标entity的绑定实体,取消后不再跟随任何其他entity
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | False表示失败,True表示成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateModel(entityId)
comp.ResetBindEntity()ResetEntityExtraSkin
客户端开发补充
清除额外添加的皮肤渲染组件,恢复原始状态。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
清除通过 actorRender 接口为实体(包括玩家)额外添加的皮肤渲染组件(几何体、动画、动画控制器、贴图、材质、渲染控制器),还原实体到原始渲染状态。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 实体的 entityId |
| skinType | int | 要清除的皮肤组件类型,使用 ExtraSkinType 枚举值,默认为 None(等同于 ExtraSkinType.ALL,清除全部) |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 操作是否成功 |
备注
- 调用本接口后需手动调用 RebuildPlayerRender(玩家)或 RebuildRenderForOneActor(非玩家实体)才会生效。
本接口只清除通过 mod 接口额外添加的渲染属性,不影响实体原版定义中的渲染配置。
针对玩家实体,同时清理 operationHistory 中的对应历史,确保该玩家重进 AOI 时不会重复应用已清除的组件。
skinType 可选值参考 GetMinecraftEnum().ExtraSkinType。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
# 清除所有额外皮肤组件后重建渲染
comp.ResetEntityExtraSkin(entityId)
comp.RebuildPlayerRender() # 玩家实体
# comp.RebuildRenderForOneActor() # 非玩家实体ResetRenderForOneActor
客户端开发补充
移除单个生物的独立渲染覆盖,恢复所属类型的渲染定义。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
将调用OneActor类渲染接口(CopyPlayerTextureToOneActor、CopyPlayerRenderMaterialToOneActor等)的生物重置回种群
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 重置是否成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.ResetRenderForOneActor()SetActorAllBlockGeometryVisible
客户端开发补充
控制实体上全部方块几何体模型的显示状态。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
设置实体中所有的方块几何体模型是否显示。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| visible | bool | 设置是否显示或隐藏,True表示显示,False表示隐藏 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True,失败返回False。 |
- 示例
import mod.client.extraClientApi as clientApi
blockGeometryComp = clientApi.GetEngineCompFactory().CreateBlockGeometry(levelId)
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender("-4294967295")
# 合并方块并转换为名叫"my_block_geometry"的方块几何体模型
geometryName = blockGeometryComp.CombineBlockFromPosListToGeometry([(200,64,200),(201,65,202)],"my_block_geometry")
# 添加到实体id为-4294967295的实体中
print actorRenderComp.AddActorBlockGeometry(geometryName)
# 隐藏所有的方块几何体
print actorRenderComp.SetActorAllBlockGeometryVisible(False)SetActorBlockGeometryVisible
客户端开发补充
能力:实体 · 方块几何体 · 可见性
作用对象:方块几何体
控制实体上指定方块几何体模型是否显示。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
设置实体中指定的方块几何体模型是否显示。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| geometryName | str | 几何体模型的名称,用于标识每个几何体模型,相当于是该模型的id |
| visible | bool | 设置是否显示或隐藏,True表示显示,False表示隐藏 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True,失败返回False。 |
- 示例
import mod.client.extraClientApi as clientApi
blockGeometryComp = clientApi.GetEngineCompFactory().CreateBlockGeometry(levelId)
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender("-4294967295")
# 合并方块并转换为名叫"my_block_geometry"的方块几何体模型
geometryName = blockGeometryComp.CombineBlockFromPosListToGeometry([(200,64,200),(201,65,202)],"my_block_geometry")
# 添加到实体id为-4294967295的实体中
print actorRenderComp.AddActorBlockGeometry(geometryName)
# 隐藏刚才添加的方块几何体
print actorRenderComp.SetActorBlockGeometryVisible(geometryName, False)SetAlwaysShowName
客户端开发补充
能力:持续显示 · 实体 · 实体名称
控制实体名称是否在未被瞄准时也持续显示。
客户端
method in mod.client.component.nameCompClient.NameComponentClient
- 描述
设置生物名字是否一直显示,瞄准点不指向生物时也能显示
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| show | bool | True为显示 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 返回是否设置成功 |
备注
该接口只对普通生物生效,对玩家设置不起作用
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateName(entityId)
# 不显示头上的名字
comp.SetAlwaysShowName(False)SetColor
客户端开发补充
设置血条前景及背景颜色。
客户端
method in mod.client.component.healthCompClient.HealthComponentClient
- 描述
设置血条的颜色及背景色
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| front | tuple(float,float,float,float) | 血条颜色的RGBA值,范围0-1 |
| back | tuple(float,float,float,float) | 背景颜色的RGBA值,范围0-1 |
- 返回值
无
备注
必须用game组件设置ShowHealthBar时才能显示血条!!
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateHealth(entityId)
comp.SetColor((0, 0, 0, 1), (1, 1, 1, 1))SetEntityExtraUniforms
客户端开发补充
设置实体着色器的自定义向量参数。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
设置可在实体shader当中使用的自定义变量的值。该自定义变量总共可设置EXTRA_ACTOR_UNIFORM1,EXTRA_ACTOR_UNIFORM2,EXTRA_ACTOR_UNIFORM3,EXTRA_ACTOR_UNIFORM4,总共4组,每组为一个vec4(float, float, float ,float)类型的向量,向量的默认值为(1.0,1.0,1.0,1.0)。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| uniformIndex | int | 需要设置的自定义变量的下标,值范围为1~4。分别对应EXTRA_ACTOR_UNIFORM1,EXTRA_ACTOR_UNIFORM2,EXTRA_ACTOR_UNIFORM3,EXTRA_ACTOR_UNIFORM4。 |
| data | tuple(float,float,float,float) | 需要设置的自定义变量的值。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True,否则返回False |
备注
此接口是针对使用了原版BB模型的实体,使用了骨骼模型的实体和玩家请使用SetExtraUniformValue接口进行动态设置。
示例
import mod.client.extraClientApi as clientApi
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
# 对实体id为entityId的实体设置自定义变量EXTRA_ACTOR_UNIFORM1的值
print actorRenderComp.SetEntityExtraUniforms(1, (2.5,2.5,2.5,2.5))
# 对实体id为entityId的实体设置自定义变量EXTRA_ACTOR_UNIFORM3的值
print actorRenderComp.SetEntityExtraUniforms(3, (3.0,3.0,3.0,3.0))
# 接下来,我们在实体的vertex shader或是fragment shader中做如下声明及使用:
#
# // .. 省略其他代码
# // 声明这两个自定义变量
# uniform vec4 EXTRA_ACTOR_UNIFORM1;
# uniform vec4 EXTRA_ACTOR_UNIFORM3;
#
# void main() {
# vec4 my_custom_value = EXTRA_ACTOR_UNIFORM1;
# vec4 my_custom_value = EXTRA_ACTOR_UNIFORM3;
# // .. do what you want ..
# }SetEntityRenderDistance
客户端开发补充
设置本地玩家周围实体的可渲染距离。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
设置玩家周围的实体的可渲染距离。玩家周围的实体指这个区块内的实体,也包含玩家自身。实体的渲染距离指,实体的位置到玩家相机位置的距离。可渲染距离指,如果实体的渲染距离在可渲染距离之内,则实体会被渲染出来,如果在距离以外,则实体不会被渲染出来。仅对本地玩家有效。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| distance | float | 实体的可渲染距离,有效值范围为大于等于0。如果小于0,则使用原版游戏内的默认可渲染距离。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True,失败返回False。 |
备注
需要特别注意,该渲染距离指的是实体的位置到玩家相机的位置,而非玩家的位置。当玩家相机视觉上下转动或是左右转动时,玩家相机的位置是绕以相机中心为球心的球形表面进行旋转。因此视觉转动时,玩家相机位置与实体之间距离也会进行改变,导致该实体的渲染距离改变。一些玩法会改变相机位置制作来超远或者超过视角的,可能会出现看不到玩家自身模型的问题。此时可以调用该接口来调整渲染距离,从而使得玩家自身可见或不可见。
示例
import mod.client.extraClientApi as clientApi
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender(playerId)
# 设置实体的可渲染距离为48
print actorRenderComp.SetEntityRenderDistance(48)SetEntityUIExtraUniforms
客户端开发补充
设置纸娃娃控件按类型渲染实体时使用的着色变量。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
设置可在实体shader当中使用的UI自定义变量的值,可在微软UI纸娃娃(paperdoll)及网易版纸娃娃(neteasepaperdoll)上使用identifier渲染某一类生物实体时使用。该自定义变量总共可设置EXTRA_ACTOR_UNIFORM1,EXTRA_ACTOR_UNIFORM2,EXTRA_ACTOR_UNIFORM3,EXTRA_ACTOR_UNIFORM4,总共4组,每组为一个vec4(float, float, float ,float)类型的向量,向量的默认值为(1.0,1.0,1.0,1.0)。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityIdentifier | str | 需要设置的实体identifier。如果需要对玩家设置,则填写minecraft:player。 |
| uniformIndex | int | 需要设置的自定义变量的下标,值范围为1~4。分别对应EXTRA_ACTOR_UNIFORM1,EXTRA_ACTOR_UNIFORM2,EXTRA_ACTOR_UNIFORM3,EXTRA_ACTOR_UNIFORM4。 |
| data | tuple(float,float,float,float) | 需要设置的自定义变量的值。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功,成功返回True,否则返回False |
备注
此接口是针对使用了原版BB模型的实体,使用了骨骼模型的实体和玩家请使用SetExtraUniformValue接口进行动态设置。
示例
import mod.client.extraClientApi as clientApi
actorRenderComp = clientApi.GetEngineCompFactory().CreateActorRender(None)
# 对苦力怕设置自定义变量EXTRA_ACTOR_UNIFORM1的值
print actorRenderComp.SetEntityUIExtraUniforms("minecraft:creeper", 1, (2.5,2.5,2.5,2.5))
# 对玩家实体设置自定义变量EXTRA_ACTOR_UNIFORM3的值
print actorRenderComp.SetEntityUIExtraUniforms("minecraft:player", 3, (3.0,3.0,3.0,3.0))
# 接下来,我们在实体的vertex shader或是fragment shader中做如下声明及使用:
#
# // .. 省略其他代码
# // 声明这两个自定义变量
# uniform vec4 EXTRA_ACTOR_UNIFORM1;
# uniform vec4 EXTRA_ACTOR_UNIFORM3;
#
# void main() {
# vec4 my_custom_value = EXTRA_ACTOR_UNIFORM1;
# vec4 my_custom_value = EXTRA_ACTOR_UNIFORM3;
# // .. do what you want ..
# }SetHealthBarDeviation
客户端开发补充
设置实体血条相对于实体的高度偏移。
客户端
method in mod.client.component.healthCompClient.HealthComponentClient
- 描述
设置某个entity血条的相对高度
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| health_bar_deviation | float | 血条的相对高度 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
备注
必须用game组件设置ShowHealthBar时才能显示血条;血条默认在生物AABB上方1.5高度处
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateHealth(entityId)
# 设置血条的相对高度
comp.SetHealthBarDeviation(1.0)SetNameDeeptest
客户端开发补充
能力:深度检测 · 实体 · 实体名称
控制实体名称显示是否受深度遮挡影响。
客户端
method in mod.client.component.gameCompClient.GameComponentClient
- 描述
设置名字是否透视
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| deeptest | bool | True为不透视。默认情况下为透视 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateGame(levelId)
# 设置为不透视
comp.SetNameDeeptest(True)SetNotRenderAtAll
客户端开发补充
控制是否完全关闭实体渲染。
客户端
method in mod.client.component.actorRenderCompClient.ActorRenderCompClient
- 描述
设置是否关闭实体渲染
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| notRender | bool | True表示不渲染该实体 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.client.extraClientApi as clientApi
# 不渲染单个实体 entityId
comp = clientApi.GetEngineCompFactory().CreateActorRender(entityId)
comp.SetNotRenderAtAll(True)
# 重新开始渲染该实体
comp.SetNotRenderAtAll(False)SetRenderLocalPlayer
客户端开发补充
控制本地玩家模型是否渲染。
客户端
method in mod.client.component.gameCompClient.GameComponentClient
- 描述
设置本地玩家是否渲染
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| render | bool | True为渲染 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateGame(levelId)
# 不渲染本地玩家
comp.SetRenderLocalPlayer(False)SetShowName
客户端开发补充
控制名称是否按默认游戏逻辑显示。
客户端
method in mod.client.component.nameCompClient.NameComponentClient
- 描述
设置生物名字是否按照默认游戏逻辑显示(包括玩家)
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| show | bool | True为显示 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 返回是否设置成功 |
备注
- 当设置为True时,生物的名字显示遵循游戏默认的渲染逻辑,即普通生物需要中心点指向生物才显示名字,玩家则是会一直显示名字
但设置为False时,生物名字不再显示。
生物名字显示与否还会受到全局名字显示与否影响,详见接口HideNameTag
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateName(entityId)
# 不显示头上的名字
comp.SetShowName(False)ShowHealth
客户端开发补充
控制指定实体是否显示血条。
客户端
method in mod.client.component.healthCompClient.HealthComponentClient
- 描述
设置某个entity是否显示血条,默认为显示
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| show | bool | 设置是否显示 |
- 返回值
无
备注
必须用game组件设置ShowHealthBar时才能显示血条!!
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateHealth(entityId)
# 设置该entity不显示血条
comp.ShowHealth(False)ShowHealthBar
客户端开发补充
控制血条显示开关。
客户端
method in mod.client.component.gameCompClient.GameComponentClient
- 描述
设置是否显示血条
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| show | bool | True为显示。开启后可用health组件的SetColor、ShowHealth接口,单独设置某个实体的血条颜色及是否显示 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateGame(levelId)
comp.ShowHealthBar(True)