行为
AddPlayerAroundEntityMotion
服务端开发补充
为玩家添加围绕实体运动的运动器。
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
给玩家添加对实体环绕运动器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| eID | str | 要环绕的某个实体的ID |
| angularVelocity | float | 圆周运动的角速度(弧度/秒) |
| axis | tuple(float,float,float) | 圆周运动的轴,决定了在哪个平面上做圆周运动,默认为(0, 1, 0) |
| lockDir | bool | 是否在运动器生效时锁定实体的朝向,不锁定则实体的朝向会随着运动而改变,默认为False。 |
| stopRad | float | 停止该运动器所需要的弧度,当stopRad为0时,该运动器会一直运行,默认为0 |
| radius | float | 环绕半径,当设置为-1时环绕运动器使用当前与目标的距离作为半径,当设置为非负数时表示按设定的值作为环绕半径,默认为-1 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 运动器ID,添加失败时返回-1 |
备注
该接口会在客户端和服务端同步进行,使用前请确保环绕的对象在客户端和服务端都已创建。
该接口不屏蔽玩家控制的移动以及重力作用,当有玩家控制发生时,最终的表现结果可能与预期有差异。由于玩家的头部与相机控制相关,若需要使运动器控制玩家的头部,请使用DepartCamera分离玩家与摄像机。
环绕运动器可叠加多个,且可与速度运动器互相叠加,每一帧的最终效果为各个运动器计算出的瞬时向量之和。
由于引擎中有加载的区块限制以及客户端对实体管理进行了优化,建议将玩家与目标之间的半径控制在30以内。
示例
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
axis=(-1, 1, 1)
mID = motionComp.AddPlayerAroundEntityMotion(eID, 1.0, axis, lockDir=False, stopRad=0, radius=2.0)
#启动该运动器
motionComp.StartPlayerMotion(mID)AddPlayerAroundPointMotion
服务端开发补充
为玩家添加围绕指定位置运动的运动器。
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
给玩家添加对点环绕运动器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| center | tuple(float,float,float) | 要环绕的圆心点坐标 |
| angularVelocity | float | 圆周运动的角速度(弧度/秒) |
| axis | tuple(float,float,float) | 圆周运动的轴,决定了在哪个平面上做圆周运动,默认为(0, 1, 0) |
| lockDir | bool | 是否在运动器生效时锁定实体的朝向,不锁定则玩家的朝向会随着运动而改变,默认为False。 |
| stopRad | float | 停止该运动器所需要的弧度,当stopRad为0时,该运动器会一直运行,默认为0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 运动器ID,添加失败时返回-1 |
备注
该接口不屏蔽玩家控制的移动以及重力作用,当有玩家控制发生时,最终的表现结果可能与预期有差异。由于玩家的头部与相机控制相关,若需要使运动器控制玩家的头部,请使用DepartCamera分离玩家与摄像机。
环绕运动器可叠加多个,且可与速度运动器互相叠加,每一帧的最终效果为各个运动器计算出的瞬时向量之和。
由于引擎中有加载的区块限制,建议将玩家的运动范围控制在当前位置±100内。
示例
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
center = (0, 8, 0)
axis=(-1, 1, 1)
mID = motionComp.AddPlayerAroundPointMotion(center, 1.0, axis, lockDir=False, stopRad=0)
#启动该运动器
motionComp.StartPlayerMotion(mID)AddPlayerTrackMotion
服务端开发补充
为玩家添加轨迹运动器。
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
给玩家添加轨迹运动器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| targetPos | tuple(float,float,float) | 轨迹终点 |
| duraTime | float | 到达终点所需要的时间 |
| startPos | tuple(float,float,float) | 轨迹起点,默认为None,表示以调用StartPlayerMotion的位置作为起点。 |
| relativeCoord | bool | 是否使用相对坐标设置起点和终点的位置以及朝向,默认为False。 |
| isLoop | bool | 是否循环,若设为True,则玩家会在起点和终点之间往复运动,默认为False。 |
| targetRot | tuple(float,float) | 玩家到达targetPos时的朝向,受参数relativeCoord影响,默认为None,表示使用调用StartPlayerMotion时的朝向。 |
| startRot | tuple(float,float) | 玩家到达startPos时的朝向,受参数relativeCoord影响,默认为None,表示使用调用StartPlayerMotion时的朝向。 |
| useVelocityDir | bool | 是否使用运动中的速度方向作为朝向,默认为False,若为True,则参数targetRot和startRot无效 |
| ease | TimeEaseType | 时间变化函数, 默认值为serverApi.GetMinecraftEnum().TimeEaseType.linear, 参数不在枚举值中也当作linear |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 运动器ID,添加失败时返回-1 |
备注
该接口不屏蔽玩家控制的移动,当有玩家控制发生时,最终的表现结果可能与预期有差异。由于玩家的头部与相机控制相关,若需要使运动器控制玩家的头部,请使用DepartCamera分离玩家与摄像机。
轨迹运动器不可叠加,仅能添加一个。
设置朝向后会根据相应的参数计算出最终朝向,若此时的targetRot > startRot,则会顺时针旋转,反之逆时针旋转。
示例
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
target = (5, 0, 0)
rot1 = (0, 0)
rot2 = (0, 360)
mID = motionComp.AddPlayerTrackMotion(target, 3.0, startPos=None, relativeCoord=True, isLoop=False, targetRot=rot1, startRot=rot2, useVelocityDir=True, ease = serverApi.GetMinecraftEnum().TimeEaseType.linear)
#启动该运动器
motionComp.StartPlayerMotion(mID)AddPlayerVelocityMotion
服务端开发补充
为玩家添加按速度运动的运动器。
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
给玩家添加速度运动器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| velocity | tuple(float,float,float) | 速度,包含大小、方向 |
| accelerate | tuple(float,float,float) | 加速度,包含大小、方向,默认为None,表示没有加速度 |
| useVelocityDir | bool | 是否使用当前速度的方向作为此刻实体的朝向,默认为True |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 运动器ID,添加失败时返回-1 |
备注
该接口不屏蔽玩家控制的移动以及重力作用,当有玩家控制发生时,最终的表现结果可能与预期有差异。由于玩家的头部与相机控制相关,若需要使运动器控制玩家的头部,请使用DepartCamera分离玩家与摄像机。
速度运动器可叠加多个,且可与环绕运动器互相叠加。
由于引擎中有加载的区块限制,建议将玩家的运动范围控制在当前位置±100内。
示例
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
velocity = (0, 0, 1)
accelerate = (0, 0, -1)
mID = motionComp.AddPlayerVelocityMotion(velocity, accelerate, useVelocityDir=True)
#启动该运动器
motionComp.StartPlayerMotion(mID)BeginSprinting
客户端开发补充
让本地玩家进入并保持向前疾跑状态。
客户端
method in mod.client.component.actorMotionCompClient.ActorMotionComponentClient
- 描述
使本地玩家进入并保持向前疾跑/冲刺状态
- 参数
无
- 返回值
无
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorMotion(localPlayerId)
comp.BeginSprinting()ChangePlayerDimension
服务端开发补充
能力:维度 · 玩家 · 位置 · 实体传送
作用对象:玩家
将玩家传送到目标维度的指定位置;位置需按接口要求的头部坐标基准传入。
- 成功切换维度时玩家脚底比传入位置低 1.62,不应直接复用脚底传送坐标。
- 此接口成功切维度时 pos 是玩家头部位置,脚底会比给定位置低 1.62;与同维度脚底传送的坐标基准不同。
关联接口:SetPos (server) · GetFootPos (server) · SetFootPos (server) · ChangeEntityDimension (server)
服务端
method in mod.server.component.dimensionCompServer.DimensionCompServer
- 描述
传送玩家
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| dimensionId | int | 维度,0-overWorld; 1-nether; 2-theEnd |
| pos | tuple(int,int,int) | 传送的坐标 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
备注
该接口在成功切换维度时pos位置为玩家头的位置,即比设定位置低1.62
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateDimension(playerId)
comp.ChangePlayerDimension(0, (0,4,0))ChangePlayerFlyState
服务端开发补充
设置玩家飞行能力,并分别控制是否进入飞行状态。
- 拥有飞行能力时不受摔落伤害;允许飞行与正在飞行是不同状态。
- 从客户端落地事件通知服务端后调用时,原文建议延后一帧处理。
关联接口:IsPlayerCanFly (server) · IsPlayerFlying (server) · AddTimer (server)
服务端
method in mod.server.component.flyCompServer.FlyComponentServer
- 描述
给予/取消飞行能力, 并根据enterFly参数确定是否进入飞行状态
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| isFly | bool | 给予/取消飞行能力 |
| enterFly | bool | 是否进入飞行状态,当isFly为true时,该参数才有效,其他情况下均为false |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | True:是 False:否;是否设置成功 |
备注
不建议在OnGroundClientEvent事件回调中NotifyToServer,然后服务端收到数据后,调用ChangePlayerFlyState接口。 如果仍然需要这样调用,则建议在服务端收到数据后,用AddTimer延迟一帧后再调用ChangePlayerFlyState接口
拥有飞行能力时,不会受到摔落伤害
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFly(playerId)
comp.ChangePlayerFlyState(True) # 给予飞行能力,并进入飞行状态
# comp.ChangePlayerFlyState(True, False)# 给予飞行能力,不进入飞行状态
# comp.ChangePlayerFlyState(False)# 取消飞行能力EnableKeepInventory
服务端开发补充
能力:死亡 · 死亡掉落 · 玩家
作用对象:玩家
控制玩家死亡后是否保留物品。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家死亡不掉落物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| enable | bool | True:不掉落,False:掉落 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
备注
只有全局的“保留物品栏”规则关闭时,才会使用该设置控制玩家是否掉落。如果全局的“保留物品栏”规则是开启的,那么所有玩家死亡时都不会掉落。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
succ = comp.EnableKeepInventory(True)EndSprinting
客户端开发补充
结束本地玩家向前疾跑状态。
客户端
method in mod.client.component.actorMotionCompClient.ActorMotionComponentClient
- 描述
使本地玩家结束向前疾跑/冲刺状态
- 参数
无
- 返回值
无
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorMotion(localPlayerId)
comp.EndSprinting()GetEntityRider
服务端开发补充
读取骑乘者当前所乘坐的实体标识。
客户端开发补充
读取骑乘者当前所乘坐的实体标识。
服务端客户端
服务端接口
method in mod.server.component.rideCompServer.RideCompServer
- 描述
获取骑乘者正在骑乘的实体的id。
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 骑乘者直接骑乘对象的实体id,假如骑乘者没有骑乘则返回“-1” |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateRide(entityId)
riderId = comp.GetEntityRider()客户端接口
method in mod.client.component.rideCompClient.RideCompClient
- 描述
获取骑乘者正在骑乘的实体的id。
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| str | 骑乘者直接骑乘对象的实体id,假如该骑乘者没有骑乘则返回“-1” |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateRide(entityId)
riderId = comp.GetEntityRider()GetInteracteCenterOffset
服务端开发补充
读取玩家服务端交互中心偏移。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家服务端交互中心的偏移,对应使用SetPickCenterOffset修改的偏移值
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float) | 偏移量 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetInteracteCenterOffset()GetIsBlocking
服务端开发补充
查询玩家是否激活盾牌格挡。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家激活盾牌状态
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 玩家盾牌状态是否激活 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetIsBlocking()GetPickCenterOffset
客户端开发补充
读取客户端第三人称交互中心偏移。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
获取玩家设置的第三人称下客户端交互中心的偏移
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| tuple(float,float,float) | 偏移量 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetPickCenterOffset()GetPickRange
客户端开发补充
读取客户端玩家交互距离。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
获取玩家客户端的交互距离
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 交互范围 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetPickRange()GetPlayerDestroyTotalTime
服务端开发补充
能力:破坏 · 破坏时间 · 主手物品 · 玩家
读取综合玩家状态、手持工具及附魔后的方块破坏耗时。
客户端开发补充
读取综合玩家状态、手持工具及附魔后的方块破坏耗时。
服务端客户端
服务端接口
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家破坏方块需要的时间,受玩家状态(急迫、潮涌、挖掘疲劳)和手持物及手持物附魔(效率)影响
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| blockName | str | 方块标识符,格式[namespace:name:auxvalue],auxvalue默认为0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 需要消耗的时间 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetPlayerDestroyTotalTime("minecraft:diamond_block")客户端接口
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
获取玩家破坏方块需要的时间,受玩家状态(急迫、潮涌、挖掘疲劳)和手持物及手持物附魔(效率)影响
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| blockName | str | 方块标识符,格式[namespace:name:auxvalue],auxvalue默认为0 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 需要消耗的时间 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetPlayerDestroyTotalTime("minecraft:diamond_block")GetPlayerExhaustionRatioByType
服务端开发补充
按行为类型读取玩家饥饿消耗倍率。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家某行为饥饿度消耗倍率
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| type | int | 行为枚举PlayerExhauseRatioType枚举 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 饥饿度消耗倍率值, -1为获取失败(例如在创造模式下) |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
jumpType = serverApi.GetMinecraftEnum().PlayerExhauseRatioType.JUMP
ratio = comp.GetPlayerExhaustionRatioByType(jumpType)GetPlayerInteracteRange
服务端开发补充
读取服务端玩家交互距离。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家服务端的交互距离
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| float | 交互半径 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetPlayerInteracteRange()GetPlayerIsFishing
服务端开发补充
判断玩家是否处于钓鱼状态。
客户端开发补充
判断玩家是否处于钓鱼状态。
服务端客户端
服务端接口
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家是否在钓鱼
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 在钓鱼时为True,没在钓鱼时为False |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
isFishing = comp.GetPlayerIsFishing()客户端接口
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
获取玩家是否在钓鱼
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 在钓鱼时为True,没在钓鱼时为False |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreatePlayer(playerId)
isFishing = comp.GetPlayerIsFishing()GetPlayerMotions
服务端开发补充
列出玩家当前已有的运动器。
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
获取玩家身上的所有运动器
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 运动器集合,key值代表运动器mID,value值代表运动器类型0:轨迹运动器、1:速度运动器、2:环绕运动器 |
备注
运动器非人为停止后会被移除。
示例
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
motions = motionComp.GetPlayerMotions()
# motions = {
# 0:1,
# 1:2
# }GetPlayerRespawnPos
服务端开发补充
读取玩家复活点。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家复活点
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| dict | 复活点信息,包括维度和坐标 |
备注
使用spawnpoint指令设置玩家的出生点后,该接口可以获取到设置后的出生点
未使用setworldspawn指令设置过出生点位置时,返回坐标的y轴是32767
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
print comp.GetPlayerRespawnPos()
#结果示例 {'dimensionId': 0, 'pos': (44, 32767, 4)}GetRelevantPlayer
服务端开发补充
查询附近玩家标识列表;适用环境以原文为准。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取附近玩家id列表
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| exceptList | list(str) | 排除的玩家id列表,默认值为None,不排除其他玩家及自身 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| list(str) | 附近玩家id列表 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetRelevantPlayer(exceptId)IsEntityRiding
服务端开发补充
判断玩家是否正在骑乘。
服务端
method in mod.server.component.rideCompServer.RideCompServer
- 描述
检查玩家是否骑乘。
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否骑乘 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateRide(entityId)
isRiding = comp.IsEntityRiding()IsInScaffolding
客户端开发补充
判断玩家是否处于脚手架中。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
获取玩家是否在脚手架中
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否在脚手架中 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.IsInScaffolding()IsOnLadder
客户端开发补充
判断玩家是否位于梯子或藤蔓上。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
获取玩家是否在梯子/藤蔓上
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否在梯子/藤蔓上 |
- 示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.IsOnLadder()IsPlayerCanFly
服务端开发补充
查询玩家是否具有飞行能力,不改变该能力。
- 能飞不等于当前正在飞;只查询,不改变飞行能力。
关联接口:ChangePlayerFlyState (server) · IsPlayerFlying (server)
服务端
method in mod.server.component.flyCompServer.FlyComponentServer
- 描述
获取玩家能否飞行
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | True:是 False:否 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFly(playerId)
comp.IsPlayerCanFly()IsPlayerFlying
服务端开发补充
查询玩家当前是否处于飞行状态,不改变飞行能力或状态。
- 正在飞行与拥有飞行能力不同;本接口不授予飞行能力。
关联接口:IsPlayerCanFly (server) · ChangePlayerFlyState (server)
服务端
method in mod.server.component.flyCompServer.FlyComponentServer
- 描述
获取玩家是否在飞行
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | True:是 False:否 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFly(playerId)
comp.IsPlayerFlying()OpenNeteaseContainer
服务端开发补充
打开不依赖方块的自定义容器界面;物品数据由调用方维护。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
打开自定义容器界面,不依赖于方块。该界面的物品数据需由开发者自行维护。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| screenName | str | 打开的容器ui的命名空间,格式[namespace.screenName] |
| customDescription | str | 打开的容器ui的标题(复用原版ui时生效) |
| isCloseReturnItem | bool | 关闭容器界面时,是否返还物品到背包;默认为False(不返还),由开发者维护物品数据的存储。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 返回True则执行成功,不代表界面已打开 |
备注
参数含义以及自定义容器ui json的编写,参考 自定义容器 教程。
collection_name需指定为
netease_ui_container。如果isCloseReturnItem为False,将在关闭界面后,
容器内的物品不会返还到背包。可使用GetPlayerUIItem、SetPlayerUIItem接口来获取、设置容器内的物品。
该接口打开的容器,可触发PlayerTryAddCustomContainerItemServerEvent、PlayerTryPutCustomContainerItemServerEvent、PlayerTryRemoveCustomContainerItemServerEvent以及对应的客户端事件。
可通过监听PushScreenEvent,来做容器内格子物品的初始化逻辑;建议每一个ui namespace单独对应一种功能,以免无法正确区分容器界面。
如出现“failed to create root control”等断言,请检查ui json的编写是否正确。
如出现物品无法放入容器界面、或者无法移动物品,请检查ui json的是否使用了netease_ui_container。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.OpenNeteaseContainer("netease_container.netease_custom_container_screen", "容器标题")OpenWorkBench
服务端开发补充
在玩家位置打开工作台界面,不要求放置工作台方块。
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
在玩家当前位置打开工作台UI,不依赖于工作台方块
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 打开结果 |
备注
工作台有交互距离要求,太远了(与打开位置超过5格以上)打开工作台UI后会自动关闭
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId) # 此处playerId为使用物品的玩家
comp.OpenWorkBench()PickUpItemEntity
服务端开发补充
让指定玩家拾取物品实体。
服务端
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
某个Player拾取物品ItemEntity
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| playerEntityId | str | 拾取者的playerEntityId |
| itemEntityId | str | 要拾取的物品itemEntityId |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否拾取成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateGame(levelId)
comp.PickUpItemEntity(playerEntityId, itemEntityId)PlayerAttackEntity
服务端开发补充
能力:攻击 · 主手物品 · 玩家
让玩家使用手持武器攻击目标实体。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
玩家使用手持武器攻击某个生物
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物entityId |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 执行结果 |
备注
1.会触发PlayerAttackEntityEvent事件,并且可以被这个事件cancel
2.此接口无视距离,但无法跨维度使用,同时需要目标区域已加载
3.常加载区块的生物也不会执行tick,生物受伤cd不会减少,无法对生物多次造成伤害,通过SetHurtCD接口设置伤害间隔为0,可以解决这个问题
4.此接口不会播放原版攻击动作,可以使用Swing接口来播放原版攻击动作
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId) # 此处playerId为发起攻击的玩家
suc = comp.PlayerAttackEntity("-123456")PlayerDestroyBlock
服务端开发补充
能力:方块 · 破坏 · 耐久度 · 主手物品 · 玩家
让玩家使用手持工具破坏方块。
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
使用手上工具破坏方块
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pos | tuple(int,int,int) | 方块位置 |
| particle | int | 是否开启破坏粒子效果,默认为开 |
| sendInv | bool | 是否同步服务端背包信息,默认为不同步。因为破坏方块可能会造成手持物品耐久度降低等信息改变,不同步信息可能会造成后续一些逻辑异常,若大批量破坏方块,每次同步会有性能问题,建议前面的调用可令sendInv为False,在最后一次调用此函数时传入sendInv为True。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
备注
手上工具的附魔效果会生效,同时扣除耐久度
会触发ServerPlayerTryDestroyBlockEvent事件,并且可以被这个事件cancel
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId) # 此处playerId为block的破坏者
comp.PlayerDestroyBlock((0, 5, 0), 1, False)
comp.PlayerDestroyBlock((0, 6, 0), 1, True)
# 关闭破坏粒子效果
comp.PlayerDestroyBlock((0, 6, 0),0)PlayerUseItemToEntity
服务端开发补充
让玩家向目标实体使用手持物品。
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
玩家使用手上物品对某个生物使用
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| entityId | str | 生物entityId |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
备注
1.会触发PlayerInteractServerEvent事件,并且可以被这个事件cancel
2.使用PlayerUseItemToEntity接口模拟玩家用命名牌重命名生物、用食物喂养生物时,可以触发PlayerNamedEntityServerEvent、PlayerFeedEntityServerEvent事件,并且这两个事件都可以cancel
3.此接口无视距离,但无法跨维度使用,同时需要目标区域已加载
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId) # 此处playerId为使用物品的玩家
suc = comp.PlayerUseItemToEntity("-123456")PlayerUseItemToPos
服务端开发补充
模拟玩家向指定坐标使用物品。
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
模拟玩家对某个坐标使用物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pos | tuple(int,int,int) | 坐标 |
| posType | int | 物品所在的地方ItemPosType枚举 |
| slotPos | int | 槽位,获取INVENTORY及ARMOR时需要设置,其他情况写0即可 |
| facing | int | 朝向,详见Facing枚举 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置结果 |
备注
当使用抛射物时,只有在非创造模式下才会返回True;如果要对"盔甲架"等实体使用物品,请使用PlayerUseItemToEntity接口;只能对玩家周边200格以内的坐标使用
模拟玩家使用物品时,最终效果和右键使用物品类似,会先触发方块交互,再触发物品使用。因此,该接口同时也可用作方块交互目的
使用api放置容器类方块(如箱子)后,立刻调用PlayerUseItemToPos尝试打开箱子,会因为当前客户端还没有这个方块而无法打开,同时导致服务端与客户端状态不同步,后续也无法打开其他容器与玩家背包。为防止此问题,请确保客户端获取到对应坐标是箱子,再调用服务端PlayerUseItemToPos。
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId) # 此处playerId为使用物品的玩家
comp.PlayerUseItemToPos((0, 5, 0), serverApi.GetMinecraftEnum().ItemPosType.INVENTORY, 0, 1)RemovePlayerMotion
服务端开发补充
移除玩家上的指定运动器。
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
移除玩家身上的运动器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| motionId | int | 要移除的某个运动器的ID |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功移除 |
- 示例
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
motionComp.RemovePlayerMotion(mID)SetBanPlayerFishing
服务端开发补充
能力:钓鱼权限 · 玩家
作用对象:玩家
适用限定:钓鱼权限
控制玩家能否钓起物品;禁止后仍可甩出鱼竿。
- 只控制是否允许钓起物品,不执行抛竿或收杆。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置是否屏蔽玩家钓鱼功能,屏蔽后玩家可以正常抛甩鱼竿,但无法钓起任何物品
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| isBan | bool | 是否屏蔽玩家钓鱼功能,True为屏蔽,False为取消屏蔽 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetBanPlayerFishing(True)SetInteracteCenterOffset
服务端开发补充
设置玩家服务端交互中心偏移。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家服务端交互中心的偏移
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| offset | tuple(float,float,float) | 偏移量 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
备注
该接口只修改服务端的交互中心,所以需要使用SetCameraAnchor修改客户端第一人称的交互中心,使用SetPickCenterOffset修改客户端第三人称的交互中心,否则客户端将无法选中方块,即无法发送正确的信息给服务端
注:当前客户端能修改交互中心的有SetCameraAnchor修改第一人称,SetPickCenterOffset修改第三人称。服务端能使用SetInteracteCenterOffset修改玩家交互中心(服务端无第几人称概念)
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetInteracteCenterOffset(offset)SetPickCenterOffset
客户端开发补充
设置客户端第三人称交互中心偏移。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
设置第三人称下,玩家客户端交互中心的偏移
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| offset | tuple(float,float,float) | 偏移量 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
备注
该接口只修改第三人称,第一人称下需要使用SetCameraAnchor接口设置交互中心。
该接口只修改客户端的交互中心,选中后客户端会将选中的消息发给服务端,所以需要使用SetInteracteCenterOffset修改服务端的的玩家交互中心,否则超出服务端允许的玩家可交互范围将被撤销。
注:当前客户端能修改交互中心的有SetCameraAnchor修改第一人称,SetPickCenterOffset修改第三人称。服务端能使用SetInteracteCenterOffset修改玩家交互中心(服务端无第几人称概念)
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPickCenterOffset(offset)SetPickRange
客户端开发补充
设置客户端玩家交互距离。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
设置玩家客户端的交互距离
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pickRange | float | 交互半径 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
备注
该接口只修改客户端的交互距离,选中后客户端会将选中的消息发给服务端,所以需要使用SetPlayerInteracteRange修改服务端玩家的交互距离,否则超出服务端允许的玩家可交互范围将被撤销。
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPickRange(pickRange)SetPickUpArea
服务端开发补充
在原版拾取范围基础上调整玩家的物品拾取范围。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家的拾取物品范围,设置后该玩家的拾取物品范围会在原版拾取范围的基础上进行改变。
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| area | tuple(float,float,float) | 拾取物品范围,传入(0, 0, 0)时视作取消设置 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
# 玩家拾取物品范围在X轴正负方向各增加5格,在Z轴正负方向各增加3格,在Y轴保持不变
succ = comp.SetPickUpArea((5, 0, 3))SetPlayerAttackSpeedAmplifier
服务端开发补充
调整攻击速度倍率并影响全局受击间隔;大于一表示减速,小于一表示加速。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家攻击速度倍数,1.0表示正常水平,1.2表示速度减益20%,0.8表示速度增益20%
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| amplifier | float | 攻击速度倍数,范围[0.5,2.0] |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
备注
该接口影响接口SetHurtCD设置的全局受击间隔CD
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPlayerAttackSpeedAmplifier(1.1)SetPlayerExhaustionRatioByType
服务端开发补充
按行为类型修改玩家饥饿消耗倍率。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家某行为饥饿度消耗倍率
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| type | int | 行为枚举PlayerExhauseRatioType枚举 |
| ratio | float | 倍率 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
jumpType = serverApi.GetMinecraftEnum().PlayerExhauseRatioType.JUMP
ratio = comp.SetPlayerExhaustionRatioByType(jumpType, 20)SetPlayerInteracteRange
服务端开发补充
设置服务端玩家交互距离。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家服务端的交互距离
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| interacteRange | float | 交互半径 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPlayerInteracteRange(interacteRange)SetPlayerJumpable
服务端开发补充
控制玩家是否可以跳跃。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家是否可跳跃
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| isJumpable | bool | 是否可跳跃,True允许跳跃,False禁止跳跃 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPlayerJumpable(False)SetPlayerMotion
服务端开发补充
能力:玩家 · 运动速度
在服务端设置玩家瞬时运动向量;伤害事件中使用自定义击退时需关闭原事件击退。
- 本接口针对玩家,非玩家生物另查 SetMotion;不要把速度运动器当成同一个瞬时操作。
- 面向玩家使用此接口;SetMotion 面向非玩家生物,不能因名称类似而替换。
关联接口:GetMotion (server) · SetMotion (server) · DamageEvent (server)
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
设置玩家的瞬时移动方向向量(可解决SetMotion闪现问题)
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| motion | tuple(float,float,float) | 世界坐标系下的向量,该方向为世界坐标系下的向量,以x,z,y三个轴的正方向为正值,可以通过当前生物的rot组件判断目前玩家面向的方向,可在开发模式下打开F3观察数值变化。 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
备注
在damageEvent事件里面使用该接口时,需把damageEvent事件回调的knock参数设置为False
SetMotion接口需要客户端服务端双端调用,但受限于网速、延迟等,会出现闪现情况,此接口可完美解决上述问题
示例
import mod.server.extraServerApi as serverApi
# 使生物向准星的方向突进一段距离
rotComp = serverApi.GetEngineCompFactory().CreateRot(entityId)
rot = rotComp.GetRot()
x, y, z = serverApi.GetDirFromRot(rot)
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(entityId)
motionComp.SetPlayerMotion((x * 5, y * 5, z * 5))
# rot 和 世界坐标系关系
# ^ x -90°
# |
# 180°/-180 ----------> z 0°
# | 90°SetPlayerMovable
服务端开发补充
控制玩家是否可以移动。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家是否可移动
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| isMovable | bool | 是否可移动,True允许移动,False禁止移动 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
备注
注:该接口“不可移动”指不能移动、跳跃、飞行、潜行,并且飞行状态下也不能上升下降
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPlayerMovable(False)SetPlayerRespawnPos
服务端开发补充
设置玩家复活时的位置和维度。
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家复活的位置与维度
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| pos | tuple(int,int,int) | 复活点的位置坐标 |
| dimensionId | int | 复活点的维度,默认值为0(主世界),注意1:维度21是不可用的;注意2:不能在玩家死亡(PlayerDieEvent)之后设置复活点 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否设置成功 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
suc = comp.SetPlayerRespawnPos((0, 4, 0), 0)StartPlayerMotion
服务端开发补充
启动玩家已有的指定运动器。
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
启动玩家身上的某个运动器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| motionId | int | 要启动的某个运动器的ID |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功启动 |
备注
运动器控制的玩家会无视原生的碰撞逻辑而穿透方块,若需停止,请自行监听碰撞事件OnPlayerHitBlockServerEvent然后使用StopPlayerMotion停止
由于玩家的运动器需要在客户端与服务端之间同步,所以请以EntityMotionStartServerEvent事件的触发作为真正的开始时机。
示例
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
motionComp.StartPlayerMotion(mID)StopPlayerMotion
服务端开发补充
停止玩家已有的指定运动器。
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
停止玩家身上的某个运动器
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| motionId | int | 要停止的某个运动器的ID |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否成功停止 |
备注
调用该接口不会触发事件EntityMotionStopServerEvent。
示例
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
motionComp.StopPlayerMotion(mID)isGliding
客户端开发补充
判断玩家是否处于鞘翅滑翔状态。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否鞘翅飞行
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否鞘翅飞行 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isGliding()isInWater
客户端开发补充
判断玩家是否位于水中。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否在水中
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否在水中 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isInWater()isMoving
客户端开发补充
判断玩家是否正在行走。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否在行走
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否在行走 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isMoving()isRiding
客户端开发补充
读取客户端玩家骑乘状态。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否骑乘
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否骑乘 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isRiding()isSneaking
服务端开发补充
能力:玩家 · 潜行 · 状态数据
判断玩家是否处于潜行状态。
客户端开发补充
能力:玩家 · 潜行 · 状态数据
判断玩家是否处于潜行状态。
服务端客户端
服务端接口
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家是否处于潜行状态
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 当前玩家是否处于潜行状态 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
is_sneaking = comp.isSneaking()客户端接口
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否潜行
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否潜行 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isSneaking()isSprinting
客户端开发补充
判断玩家是否正在疾跑。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否在疾跑
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否在疾跑 |
备注
注意,只有当玩家在疾跑时,该接口才返回true,静止状态下,返回false
示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isSprinting()isSwimming
服务端开发补充
判断玩家是否处于游泳状态。
客户端开发补充
判断玩家是否处于游泳状态。
服务端客户端
服务端接口
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家是否处于游泳状态。
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 当前玩家是否处于游泳状态 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
is_swiming = comp.isSwimming()客户端接口
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否游泳
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 是否游泳 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isSwimming()setMoving
客户端开发补充
设置本地玩家行走状态,仅适用于移动端。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
设置是否行走,只能设置本地玩家(只适用于移动端)
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.setMoving()setSneaking
客户端开发补充
设置本地玩家潜行状态,仅适用于移动端。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
设置是否潜行,只能设置本地玩家(只适用于移动端)
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.setSneaking()setSprinting
客户端开发补充
设置本地玩家的疾跑行走模式,仅适用于移动端。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
设置行走模式为疾跑/冲刺,只能设置本地玩家(只适用于移动端)
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 设置是否成功 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.setSprinting()setUsingShield
客户端开发补充
激活本地玩家的盾牌状态。
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
激活盾牌状态
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| flag | bool | True使用盾牌,False取消使用盾牌 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 1设置成功,0设置失败,-1玩家未持盾 |
- 示例
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.setUsingShield(True)