25 KiB
sidebarDepth
| sidebarDepth |
|---|
| 1 |
控制
索引
包括屏幕操作的相关接口
| 接口 | 描述 | |
|---|---|---|
| AddPickBlacklist | 客户端 | 添加使用camera组件选取实体时的黑名单,即该实体不会被选取到 |
| ClearPickBlacklist | 客户端 | 清除使用camera组件选取实体的黑名单 |
| GetChosen | 客户端 | 获取屏幕点击位置的实体或方块信息,通常与GetEntityByCoordEvent配合使用 |
| GetChosenEntity | 客户端 | 获取屏幕点击位置的实体id,通常与GetEntityByCoordEvent配合使用 |
| GetHoldTimeThresholdInMs | 客户端 | 获取长按判定时间,即按着屏幕多长时间会触发长按操作 |
| GetInputVector | 客户端 | 获取方向键(移动轮盘)的输入 |
| GetTouchPos | 客户端 | 获取点击的屏幕坐标。可以监听TapBeforeClientEvent或TapOrHoldReleaseClientEvent事件,调用本API获取点击坐标。 |
| LockInputVector | 客户端 | 锁定本地玩家方向键(移动轮盘)的输入,可使本地玩家持续向指定方向前行,且不会再受玩家输入影响 |
| PickFacing | 客户端 | 获取准星选中的实体或者方块 |
| SetCanAll | 客户端 | 同时设置SetCanMove,SetCanJump,SetCanAttack,SetCanWalkMode,SetCanPerspective,SetCanPause,SetCanChat,SetCanScreenShot,SetCanOpenInv,SetCanDrag,SetCanInair |
| SetCanAttack | 客户端 | 设置是否响应攻击 |
| SetCanChat | 客户端 | 设置是否响应聊天按钮 |
| SetCanDrag | 客户端 | 设置是否响应屏幕拖动 |
| SetCanInair | 客户端 | 设置是否响应上升下降按钮(飞在空中时右下角的三个按钮) |
| SetCanJump | 客户端 | 设置是否响应跳跃(以及在水中浮起) |
| SetCanMove | 客户端 | 设置是否响应移动 |
| SetCanOpenInv | 客户端 | 设置是否响应打开背包按钮 |
| SetCanPause | 客户端 | 设置是否响应暂停按钮 |
| SetCanPerspective | 客户端 | 设置是否响应切换视角 |
| SetCanScreenShot | 客户端 | 设置是否响应截图按钮 |
| SetCanWalkMode | 客户端 | 设置是否响应切换行走模式 |
| SetDeviceVibrate | 客户端 | 设置设备震动 |
| SetHoldTimeThreshold | 客户端 | 设置长按判定时间,即按着屏幕多长时间会触发长按操作 |
| SetMoveLock | 客户端 | 设置是否锁住移动。实际上为是否响应十字键与遥感的操作。 |
| SetShowRideUI | 服务端 | 设置是否显示马匹的UI界面 |
| SimulateTouchWithMouse | 客户端 | 模拟使用鼠标控制UI(PC F11快捷键) |
| UnlockInputVector | 客户端 | 解锁本地玩家方向键(移动轮盘)的输入 |
AddPickBlacklist
客户端
method in mod.client.component.gameCompClient.GameComponentClient
-
描述
添加使用camera组件选取实体时的黑名单,即该实体不会被选取到
-
参数
参数名 数据类型说明 entityId str 实体id -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateGame(levelId)
# 添加黑名单
comp.AddPickBlacklist(entityId)
ClearPickBlacklist
客户端
method in mod.client.component.gameCompClient.GameComponentClient
-
描述
清除使用camera组件选取实体的黑名单
-
参数
无
-
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateGame(levelId)
# 清除黑名单中所有实体
comp.ClearPickBlacklist()
GetChosen
客户端
method in mod.client.component.cameraCompClient.CameraComponentClient
-
描述
获取屏幕点击位置的实体或方块信息,通常与GetEntityByCoordEvent配合使用
-
参数
无
-
返回值
数据类型说明 dict 选中目标的数据,详见PickFacing接口的备注 -
备注
- 目前只有在第一人称视角才能准确获取
-
示例
import mod.client.extraClientApi as clientApi
# 当玩家点击屏幕时获取点击位置的entityId
class MyClientSystem(ClientSystem):
def __init__(self, namespace, name):
ClientSystem.__init__(self, namespace, name)
self.ListenForEvent('Minecraft', 'Engine', 'GetEntityByCoordEvent', self, self.click)
def click(self, args):
comp = clientApi.GetEngineCompFactory().CreateCamera(levelId)
pickData = comp.GetChosen()
GetChosenEntity
客户端
method in mod.client.component.cameraCompClient.CameraComponentClient
-
描述
获取屏幕点击位置的实体id,通常与GetEntityByCoordEvent配合使用
-
参数
无
-
返回值
数据类型说明 str 实体id -
备注
- 目前只有在第一人称视角才能准确获取
-
示例
# 当玩家点击屏幕时获取点击位置的entityId
import mod.client.extraClientApi as clientApi
class MyClientSystem(ClientSystem):
def __init__(self, namespace, name):
ClientSystem.__init__(self, namespace, name)
self.ListenForEvent('Minecraft', 'Engine', 'GetEntityByCoordEvent', self, self.click)
def click(self, args):
comp = clientApi.GetEngineCompFactory().CreateCamera(levelId)
entityId = comp.GetChosenEntity()
GetHoldTimeThresholdInMs
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
获取长按判定时间,即按着屏幕多长时间会触发长按操作
-
参数
无
-
返回值
数据类型说明 int 时间,单位毫秒。默认为400 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
timeMs = comp.GetHoldTimeThresholdInMs()
GetInputVector
客户端
method in mod.client.component.actorMotionCompClient.ActorMotionComponentClient
-
描述
获取方向键(移动轮盘)的输入
-
参数
无
-
返回值
数据类型说明 tuple(float,float) 返回一个单位向量,向量第一项为向左的大小,第二项为向前的大小 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateActorMotion(localPlayerId)
left, up = comp.GetInputVector()
GetTouchPos
客户端
method in mod.client.extraClientApi
-
描述
获取点击的屏幕坐标。可以监听TapBeforeClientEvent或TapOrHoldReleaseClientEvent事件,调用本API获取点击坐标。
-
参数
无
-
返回值
数据类型说明 tuple(float,float) 屏幕坐标 -
示例
import mod.client.extraClientApi as clientApi
def GetTouchPosTest():
touchX, touchY = clientApi.GetTouchPos()
LockInputVector
客户端
method in mod.client.component.actorMotionCompClient.ActorMotionComponentClient
-
描述
锁定本地玩家方向键(移动轮盘)的输入,可使本地玩家持续向指定方向前行,且不会再受玩家输入影响
-
参数
参数名 数据类型说明 inputVector tuple(float,float) 输入向量,第一项控制向左的大小,第二项控制向前的大小。传入(0, 0)时玩家将会被强制固定在原地,不允许移动。 -
返回值
数据类型说明 bool 是否锁定成功,True:成功 False:失败 -
备注
- 传入的向量会被转化为单位向量,因此传入(10, 0)与传入(0.1, 0)效果相同
-
示例
import mod.client.extraClientApi as clientApi
# 使玩家向左前方持续移动
localPlayerId = clientApi.GetLocalPlayerId()
rotComp = clientApi.GetEngineCompFactory().CreateRot(localPlayerId)
motionComp = clientApi.GetEngineCompFactory().CreateActorMotion(localPlayerId)
motionComp.LockInputVector((1, 1))
PickFacing
客户端
method in mod.client.component.cameraCompClient.CameraComponentClient
-
描述
获取准星选中的实体或者方块
-
参数
无
-
返回值
数据类型说明 dict 选中目标的数据,详见备注 -
备注
- 选中目标为实体时,返回值为:
{ "type": "Entity", "entityId": entityId } - 选中目标为方块时,返回值为:
{ "type": "Block", "x": x, "y": y, "z": z, "face": face } - 没有选中目标时,返回值为:
{ "type": "None" }
- 选中目标为实体时,返回值为:
-
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateCamera(levelId)
pickData = comp.PickFacing()
SetCanAll
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
同时设置SetCanMove,SetCanJump,SetCanAttack,SetCanWalkMode,SetCanPerspective,SetCanPause,SetCanChat,SetCanScreenShot,SetCanOpenInv,SetCanDrag,SetCanInair
-
参数
参数名 数据类型说明 all bool True为全部响应 -
返回值
数据类型说明 bool 设置是否成功 -
备注
- 要在其他属性设置之前设置,不然在all之前设置的会被覆盖掉
-
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 全部设置为不响应
comp.SetCanAll(False)
SetCanAttack
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应攻击
-
参数
参数名 数据类型说明 attack bool True为可攻击 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应攻击
comp.SetCanAttack(False)
SetCanChat
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应聊天按钮
-
参数
参数名 数据类型说明 chat bool True为可打开聊天页面 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应聊天按钮
comp.SetCanChat(False)
SetCanDrag
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应屏幕拖动
-
参数
参数名 数据类型说明 drag bool True为可拖动屏幕 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应屏幕拖动
comp.SetCanDrag(False)
SetCanInair
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应上升下降按钮(飞在空中时右下角的三个按钮)
-
参数
参数名 数据类型说明 inair bool True为可点击 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应空中控制按钮
comp.SetCanInair(False)
SetCanJump
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应跳跃(以及在水中浮起)
-
参数
参数名 数据类型说明 jump bool True为可跳跃 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应跳跃
comp.SetCanJump(False)
SetCanMove
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应移动
-
参数
参数名 数据类型说明 move bool True为可移动 -
返回值
数据类型说明 bool 设置是否成功 -
备注
- 与SetMoveLock的区别:调用SetCanMove会清除当前Input Vector,例如玩家一直按着前进键,调用SetCanMove(False)会立即停下来,调用SetMoveLock(True)则不会。
-
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应移动
comp.SetCanMove(False)
SetCanOpenInv
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应打开背包按钮
-
参数
参数名 数据类型说明 open bool True为可打开背包 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应打开背包按钮
comp.SetCanOpenInv(False)
SetCanPause
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应暂停按钮
-
参数
参数名 数据类型说明 pause bool True为可打开暂停页面 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应暂停按钮
comp.SetCanPause(False)
SetCanPerspective
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应切换视角
-
参数
参数名 数据类型说明 persp bool True为可切换 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应切换视角
comp.SetCanPerspective(False)
SetCanScreenShot
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应截图按钮
-
参数
参数名 数据类型说明 shot bool True为可截图 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应截图按钮
comp.SetCanScreenShot(False)
SetCanWalkMode
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否响应切换行走模式
-
参数
参数名 数据类型说明 walkmode bool True为可切换 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 不响应切换行走模式
comp.SetCanWalkMode(False)
SetDeviceVibrate
客户端
method in mod.client.component.deviceCompClient.DeviceCompClient
-
描述
设置设备震动
-
参数
参数名 数据类型说明 milliSeconds int 震动时间(单位:毫秒) -
返回值
数据类型说明 bool 设置是否成功 -
备注
- 设置时间区间为[1,5000]毫秒,如果milliSeconds参数大于该区间将会被设置为5000毫秒,小于则设为1毫秒
- 调用时距离上次震动结束的时间不能短于2秒,如果短于2秒本次设置将会失败
- 设置震动失败(函数返回False)的可能原因:距离上次震动结束还未超过2秒、当前已经处于震动状态、设备不支持震动等
- 即使函数返回值为True,也有可能因为未正确判断设备是否支持震动、设备权限上禁止震动等原因未能真正震动
- 在目前版本中还不支持对IOS设备进行震动
-
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateDevice(entityId)
comp.SetDeviceVibrate(1000)
SetHoldTimeThreshold
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置长按判定时间,即按着屏幕多长时间会触发长按操作
-
参数
参数名 数据类型说明 time int 时间,单位毫秒。默认为400 -
返回值
数据类型说明 bool 设置是否成功 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
comp.SetHoldTimeThreshold(100)
SetMoveLock
客户端
method in mod.client.component.operationCompClient.OperationCompClient
-
描述
设置是否锁住移动。实际上为是否响应十字键与遥感的操作。
-
参数
参数名 数据类型说明 movelock bool True为锁住 -
返回值
数据类型说明 bool 设置是否成功 -
备注
- 与SetCanMove的区别:调用SetCanMove会清除当前Input Vector,例如玩家一直按着前进键,调用SetCanMove(False)会立即停下来,调用SetMoveLock(True)则不会。
-
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateOperation(levelId)
# 锁住移动
comp.SetMoveLock(True)
SetShowRideUI
服务端
method in mod.server.component.rideCompServer.RideCompServer
-
描述
设置是否显示马匹的UI界面
-
参数
参数名 数据类型说明 tamedEntityId str 可骑乘生物id isShowUI bool 是否显示UI -
返回值
数据类型说明 bool 设置结果 -
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateRide(entityId)
comp.SetShowRideUI(entityId,False)
SimulateTouchWithMouse
客户端
method in mod.client.component.gameCompClient.GameComponentClient
-
描述
模拟使用鼠标控制UI(PC F11快捷键)
-
参数
参数名 数据类型说明 touch bool True:进入鼠标模式,False:退出鼠标模式 -
返回值
数据类型说明 bool 模拟结果 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateGame(levelId)
comp.SimulateTouchWithMouse(True)
UnlockInputVector
客户端
method in mod.client.component.actorMotionCompClient.ActorMotionComponentClient
-
描述
解锁本地玩家方向键(移动轮盘)的输入
-
参数
无
-
返回值
数据类型说明 bool 是否解锁成功,True:成功 False:失败 -
示例
import mod.client.extraClientApi as clientApi
# 解锁使用LockInputVector锁定的本地玩家方向键(移动轮盘)输入
comp = clientApi.GetEngineCompFactory().CreateActorMotion(localPlayerId)
motionComp.UnlockInputVector()