Files
netease-modsdk-wiki/docs/mcdocs/1-ModAPI/接口/通用/索引.md
2025-06-27 23:59:47 +08:00

166 lines
23 KiB
Markdown
Raw 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
---
# 索引
---
- [Component](#component)
- [System](#system)
- [事件](#事件)
- [本地设备](#本地设备)
- [本地存储](#本地存储)
- [数学](#数学)
- [工具](#工具)
- [调试](#调试)
### Component
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [CreateComponent](Component.md#createcomponent) | <span style="display:inline;color:#ff5555">服务端</span> | 给实体创建服务端组件 |
| [CreateComponent](Component.md#createcomponent) | <span style="display:inline;color:#7575f9">客户端</span> | 给实体创建客户端组件 |
| [DestroyComponent](Component.md#destroycomponent) | <span style="display:inline;color:#ff5555">服务端</span> | 删除实体的服务端组件 |
| [DestroyComponent](Component.md#destroycomponent) | <span style="display:inline;color:#7575f9">客户端</span> | 删除实体的客户端组件 |
| [GetComponent](Component.md#getcomponent) | <span style="display:inline;color:#ff5555">服务端</span> | 获取实体的服务端组件。一般用来判断某个组件是否创建过其他情况请使用CreateComponent |
| [GetComponent](Component.md#getcomponent) | <span style="display:inline;color:#7575f9">客户端</span> | 获取实体的客户端组件。一般用来判断某个组件是否创建过其他情况请使用CreateComponent |
| [GetComponentCls](Component.md#getcomponentcls) | <span style="display:inline;color:#ff5555">服务端</span> | 用于获取服务器component基类。实现新的component时需要继承该接口返回的类 |
| [GetComponentCls](Component.md#getcomponentcls) | <span style="display:inline;color:#7575f9">客户端</span> | 用于获取客户端component基类。实现新的component时需要继承该接口返回的类 |
| [GetEngineCompFactory](Component.md#getenginecompfactory) | <span style="display:inline;color:#ff5555">服务端</span> | 获取引擎组件的工厂,通过工厂可以创建服务端的引擎组件 |
| [GetEngineCompFactory](Component.md#getenginecompfactory) | <span style="display:inline;color:#7575f9">客户端</span> | 获取引擎组件的工厂,通过工厂可以创建客户端的引擎组件 |
| [RegisterComponent](Component.md#registercomponent) | <span style="display:inline;color:#ff5555">服务端</span> | 用于将组件注册到引擎中 |
| [RegisterComponent](Component.md#registercomponent) | <span style="display:inline;color:#7575f9">客户端</span> | 用于将组件注册到引擎中 |
### System
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [GetClientSystemCls](System.md#getclientsystemcls) | <span style="display:inline;color:#7575f9">客户端</span> | 用于获取客户端system基类。实现新的system时需要继承该接口返回的类 |
| [GetServerSystemCls](System.md#getserversystemcls) | <span style="display:inline;color:#ff5555">服务端</span> | 用于获取服务器system基类。实现新的system时需要继承该接口返回的类 |
| [GetSystem](System.md#getsystem) | <span style="display:inline;color:#ff5555">服务端</span> | 获取已注册的系统 |
| [GetSystem](System.md#getsystem) | <span style="display:inline;color:#7575f9">客户端</span> | 用于获取其他系统实例 |
| [RegisterSystem](System.md#registersystem) | <span style="display:inline;color:#ff5555">服务端</span> | 用于将系统注册到引擎中引擎会创建一个该系统的实例并在退出游戏时回收。系统可以执行我们引擎赋予的基本逻辑例如监听事件、执行Tick函数、与客户端进行通讯等。 |
| [RegisterSystem](System.md#registersystem) | <span style="display:inline;color:#7575f9">客户端</span> | 用于将系统注册到引擎中引擎会创建一个该系统的实例并在退出游戏时回收。系统可以执行我们引擎赋予的基本逻辑例如监听事件、执行Tick函数、与服务端进行通讯等。 |
### 事件
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [BroadcastEvent](事件.md#broadcastevent) | <span style="display:inline;color:#ff5555">服务端</span><br><span style="display:inline;color:#7575f9">客户端</span> | 本地广播事件客户端system广播的事件仅客户端system能监听服务器system广播的事件仅服务端system能监听。 |
| [BroadcastToAllClient](事件.md#broadcasttoallclient) | <span style="display:inline;color:#ff5555">服务端</span> | 服务器广播事件到所有客户端 |
| [CreateEventData](事件.md#createeventdata) | <span style="display:inline;color:#ff5555">服务端</span><br><span style="display:inline;color:#7575f9">客户端</span> | 创建自定义事件的数据eventData用于发送事件。创建的eventData可以理解为一个dict可以嵌套赋值dict,list和基本数据类型但不支持tuple |
| [GetEngineNamespace](事件.md#getenginenamespace) | <span style="display:inline;color:#ff5555">服务端</span> | 获取引擎事件的命名空间。监听引擎事件时namespace传该接口返回的namespace |
| [GetEngineNamespace](事件.md#getenginenamespace) | <span style="display:inline;color:#7575f9">客户端</span> | 获取引擎事件的命名空间。监听引擎事件时namespace传该接口返回的namespace |
| [GetEngineSystemName](事件.md#getenginesystemname) | <span style="display:inline;color:#ff5555">服务端</span> | 获取引擎系统名。监听引擎事件时systemName传该接口返回的systemName |
| [GetEngineSystemName](事件.md#getenginesystemname) | <span style="display:inline;color:#7575f9">客户端</span> | 获取引擎系统名。监听引擎事件时systemName传该接口返回的systemName |
| [ListenForEvent](事件.md#listenforevent) | <span style="display:inline;color:#ff5555">服务端</span><br><span style="display:inline;color:#7575f9">客户端</span> | 注册监听某个系统抛出的事件。若监听引擎事件时namespace和systemName分别为GetEngineNamespace()和GetEngineSystemName()。具体每个事件的详细事件data可以参考"事件"分类下的内容 |
| [NotifyToClient](事件.md#notifytoclient) | <span style="display:inline;color:#ff5555">服务端</span> | 服务器发送事件到指定客户端 |
| [NotifyToMultiClients](事件.md#notifytomulticlients) | <span style="display:inline;color:#ff5555">服务端</span> | 服务器发送事件到指定一批客户端相比于在for循环内使用NotifyToClient性能更好 |
| [NotifyToServer](事件.md#notifytoserver) | <span style="display:inline;color:#7575f9">客户端</span> | 客户端发送事件到服务器 |
| [UnListenAllEvents](事件.md#unlistenallevents) | <span style="display:inline;color:#ff5555">服务端</span><br><span style="display:inline;color:#7575f9">客户端</span> | 反注册监听某个系统抛出的所有事件,即不再监听。 |
| [UnListenForEvent](事件.md#unlistenforevent) | <span style="display:inline;color:#ff5555">服务端</span><br><span style="display:inline;color:#7575f9">客户端</span> | 反注册监听某个系统抛出的事件即不再监听。若是引擎事件则namespace和systemName分别为[GetEngineNamespace](事件.md#getenginenamespace)和[GetEngineSystemName](事件.md#getenginesystemname)。与ListenForEvent对应。 |
### 本地设备
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [GetEngineVersion](本地设备.md#getengineversion) | <span style="display:inline;color:#7575f9">客户端</span> | 获取游戏版本-客户端。 |
| [GetIP](本地设备.md#getip) | <span style="display:inline;color:#7575f9">客户端</span> | 获取本地玩家的ip地址 |
| [GetMinecraftVersion](本地设备.md#getminecraftversion) | <span style="display:inline;color:#ff5555">服务端</span> | 获取Minecraft版本-服务端。 |
| [GetMinecraftVersion](本地设备.md#getminecraftversion) | <span style="display:inline;color:#7575f9">客户端</span> | 获取Minecraft版本-客户端。 |
| [GetPlatform](本地设备.md#getplatform) | <span style="display:inline;color:#ff5555">服务端</span> | 获取脚本运行的平台 |
| [GetPlatform](本地设备.md#getplatform) | <span style="display:inline;color:#7575f9">客户端</span> | 获取脚本运行的平台 |
| [IsInApollo](本地设备.md#isinapollo) | <span style="display:inline;color:#ff5555">服务端</span> | 返回当前游戏Mod是否运行在Apollo网络服 |
| [IsInServer](本地设备.md#isinserver) | <span style="display:inline;color:#ff5555">服务端</span> | 获取当前游戏是否跑在服务器环境下 |
### 本地存储
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [GetConfigData](本地存储.md#getconfigdata) | <span style="display:inline;color:#7575f9">客户端</span> | 获取本地配置文件中存储的数据 |
| [SetConfigData](本地存储.md#setconfigdata) | <span style="display:inline;color:#7575f9">客户端</span> | 以本地配置文件的方式存储数据 |
### 数学
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [GetDirFromRot](数学.md#getdirfromrot) | <span style="display:inline;color:#ff5555">服务端</span> | 通过旋转角度获取朝向 |
| [GetDirFromRot](数学.md#getdirfromrot) | <span style="display:inline;color:#7575f9">客户端</span> | 通过旋转角度获取朝向 |
| [GetIntPos](数学.md#getintpos) | <span style="display:inline;color:#ff5555">服务端</span> | 获取坐标所在方块的位置,即浮点数坐标向下取整后的整数坐标。 |
| [GetIntPos](数学.md#getintpos) | <span style="display:inline;color:#7575f9">客户端</span> | 获取坐标所在方块的位置,即浮点数坐标向下取整后的整数坐标。 |
| [GetLocalPosFromWorld](数学.md#getlocalposfromworld) | <span style="display:inline;color:#ff5555">服务端</span> | 获取基于实体的世界坐标对应的局部坐标 |
| [GetLocalPosFromWorld](数学.md#getlocalposfromworld) | <span style="display:inline;color:#7575f9">客户端</span> | 获取基于实体的世界坐标对应的局部坐标 |
| [GetRotFromDir](数学.md#getrotfromdir) | <span style="display:inline;color:#ff5555">服务端</span> | 通过朝向获取旋转角度 |
| [GetRotFromDir](数学.md#getrotfromdir) | <span style="display:inline;color:#7575f9">客户端</span> | 通过朝向获取旋转角度 |
| [GetWorldPosFromLocal](数学.md#getworldposfromlocal) | <span style="display:inline;color:#ff5555">服务端</span> | 获取基于实体的局部坐标对应的世界坐标 |
| [GetWorldPosFromLocal](数学.md#getworldposfromlocal) | <span style="display:inline;color:#7575f9">客户端</span> | 获取基于实体的局部坐标对应的世界坐标 |
### 工具
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [AddRepeatedTimer](工具.md#addrepeatedtimer) | <span style="display:inline;color:#ff5555">服务端</span> | 添加服务端触发的定时器,重复执行 |
| [AddRepeatedTimer](工具.md#addrepeatedtimer) | <span style="display:inline;color:#7575f9">客户端</span> | 添加客户端触发的定时器,重复执行 |
| [AddTimer](工具.md#addtimer) | <span style="display:inline;color:#ff5555">服务端</span> | 添加服务端触发的定时器,非重复 |
| [AddTimer](工具.md#addtimer) | <span style="display:inline;color:#7575f9">客户端</span> | 添加客户端触发的定时器,非重复 |
| [CancelTimer](工具.md#canceltimer) | <span style="display:inline;color:#ff5555">服务端</span> | 取消定时器 |
| [CancelTimer](工具.md#canceltimer) | <span style="display:inline;color:#7575f9">客户端</span> | 取消定时器 |
| [CheckNameValid](工具.md#checknamevalid) | <span style="display:inline;color:#ff5555">服务端</span> | 检查昵称是否合法,即不包含敏感词 |
| [CheckNameValid](工具.md#checknamevalid) | <span style="display:inline;color:#7575f9">客户端</span> | 检查昵称是否合法,即不包含敏感词 |
| [CheckWordsValid](工具.md#checkwordsvalid) | <span style="display:inline;color:#ff5555">服务端</span> | 检查语句是否合法,即不包含敏感词 |
| [CheckWordsValid](工具.md#checkwordsvalid) | <span style="display:inline;color:#7575f9">客户端</span> | 检查语句是否合法,即不包含敏感词 |
| [GetChinese](工具.md#getchinese) | <span style="display:inline;color:#ff5555">服务端</span> | 获取langStr对应的中文可参考PC开发包中\handheld\localization\handheld\data\resource_packs\vanilla\texts\zh_CN.lang |
| [GetChinese](工具.md#getchinese) | <span style="display:inline;color:#7575f9">客户端</span> | 获取langStr对应的中文可参考PC开发包中\handheld\localization\handheld\data\resource_packs\vanilla\texts\zh_CN.lang |
| [GetClipboardContent](工具.md#getclipboardcontent) | <span style="display:inline;color:#7575f9">客户端</span> | 获取系统剪贴板内容 |
| [GetFps](工具.md#getfps) | <span style="display:inline;color:#7575f9">客户端</span> | 获取fps |
| [GetHostPlayerId](工具.md#gethostplayerid) | <span style="display:inline;color:#ff5555">服务端</span> | 获取房主的entityId |
| [GetHostPlayerId](工具.md#gethostplayerid) | <span style="display:inline;color:#7575f9">客户端</span> | 获取房主的entityId |
| [GetMinecraftEnum](工具.md#getminecraftenum) | <span style="display:inline;color:#ff5555">服务端</span> | 用于获取[枚举值文档](../../枚举值/索引.md)中的枚举值 |
| [GetMinecraftEnum](工具.md#getminecraftenum) | <span style="display:inline;color:#7575f9">客户端</span> | 用于获取[枚举值文档](../../枚举值/索引.md)中的枚举值 |
| [GetModConfigJson](工具.md#getmodconfigjson) | <span style="display:inline;color:#7575f9">客户端</span> | 以字典形式返回指定路径的json格式配置文件的内容文件必须放置在资源包的/modconfigs目录下 |
| [GetServerTickTime](工具.md#getserverticktime) | <span style="display:inline;color:#ff5555">服务端</span> | 获取服务端引擎上一帧的帧消耗时间 |
| [ImportModule](工具.md#importmodule) | <span style="display:inline;color:#ff5555">服务端</span> | 使用字符串路径导入模块作用与importlib.import_module类似但只能导入当前加载的mod中的模块 |
| [ImportModule](工具.md#importmodule) | <span style="display:inline;color:#7575f9">客户端</span> | 使用字符串路径导入模块作用与importlib.import_module类似但只能导入当前加载的mod中的模块 |
| [SetClipboardContent](工具.md#setclipboardcontent) | <span style="display:inline;color:#7575f9">客户端</span> | 设置系统剪贴板内容 |
| [StartCoroutine](工具.md#startcoroutine) | <span style="display:inline;color:#ff5555">服务端</span> | 开启服务端协程,实现函数分段式执行,可用于缓解复杂逻辑计算导致游戏卡顿问题 |
| [StartCoroutine](工具.md#startcoroutine) | <span style="display:inline;color:#7575f9">客户端</span> | 开启客户端协程,实现函数分段式执行,可用于缓解复杂逻辑计算导致游戏卡顿问题 |
| [StopCoroutine](工具.md#stopcoroutine) | <span style="display:inline;color:#ff5555">服务端</span> | 停止协程 |
| [StopCoroutine](工具.md#stopcoroutine) | <span style="display:inline;color:#7575f9">客户端</span> | 停止客户端协程 |
### 调试
| 接口 | <div style="width: 3em"></div> | 描述 |
| --- | --- | --- |
| [GetEnableReconnectNetgame](调试.md#getenablereconnectnetgame) | <span style="display:inline;color:#7575f9">客户端</span> | 获取是否允许断线重连 |
| [GetKeepResourceWhenTransfer](调试.md#getkeepresourcewhentransfer) | <span style="display:inline;color:#7575f9">客户端</span> | 获取快速切服设置 |
| [GetMcpModLogCanPostDump](调试.md#getmcpmodlogcanpostdump) | <span style="display:inline;color:#ff5555">服务端</span> | 获取是否可以打印错误信息到McpModLog日志。 |
| [GetMcpModLogCanPostDump](调试.md#getmcpmodlogcanpostdump) | <span style="display:inline;color:#7575f9">客户端</span> | 获取是否可以打印错误信息到McpModLog日志。 |
| [GetResourceFastload](调试.md#getresourcefastload) | <span style="display:inline;color:#7575f9">客户端</span> | 获取资源快速加载设置 |
| [PostMcpModDump](调试.md#postmcpmoddump) | <span style="display:inline;color:#ff5555">服务端</span> | 主动打印信息到McpModLog日志需要先调用 SetMcpModLogCanPostDump 接口进行设置,才能生效。 |
| [PostMcpModDump](调试.md#postmcpmoddump) | <span style="display:inline;color:#7575f9">客户端</span> | 主动打印信息到McpModLog日志需要先调用 SetMcpModLogCanPostDump 接口进行设置,才能生效。 |
| [ReloadAllMaterials](调试.md#reloadallmaterials) | <span style="display:inline;color:#7575f9">客户端</span> | 重新加载所有材质文件 |
| [ReloadAllShaders](调试.md#reloadallshaders) | <span style="display:inline;color:#7575f9">客户端</span> | 重新加载所有Shader文件 |
| [ReloadOneShader](调试.md#reloadoneshader) | <span style="display:inline;color:#7575f9">客户端</span> | 重新加载某个Shader文件 |
| [SetEnableReconnectNetgame](调试.md#setenablereconnectnetgame) | <span style="display:inline;color:#7575f9">客户端</span> | 设置是否允许断线重连 |
| [SetKeepResourceWhenTransfer](调试.md#setkeepresourcewhentransfer) | <span style="display:inline;color:#7575f9">客户端</span> | 设置快速切服 |
| [SetMcpModLogCanPostDump](调试.md#setmcpmodlogcanpostdump) | <span style="display:inline;color:#ff5555">服务端</span> | 设置是否可以打印错误信息到McpModLog日志。 |
| [SetMcpModLogCanPostDump](调试.md#setmcpmodlogcanpostdump) | <span style="display:inline;color:#7575f9">客户端</span> | 设置是否可以打印错误信息到McpModLog日志。 |
| [SetResourceFastload](调试.md#setresourcefastload) | <span style="display:inline;color:#7575f9">客户端</span> | 设置资源快速加载 |
| [StartMemProfile](调试.md#startmemprofile) | <span style="display:inline;color:#ff5555">服务端</span> | 开始启动服务端脚本内存分析,启动后调用[StopMemProfile](调试.md#stopMemProfile)即可在路径fileName生成函数内存火焰图此接口只支持PC端。生成的火焰图可以用浏览器打开推荐chrome浏览器。 |
| [StartMemProfile](调试.md#startmemprofile) | <span style="display:inline;color:#7575f9">客户端</span> | 开始启动客户端脚本内存分析,启动后调用[StopMemProfile](调试.md#stopMemProfile)即可在路径fileName生成函数内存火焰图此接口只支持PC端。生成的火焰图可以用浏览器打开推荐chrome浏览器。 |
| [StartMultiProfile](调试.md#startmultiprofile) | <span style="display:inline;color:#ff5555">服务端</span> | 开始启动服务端与客户端双端脚本性能分析,启动后调用[StopMultiProfile](调试.md#stopmultiprofile)即可在路径fileName生成函数性能火焰图。双端采集时数据误差较大建议优先使用[StartProfile](调试.md#startprofile)单端版本此接口只支持PC端 |
| [StartMultiProfile](调试.md#startmultiprofile) | <span style="display:inline;color:#7575f9">客户端</span> | 开始启动服务端与客户端双端脚本性能分析,启动后调用[StopMultiProfile](调试.md#stopmultiprofile)即可在路径fileName生成函数性能火焰图。双端采集时数据误差较大建议优先使用[StartProfile](调试.md#startprofile)单端版本此接口只支持PC端 |
| [StartProfile](调试.md#startprofile) | <span style="display:inline;color:#ff5555">服务端</span> | 开始启动服务端脚本性能分析,启动后调用[StopProfile](调试.md#stopprofile)即可在路径fileName生成函数性能火焰图此接口只支持PC端。生成的火焰图可以用浏览器打开推荐chrome浏览器。 |
| [StartProfile](调试.md#startprofile) | <span style="display:inline;color:#7575f9">客户端</span> | 开始启动客户端脚本性能分析,启动后调用[StopProfile](调试.md#stopprofile)即可在路径fileName生成函数性能火焰图此接口只支持PC端。生成的火焰图可以用浏览器打开推荐chrome浏览器。 |
| [StartRecordEvent](调试.md#startrecordevent) | <span style="display:inline;color:#ff5555">Apollo</span> | 开始启动服务端与客户端之间的脚本事件收发统计,启动后调用[StopRecordEvent](调试.md#stoprecordevent)即可获取两个函数调用之间脚本事件收发的统计信息仅支持租赁服与Apollo网络服环境不支持单机环境 |
| [StartRecordPacket](调试.md#startrecordpacket) | <span style="display:inline;color:#ff5555">Apollo</span> | 开始启动服务端与客户端之间的引擎收发包统计,启动后调用[StopRecordPacket](调试.md#stoprecordpacket)即可获取两个函数调用之间引擎收发包的统计信息仅支持租赁服与Apollo网络服环境不支持单机环境 |
| [StopMemProfile](调试.md#stopmemprofile) | <span style="display:inline;color:#ff5555">服务端</span> | 停止服务端脚本内存分析并生成火焰图,与[StartMemProfile](调试.md#startMemProfile)配合使用此接口只支持PC端 |
| [StopMemProfile](调试.md#stopmemprofile) | <span style="display:inline;color:#7575f9">客户端</span> | 停止客户端脚本内存分析并生成火焰图,与[StartMemProfile](调试.md#startMemProfile)配合使用此接口只支持PC端 |
| [StopMultiProfile](调试.md#stopmultiprofile) | <span style="display:inline;color:#ff5555">服务端</span> | 停止双端脚本性能分析并生成火焰图,与[StartMultiProfile](调试.md#startmultiprofile)配合使用此接口只支持PC端 |
| [StopMultiProfile](调试.md#stopmultiprofile) | <span style="display:inline;color:#7575f9">客户端</span> | 停止双端脚本性能分析并生成火焰图,与[StartMultiProfile](调试.md#startmultiprofile)配合使用此接口只支持PC端 |
| [StopProfile](调试.md#stopprofile) | <span style="display:inline;color:#ff5555">服务端</span> | 停止服务端脚本性能分析并生成火焰图,与[StartProfile](调试.md#startprofile)配合使用此接口只支持PC端 |
| [StopProfile](调试.md#stopprofile) | <span style="display:inline;color:#7575f9">客户端</span> | 停止客户端脚本性能分析并生成火焰图,与[StartProfile](调试.md#startprofile)配合使用此接口只支持PC端 |
| [StopRecordEvent](调试.md#stoprecordevent) | <span style="display:inline;color:#ff5555">Apollo</span> | 停止服务端与客户端之间的脚本事件收发统计并输出结果,与[StartRecordEvent](调试.md#startrecordevent)配合使用输出结果为字典key为网络包名value字典中记录收发信息具体见示例仅支持租赁服与Apollo网络服环境不支持单机环境 |
| [StopRecordPacket](调试.md#stoprecordpacket) | <span style="display:inline;color:#ff5555">Apollo</span> | 停止服务端与客户端之间的引擎收发包统计并输出结果,与[StartRecordPacket](调试.md#startrecordpacket)配合使用输出结果为字典key为网络包名value字典中记录收发信息具体见示例仅支持租赁服与Apollo网络服环境不支持单机环境 |