Files
boybook 760c2dd9ad 2.6
2025-12-01 20:59:16 +08:00

2096 lines
53 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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