--- sidebarDepth: 1 --- # 属性 ## ChangeEntityDimension 服务端 method in mod.server.component.dimensionCompServer.DimensionCompServer - 描述 传送实体 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | dimensionId | int | 维度id,0-主世界; 1-下界; 2-末地; 或其他自定义维度 | | pos | tuple(int,int,int) | 传送的坐标,假如输入None,那么就优先选择目标维度的传送门作为目的地,其次使用维度坐标映射逻辑确定目的地 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否设置成功 | - 备注 - 该接口无法对玩家使用,玩家请使用ChangePlayerDimension - 该接口只能传送到另一个维度,如果实体已经在这个维度会返回False - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateDimension(entityId) comp.ChangeEntityDimension(0, (0,4,0)) ``` ## GetAttrMaxValue 服务端客户端 ### 服务端接口 method in mod.server.component.attrCompServer.AttrCompServer - 描述 获取实体的引擎属性的最大值 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | type | int | [AttrType枚举](../../枚举值/AttrType.md) | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | float | 属性值结果 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateAttr(entityId) comp.GetAttrMaxValue(serverApi.GetMinecraftEnum().AttrType.HEALTH) ``` ### 客户端接口 method in mod.client.component.attrCompClient.AttrCompClient - 描述 获取属性最大值,包括生命值,饥饿度,移速等 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | type | int | [AttrType枚举](../../枚举值/AttrType.md) | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | float | 属性值结果 | - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateAttr(entityId) comp.GetAttrMaxValue(clientApi.GetMinecraftEnum().AttrType.HEALTH) ``` ## GetAttrValue 服务端客户端 ### 服务端接口 method in mod.server.component.attrCompServer.AttrCompServer - 描述 获取实体的引擎属性 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | attrType | int | [AttrType枚举](../../枚举值/AttrType.md) | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | float | 属性结果 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateAttr(entityId) comp.GetAttrValue(serverApi.GetMinecraftEnum().AttrType.HEALTH) ``` ### 客户端接口 method in mod.client.component.attrCompClient.AttrCompClient - 描述 获取属性值,包括生命值,饥饿度,移速 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | attrType | int | [AttrType枚举](../../枚举值/AttrType.md) | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | float | 属性结果 | - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateAttr(entityId) comp.GetAttrValue(clientApi.GetMinecraftEnum().AttrType.HEALTH) ``` ## GetBodyRot 客户端 method in mod.client.component.rotCompClient.RotComponentClient - 描述 获取实体的身体的角度 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | float | 身体绕竖直方向的角度,单位是角度,如果没有身体,返回为0 | - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateRot(entityId) y = comp.GetBodyRot() ``` ## GetCurrentAirSupply 服务端 method in mod.server.component.breathCompServer.BreathCompServer - 描述 生物当前氧气储备值 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | int | 生物当前氧气储备值 | - 备注 - 注意:该值返回的是当前氧气储备的支持的逻辑帧数 = 氧气储备值 * 逻辑帧数(每秒20帧数) - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateBreath(entityId) comp.GetCurrentAirSupply() ``` ## GetEntityDimensionId 服务端 method in mod.server.component.dimensionCompServer.DimensionCompServer - 描述 获取实体所在维度 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | int | 维度id,0-主世界; 1-下界; 2-末地; 或其他自定义维度 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateDimension(entityId) comp.GetEntityDimensionId() ``` ## GetEntityOwner 服务端 method in mod.server.component.actorOwnerCompServer.ActorOwnerComponentServer - 描述 获取实体的属主 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | str | 实体属主id | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateActorOwner(entityId) ownerId = comp.GetEntityOwner() ``` ## GetFootPos 服务端客户端 ### 服务端接口 method in mod.server.component.posCompServer.PosComponentServer - 描述 获取实体脚所在的位置 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | tuple(float,float,float) | 位置信息 | - 备注 - 获取实体脚底的位置(除了睡觉时) - 类似接口参见[获取实体位置](#getpos) - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreatePos(entityId) entityFootPos = comp.GetFootPos() ``` ### 客户端接口 method in mod.client.component.posCompClient.PosComponentClient - 描述 获取实体脚所在的位置 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | tuple(float,float,float) | 位置信息 | - 备注 - 获取实体脚底的位置(除了睡觉时) - 类似接口参见[获取实体位置](#getpos) - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreatePos(entityId) #获取位置: entityFootPos = comp.GetFootPos() ``` ## GetGravity 服务端 method in mod.server.component.gravityCompServer.GravityComponentServer - 描述 获取实体的重力因子,当生物重力因子为0时则应用世界的重力因子 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | float | 重力因子 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGravity(entityId) comp.GetGravity() ``` ## GetMaxAirSupply 服务端 method in mod.server.component.breathCompServer.BreathCompServer - 描述 获取生物最大氧气储备值 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | int | 最大氧气储备值 | - 备注 - 注意:该值返回的是最大氧气储备的支持的逻辑帧数 = 氧气储备值 * 逻辑帧数(每秒20帧数) - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateBreath(entityId) comp.GetMaxAirSupply() ``` ## GetName 服务端 method in mod.server.component.nameCompServer.NameComponentServer - 描述 获取生物的自定义名称,即使用命名牌或者SetName接口设置的名称 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | str | 生物的自定义名称 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateName(entityId) comp.GetName() ``` ## GetPos 服务端客户端 ### 服务端接口 method in mod.server.component.posCompServer.PosComponentServer - 描述 获取实体位置 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | tuple(float,float,float) | 位置信息 | - 备注 - 对于非玩家,获取到的是脚底部位的位置 - 对于玩家,如果处于行走,站立,游泳,潜行,滑翔状态,获得的位置比脚底位置高1.62;如果处于睡觉状态,获得的位置比最低位置高0.2 - 类似接口有[GetFootPos](#getfootpos),对任何实体都是获取脚底部位的位置 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreatePos(entityId) comp.GetPos() ``` ### 客户端接口 method in mod.client.component.posCompClient.PosComponentClient - 描述 获取实体位置 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | tuple(float,float,float) | 实体的坐标 | - 备注 - 对于非玩家,获取到的是脚底部位的位置 - 对于玩家,如果处于行走,站立,游泳,潜行,滑翔状态,获得的位置比脚底位置高1.62,如果处于睡觉状态,获得的位置比最低位置高0.2 - 类似接口有[GetFootPos](#getfootpos),对任何实体都是获取脚底部位的位置 - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreatePos(entityId) #获取位置: entityPos = comp.GetPos() ``` ## GetRot 服务端客户端 ### 服务端接口 method in mod.server.component.rotCompServer.RotComponentServer - 描述 获取实体头与水平方向的俯仰角度和竖直方向的旋转角度,获得角度后可用GetDirFromRot接口转换为朝向的单位向量 MC坐标系说明 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | tuple(float,float) | (上下角度,左右角度)单位是角度而不是弧度 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRot(entityId) comp.GetRot() ``` ### 客户端接口 method in mod.client.component.rotCompClient.RotComponentClient - 描述 获取实体头与水平方向的俯仰角度和竖直方向的旋转角度,获得角度后可用GetDirFromRot接口转换为朝向的单位向量 MC坐标系说明 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | tuple(float,float) | 俯仰角度及绕竖直方向旋转的角度,单位是角度 | - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateRot(entityId) x, y = comp.GetRot() ``` ## GetSize 服务端 method in mod.server.component.collisionBoxCompServer.CollisionBoxComponentServer - 描述 获取实体的包围盒 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | tuple(float,float) | 包围盒大小 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateCollisionBox(entityId) comp.GetSize() ``` ## GetTypeFamily 服务端 method in mod.server.component.attrCompServer.AttrCompServer - 描述 获取生物行为包字段 type_family - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | list(str) | type_family列表,例['cow', 'mob'] | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateAttr(entityId) comp.GetTypeFamily() ``` ## GetUnitBubbleAirSupply 服务端 method in mod.server.component.breathCompServer.BreathCompServer - 描述 单位气泡数对应的氧气储备值 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | int | 单位气泡数对应的氧气储备值 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateBreath(levelId) comp.GetUnitBubbleAirSupply() ``` ## IsConsumingAirSupply 服务端 method in mod.server.component.breathCompServer.BreathCompServer - 描述 获取生物当前是否在消耗氧气 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否消耗氧气 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateBreath(entityId) comp.IsConsumingAirSupply() ``` ## LockLocalPlayerRot 客户端 method in mod.client.component.rotCompClient.RotComponentClient - 描述 在分离摄像机时,锁定本地玩家的头部角度 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | lock | bool | 传入True为锁定本地玩家头部角度
传入False为解锁本地玩家头部角度 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | True:设置成功
False:设置失败 | - 备注 - 只能设置localplayer,即本地玩家自己 - 玩家重生、切换维度时会重置头部角度 - 锁定本地玩家头部角度时第一人称视角下可以旋转镜头,但玩家头部角度不会发生改变,下次切换到第一人称视角时镜头角度仍为锁定时的角度 - 锁定本地玩家头部角度后,玩家划船时头部角度会尽量靠近锁定时的角度,若无法转到该角度,则会向左或向右看(视哪边距离目标角度更近而定) - 示例 ```python import mod.client.extraClientApi as clientApi # 分离摄像机 comp = clientApi.GetEngineCompFactory().CreateCamera(levelId) comp.DepartCamera() # 锁定本地玩家的头部角度 comp = clientApi.GetEngineCompFactory().CreateRot(entityId) comp.LockLocalPlayerRot(True) ``` ## SetAttrMaxValue 服务端 method in mod.server.component.attrCompServer.AttrCompServer - 描述 设置实体的引擎属性的最大值 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | type | int | [AttrType枚举](../../枚举值/AttrType.md) | | value | float | 属性值 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 备注 - 设置接口暂不支持 ABSORPTION - 在设置属性的时候,需要注意判断是否超过原版的值范围,如果设置的数值超过原版值的范围,则返回False。 - 设置的最大饱和度不能超过当前的饥饿值; 食用食物后,最大饱和度会被原版游戏机制修改 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateAttr(entityId) comp.SetAttrMaxValue(serverApi.GetMinecraftEnum().AttrType.SPEED,0.2) ``` ## SetAttrValue 服务端 method in mod.server.component.attrCompServer.AttrCompServer - 描述 设置实体的引擎属性 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | attrType | int | [AttrType枚举](../../枚举值/AttrType.md) | | value | float | 属性值 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 备注 - 设置接口暂不支持 ABSORPTION - 在设置属性的时候,需要注意判断是否超过原版的值范围或是当前属性的值范围,如果设置的数值超过原版值的范围,则返回False。 - 如果超过当前属性的最大值,则需要先调用SetAttrMaxValue接口来扩充该属性的最大值,否则设置的值过大时会由于超过该属性的最大值而被截取成该最大值。如果设置的值低于当前属性的最小值,则会被设置成原版的最小值。 - 关于基础属性的原版最大值或最小值限制,可查看[AttrType枚举](../../枚举值/AttrType.md) - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateAttr(entityId) # 如果设置的值超过属性当前的最大值,需要先扩充该属性的最大值,否则不生效。 comp.SetAttrMaxValue(serverApi.GetMinecraftEnum().AttrType.HEALTH, 30) comp.SetAttrValue(serverApi.GetMinecraftEnum().AttrType.HEALTH, 30) ``` ## SetCurrentAirSupply 服务端 method in mod.server.component.breathCompServer.BreathCompServer - 描述 设置生物氧气储备值 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | data | int | 设置生物当前氧气值 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 备注 - 注意:该值设置的是当前氧气储备的支持的逻辑帧数 = 氧气储备值 * 逻辑帧数(每秒20帧数) - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateBreath(entityId) comp.SetCurrentAirSupply(300) ``` ## SetEntityLookAtPos 服务端 method in mod.server.component.rotCompServer.RotComponentServer - 描述 设置非玩家的实体看向某个位置 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | targetPos | tuple(float,float,float) | 要看向的目标位置 | | minTime | float | 凝视行为最短维持时间,单位为秒 | | maxTime | float | 凝视行为最长维持时间,单位为秒,最大值为60
实际行为维持时间将在minTime和maxTime之间取随机值 | | reject | bool | 在进行凝视行为时,是否禁止触发其他行为
True为禁止其他行为
False为允许其他行为(此时凝视行为可能表现不明显) | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否设置成功,True为成功,False为失败 | - 备注 - 调用本接口会打断该生物正在进行的行为,且该生物不会立刻看向目标位置,而是逐渐看向目标位置 - 对部分不会转向的实体调用此接口,可能会返回失败或返回成功但实际无表现 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRot(entityId) # 设置该实体看向(0,78,0)这个位置,该凝视行为最少持续2秒,最多持续3秒,凝视过程中禁止触发其他行为 comp.SetEntityLookAtPos((0,78,0), 2, 3, True) ``` ## SetEntityOwner 服务端 method in mod.server.component.actorOwnerCompServer.ActorOwnerComponentServer - 描述 设置实体的属主 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | targetId | str | 属主实体id,为None时设置实体的属主为空 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功,True表示设置成功 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateActorOwner(entityId) result = comp.SetEntityOwner(targetId) ``` ## SetFootPos 服务端 method in mod.server.component.posCompServer.PosComponentServer - 描述 设置实体脚底所在的位置 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | footPos | tuple(float,float,float) | 实体脚所在的位置 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否设置成功 | - 备注 - 行为与使用tp命令一致,实体会瞬移到目标点 - 在床上时调用该接口会返回False - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreatePos(entityId) comp.SetFootPos((0, 4, 0)) ``` ## SetGravity 服务端 method in mod.server.component.gravityCompServer.GravityComponentServer - 描述 设置实体的重力因子,当生物重力因子为0时则应用世界的重力因子 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | gravity | float | 负数,表示每帧向下的速度 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGravity(entityId) comp.SetGravity(-0.08) ``` ## SetMaxAirSupply 服务端 method in mod.server.component.breathCompServer.BreathCompServer - 描述 设置生物最大氧气储备值 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | data | int | 设置生物最大氧气值 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 备注 - 注意:该值设置的是最大氧气储备的支持的逻辑帧数 = 氧气储备值 * 逻辑帧数(每秒20帧数) - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateBreath(entityId) comp.SetMaxAirSupply(400) ``` ## SetName 服务端 method in mod.server.component.nameCompServer.NameComponentServer - 描述 用于设置生物的自定义名称,跟原版命名牌作用相同,玩家和新版流浪商人暂不支持 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | name | str | 名称 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateName(entityId) comp.SetName("new Name") ``` ## SetPersistent 服务端 method in mod.server.component.attrCompServer.AttrCompServer - 描述 设置实体不会因为离玩家太远而被[清除](https://minecraft.fandom.com/zh/wiki/%E7%94%9F%E6%88%90#.E5.9F.BA.E5.B2.A9.E7.89.88_2) - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | persistent | bool | 设置为True时,则实体不会被清除 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否成功 | - 备注 - 使用CreateEngineEntityByTypeStr创建isNpc为True的实体时,默认不会被清除 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateAttr(entityId) comp.SetPersistent(True) ``` ## SetPlayerLookAtPos 客户端 method in mod.client.component.rotCompClient.RotComponentClient - 描述 设置本地玩家看向某个位置 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | targetPos | tuple(float,float,float) | 要看向的目标位置 | | pitchStep | float | 俯仰角方向旋转的角速度(每帧),最小为0.2 | | yawStep | float | 偏航角方向旋转的角速度(每帧),最小为0.2 | | blockInput | bool | 转向目标角度时是否屏蔽玩家操作,默认为True
True:屏蔽玩家操作,此时玩家无法转向、移动
False:不屏蔽玩家操作,此时如果玩家有移动、镜头转向操作将会打断通过本接口设置的转向 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否设置成功,True为成功,False为失败 | - 备注 - 当本地玩家未与摄像机分离时,调用本接口会导致摄像机一同看向指定位置
当本地玩家与摄像机分离时,调用本接口将只改变本地玩家模型的朝向 - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateRot(localPlayerId) # 设置本地玩家以0.2度每帧的俯仰角速度、1度每帧的偏航角速度看向(0,78,0)这个位置,转向过程中屏蔽玩家操作 comp.SetPlayerLookAtPos((0,78,0), 0.2, 1, True) ``` ## SetPos 服务端 method in mod.server.component.posCompServer.PosComponentServer - 描述 设置实体位置 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | pos | tuple(int,int,int) | xyz值 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 备注 - 行为与使用tp命令一致,实体会瞬移到目标点 - 对于所有类型的实体都是设置脚底位置,与[SetFootPos](#setfootpos)等价 - 在床上时调用该接口会返回False - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreatePos(entityId) comp.SetPos((1,2,3)) ``` ## SetRecoverTotalAirSupplyTime 服务端 method in mod.server.component.breathCompServer.BreathCompServer - 描述 设置恢复最大氧气量的时间,单位秒 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | timeSec | float | 恢复生物最大氧气值 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否设置成功 | - 备注 - 注意:当设置的最大氧气值小于(timeSec*10)时,生物每帧恢复氧气量的值为0 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateBreath(entityId) comp.SetRecoverTotalAirSupplyTime(10) ``` ## SetRot 服务端客户端 ### 服务端接口 method in mod.server.component.rotCompServer.RotComponentServer - 描述 设置实体头与水平方向的俯仰角度和竖直方向的旋转角度 MC坐标系说明 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | rot | tuple(float,float) | (上下角度,左右角度)单位是角度而不是弧度 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateRot(entityId) comp.SetRot((30,0)) ``` ### 客户端接口 method in mod.client.component.rotCompClient.RotComponentClient - 描述 设置实体头与水平方向的俯仰角度和竖直方向的旋转角度 MC坐标系说明 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | rot | tuple(float,float) | 俯仰角度及绕竖直方向旋转的角度,单位是角度 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 备注 - 建议只用来设置本地玩家。如果设置其他生物,会被生物自身行为覆盖。 - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateRot(entityId) # 设为向上仰视45度,并朝向世界z轴正方向 comp.SetRot((-45, 0)) ``` ## SetSize 服务端 method in mod.server.component.collisionBoxCompServer.CollisionBoxComponentServer - 描述 设置实体的包围盒 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | size | tuple(float,float) | 第一位表示宽度和长度,第二位表示高度 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 备注 - 对新生产的实体需要经过5帧之后再设置包围盒的大小才会生效 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateCollisionBox(entityId) comp.SetSize((2,3)) ``` ## isEntityInLava 客户端 method in mod.client.component.attrCompClient.AttrCompClient - 描述 实体是否在岩浆中 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否在岩浆中,True为在岩浆中,False为不在岩浆中 | - 备注 - 只能获取到本地客户端已加载的实体是否在岩浆中,若实体在其他维度或未加载(距离本地玩家太远),将获取失败 - 示例 ```python comp = clientApi.GetEngineCompFactory().CreateAttr(entityId) isInLava = comp.isEntityInLava() ``` ## isEntityOnGround 客户端 method in mod.client.component.attrCompClient.AttrCompClient - 描述 实体是否触地 - 参数 无 - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否触地,True为触地,False为不触地 | - 备注 - 客户端实体刚创建时引擎计算还没完成,此时获取该实体是否着地将返回默认值True,需要延迟一帧进行获取才能获取到正确的数据 - 生物处于骑乘状态时,如玩家骑在猪身上,也视作触地 - 只能获取到本地客户端已加载的实体是否触地,若实体在其他维度或未加载(距离本地玩家太远),将获取失败 - 示例 ```python comp = clientApi.GetEngineCompFactory().CreateAttr(entityId) isOnGound = comp.isEntityOnGround() ```