---
sidebarDepth: 1
---
# 行为
## 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 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| int | 运动器ID,添加失败时返回-1 |
- 备注
- 该接口不屏蔽玩家控制的移动以及重力作用,当有玩家控制发生时,最终的表现结果可能与预期有差异。由于玩家的头部与相机控制相关,若需要使运动器控制玩家的头部,请使用[DepartCamera](./摄像机.md#DepartCamera)分离玩家与摄像机。
- 环绕运动器可叠加多个,且可与速度运动器互相叠加。
- 由于引擎中有加载的区块限制,建议将玩家的运动范围控制在当前位置±100内。
- 示例
```python
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)
```
## 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](./摄像机.md#DepartCamera)分离玩家与摄像机。
- 环绕运动器可叠加多个,且可与速度运动器互相叠加。
- 由于引擎中有加载的区块限制,建议将玩家的运动范围控制在当前位置±100内。
- 示例
```python
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)
```
## AddPlayerTrackMotion
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
给玩家添加轨迹运动器
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| targetPos | tuple(float,float,float) | 轨迹终点 |
| duraTime | float | 到达终点所需要的时间 |
| startPos | tuple(float,float,float) | 轨迹起点,默认为None,表示以调用[StartPlayerMotion](#StartPlayerMotion)的位置作为起点。 |
| relativeCoord | bool | 是否使用相对坐标设置起点和终点,默认为False。 |
| isLoop | bool | 是否循环,若设为True,则玩家会在起点和终点之间往复运动。 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| int | 运动器ID,添加失败时返回-1 |
- 备注
- 该接口不屏蔽玩家控制的移动,当有玩家控制发生时,最终的表现结果可能与预期有差异。
- 轨迹运动器不可叠加,仅能添加一个。
- 示例
```python
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
target = (5, 0, 0)
mID = motionComp.AddPlayerTrackMotion(target, 3.0, startPos=None, relativeCoord=True, isLoop=False)
```
## 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](./摄像机.md#DepartCamera)分离玩家与摄像机。
- 速度运动器可叠加多个,且可与环绕运动器互相叠加。
- 由于引擎中有加载的区块限制,建议将玩家的运动范围控制在当前位置±100内。
- 示例
```python
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)
```
## BeginSprinting
客户端
method in mod.client.component.actorMotionCompClient.ActorMotionComponentClient
- 描述
使本地玩家进入并保持向前冲刺状态
- 参数
无
- 返回值
无
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorMotion(localPlayerId)
comp.BeginSprinting()
```
## ChangePlayerDimension
服务端
method in mod.server.component.dimensionCompServer.DimensionCompServer
- 描述
传送玩家
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| dimensionId | int | 维度,0-overWorld; 1-nether; 2-theEnd |
| pos | tuple(int,int,int) | 传送的坐标 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 备注
- 该接口在成功切换维度时pos位置为玩家头的位置,即比设定位置低1.62
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateDimension(playerId)
comp.ChangePlayerDimension(0, (0,4,0))
```
## ChangePlayerFlyState
服务端
method in mod.server.component.flyCompServer.FlyComponentServer
- 描述
给予/取消飞行能力,并且进入飞行/非飞行状态
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| isFly | bool | 飞行状态,True:飞行模式,False:正常行走模式 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | True:是 False:否 |
- 备注
- 不建议在OnGroundClientEvent事件回调中NotifyToServer,然后服务端收到数据后,调用ChangePlayerFlyState接口。
如果仍然需要这样调用,则建议在服务端收到数据后,用AddTimer延迟一帧后再调用ChangePlayerFlyState接口
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFly(playerId)
comp.ChangePlayerFlyState(True)
```
## EnableKeepInventory
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家死亡不掉落物品
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| enable | bool | 是否开启“保留物品栏” |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
succ = comp.EnableKeepInventory(True)
```
## EndSprinting
客户端
method in mod.client.component.actorMotionCompClient.ActorMotionComponentClient
- 描述
使本地玩家结束向前冲刺状态
- 参数
无
- 返回值
无
- 示例
```python
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” |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateRide(entityId)
riderId = comp.GetEntityRider()
```
## GetIsBlocking
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家激活盾牌状态
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 玩家盾牌状态是否激活 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetIsBlocking()
```
## GetPlayerExhaustionRatioByType
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家某行为饥饿度消耗倍率
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| type | int | 行为枚举[PlayerExhauseRatioType枚举](../../枚举值/PlayerExhauseRatioType.md) |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| float | 饥饿度消耗倍率值, -1为获取失败 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
jumpType = serverApi.GetMinecraftEnum().PlayerExhauseRatioType.JUMP
ratio = comp.GetPlayerExhaustionRatioByType(jumpType)
```
## GetPlayerMotions
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
获取玩家身上的所有运动器
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| dict | 运动器集合,key值代表运动器mID,value值代表运动器类型0:轨迹运动器、1:速度运动器、2:环绕运动器 |
- 备注
- 运动器非人为停止后会被移除。
- 示例
```python
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
- 示例
```python
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列表
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| list(str) | exceptList | 排除的玩家id列表,默认值为None,不排除其他玩家及自身 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| list(str) | 附近玩家id列表 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.GetRelevantPlayer(exceptId)
```
## IsEntityRiding
服务端
method in mod.server.component.rideCompServer.RideCompServer
- 描述
检查玩家是否骑乘。
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否骑乘 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateRide(entityId)
isRiding = comp.IsEntityRiding()
```
## IsPlayerFlying
服务端
method in mod.server.component.flyCompServer.FlyComponentServer
- 描述
获取玩家是否在飞行
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | True:是 False:否 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateFly(playerId)
comp.IsPlayerFlying()
```
## PickUpItemEntity
服务端
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
某个Player拾取物品ItemEntity
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| playerEntityId | str | 拾取者的playerEntityId |
| itemEntityId | str | 要拾取的物品itemEntityId |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否拾取成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateGame(levelId)
comp.PickUpItemEntity(playerEntityId, itemEntityId)
```
## PlayerDestoryBlock
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
使用手上工具破坏方块
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| pos | tuple(int,int,int) | 方块位置 |
| particle | int | 是否开启破坏粒子效果,默认为开 |
| sendInv | bool | 是否同步服务端背包信息,默认为不同步。因为破坏方块可能会造成手持物品耐久度降低等信息改变,不同步信息可能会造成后续一些逻辑异常,若大批量破坏方块,每次同步会有性能问题,建议前面的调用可令sendInv为False,在最后一次调用此函数时传入sendInv为True。 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 设置结果 |
- 备注
- 手上工具的附魔效果会生效,同时扣除耐久度
- 会触发ServerPlayerTryDestroyBlockEvent事件,并且可以被这个事件cancel
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId) # 此处playerId为block的破坏者
comp.PlayerDestoryBlock((0, 5, 0), 1, False)
comp.PlayerDestoryBlock((0, 6, 0), 1, True)
# 关闭破坏粒子效果
comp.PlayerDestoryBlock((0, 6, 0),0)
```
## PlayerUseItemToEntity
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
- 描述
玩家使用手上物品对某个生物使用
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| entityId | str | 生物entityId |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 设置结果 |
- 备注
- 1.会触发PlayerInteractServerEvent事件,并且可以被这个事件cancel;2.此接口无视距离,但无法跨维度使用,同时需要目标区域已加载
- 示例
```python
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枚举](../../枚举值/ItemPosType.md) |
| slotPos | int | 槽位,获取INVENTORY及ARMOR时需要设置,其他情况写0即可 |
| facing | int | 朝向,详见[Facing枚举](../../枚举值/Facing.md) |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 设置结果 |
- 备注
- 当使用抛射物时,只有在非创造模式下才会返回True;如果要对"盔甲架"等实体使用物品,请使用PlayerUseItemToEntity接口;只能对玩家周边200格以内的坐标使用
- 示例
```python
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 | 是否成功移除 |
- 示例
```python
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
motionComp.RemovePlayerMotion(mID)
```
## SetPickUpArea
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家的拾取物品范围,设置后该玩家的拾取物品范围会在原版拾取范围的基础上进行改变。
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| area | tuple(float,float,float) | 拾取物品范围,传入(0, 0, 0)时视作取消设置 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
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](../世界/游戏规则.md#sethurtcd)设置的全局攻击cd
- 示例
```python
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枚举](../../枚举值/PlayerExhauseRatioType.md) |
| ratio | float | 倍率 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
jumpType = serverApi.GetMinecraftEnum().PlayerExhauseRatioType.JUMP
ratio = comp.SetPlayerExhaustionRatioByType(jumpType, 20)
```
## SetPlayerJumpable
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家是否可跳跃
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| isJumpable | bool | 是否可跳跃,True允许跳跃,False禁止跳跃 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPlayerJumpable(False)
```
## SetPlayerMovable
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家是否可移动
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| isMovable | bool | 是否可移动,True允许移动,False禁止移动 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
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 | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
suc = comp.SetPlayerRespawnPos((0, 4, 0), 0)
```
## SetPlayerRideEntity
服务端
method in mod.server.component.rideCompServer.RideCompServer
- 描述
设置玩家骑乘生物(或者船与矿车)
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| playerId | str | 玩家id |
| rideEntityId | str | 被骑乘生物id |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 设置结果 |
- 备注
- 通常需要配合SetEntityRide、SetControl一起使用
当被控制的entity有多个位置时且开发者想要添加多个玩家时,第一个被添加的玩家会被引擎默认设置为控制者
- 示例
```python
# 骑上坐骑
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateRide(entityId)
comp.SetPlayerRideEntity(playerId,rideEntityId)
```
## StartPlayerMotion
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
启动玩家身上的某个运动器
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| motionId | int | 要启动的某个运动器的ID |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否成功启动 |
- 备注
- 由于玩家的运动器需要在客户端与服务端之间同步,所以请以[EntityMotionStartServerEvent](../../事件/实体.md#EntityMotionStartServerEvent)事件的触发作为真正的开始时机。
- 示例
```python
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
motionComp.StartPlayerMotion(mID)
```
## StopEntityRiding
服务端
method in mod.server.component.rideCompServer.RideCompServer
- 描述
强制玩家下坐骑。
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 当玩家当前正在骑乘并成功下坐骑返回True,否则返回False |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateRide(entityId)
success = comp.StopEntityRiding()
```
## StopPlayerMotion
服务端
method in mod.server.component.actorMotionCompServer.ActorMotionComponentServer
- 描述
停止玩家身上的某个运动器
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| motionId | int | 要停止的某个运动器的ID |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否成功停止 |
- 备注
- 调用该接口不会触发事件[EntityMotionStopServerEvent](../../事件/实体.md#EntityMotionStopServerEvent)。
- 示例
```python
import mod.server.extraServerApi as serverApi
motionComp = serverApi.GetEngineCompFactory().CreateActorMotion(playerId)
motionComp.StopPlayerMotion(mID)
```
## isGliding
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否鞘翅飞行
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否鞘翅飞行 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isGliding()
```
## isInWater
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否在水中
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否在水中 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isInWater()
```
## isMoving
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否在行走
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否在行走 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isMoving()
```
## isRiding
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否骑乘
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否骑乘 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isRiding()
```
## isSneaking
服务端客户端
### 服务端接口
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家是否处于潜行状态
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 当前玩家是否处于潜行状态 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
is_sneaking = comp.isSneaking()
```
### 客户端接口
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否潜行
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否潜行 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isSneaking()
```
## isSprinting
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否在疾跑
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否在疾跑 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isSprinting()
```
## isSwimming
服务端客户端
### 服务端接口
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家是否处于游泳状态。
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 当前玩家是否处于游泳状态 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
is_swiming = comp.isSwimming()
```
### 客户端接口
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
是否游泳
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否游泳 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.isSwimming()
```
## setMoving
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
设置是否行走,只能设置本地玩家(只适用于移动端)
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.setMoving()
```
## setSneaking
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
设置是否潜行,只能设置本地玩家(只适用于移动端)
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.setSneaking()
```
## setSprinting
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
设置是否疾跑,只能设置本地玩家(只适用于移动端)
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.setSprinting()
```
## setUsingShield
客户端
method in mod.client.component.playerCompClient.PlayerCompClient
- 描述
激活盾牌状态
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| flag | bool | True使用盾牌,False取消使用盾牌 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| int | 1设置成功,0设置失败,-1玩家未持盾 |
- 示例
```python
comp = clientApi.GetEngineCompFactory().CreatePlayer(entityId)
comp.setUsingShield(True)
```