### Example Function File Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/BedrockWiki/commands/mcfunctions.md This example demonstrates a basic function file that applies regeneration, saturation, and weakness effects to players tagged with 'wiki:at_spawn'. ```mcfunction # These effects are for the spawn effect @a[tag=wiki:at_spawn] regeneration 12 255 true effect @a[tag=wiki:at_spawn] saturation 12 255 true effect @a[tag=wiki:at_spawn] weakness 12 255 true ``` -------------------------------- ### Install Latest Beta API Modules Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/BedrockWiki/scripting/scripting-intro.md Install specific beta versions of Minecraft Script API modules using npm. Ensure Node.js and npm are installed. ```bash npm i @minecraft/server@2.3.0-beta.1.21.114-stable npm i @minecraft/server-ui@2.1.0-beta.1.21.114-stable npm i @minecraft/server-gametest@1.0.0-beta.1.21.114-stable npm i @minecraft/server-admin@1.0.0-beta.1.21.114-stable npm i @minecraft/server-net@1.0.0-beta.1.21.114-stable npm i @minecraft/debug-utilities@1.0.0-beta.1.21.114-stable ``` -------------------------------- ### Give Command Examples for Item Properties Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/NeteaseGuide/mcguide/20-玩法开发/15-自定义游戏内容/1-自定义物品/1-自定义基础物品.md Examples of using the `/give` command to obtain items with specific NBT data, such as adventure placement/destruction, item locking, and keep-on-death properties. ```plaintext - 冒险放置:/give @s lever 1 0 {"minecraft:can_place_on":{"blocks":["stone", "grass"]}} - 冒险破坏:/give @s apple 1 0 {"minecraft:can_destroy":{"blocks":["stone", "grass"]}} - 无法移动:/give @s apple 1 0 {"minecraft:item_lock":{"mode":"lock_in_slot"}} - 无法丢弃:/give @s apple 1 0 {"minecraft:item_lock":{"mode":"lock_in_inventory"}} - 死亡不掉落:/give @s apple 1 0 {"minecraft:keep_on_death":{}} ``` -------------------------------- ### StartNavTo Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/玩家/导航.md Initiates a guided navigation system that uses visual cues (sprites) along the path to guide the player. It automatically re-navigates if the player deviates. ```APIDOC ## StartNavTo ### Description Implements a navigation system based on `GetNavPath` by generating sequential frames along the path to guide the player to the target point. It re-navigates if the player deviates from the path. ### Method `mod.client.extraClientApi.StartNavTo` ### Parameters #### Path Parameters - **pos** (tuple(float,float,float)) - Required - The coordinates of the target point. - **sfxPath** (str) - Required - The path to the sprite material used for the navigation path. - **callback** (function) - Required - A callback function invoked when the player reaches the destination. It accepts a boolean parameter. - **sfxIntl** (float) - Optional - The interval between adjacent sprites. Defaults to 2. - **sfxMaxNum** (int) - Optional - The maximum number of sprites displayed simultaneously. Defaults to 16. - **sfxScale** (tuple(float,float)) - Optional - The scaling of the sprites' width and height. Defaults to (0.5, 0.5). - **maxIteration** (int) - Optional - The maximum number of iterations for the A* pathfinding algorithm. Defaults to 800. - **isSwimmer** (bool) - Optional - Whether the target point is in water. Defaults to False. - **fps** (int) - Optional - The frame rate of the sprites. Defaults to 20, not recommended to exceed 30. - **playIntl** (int) - Optional - The interval between the start of adjacent sprites in a sequence. Defaults to 8 frames, must be non-negative. - **duration** (int) - Optional - The number of frames a single sprite is displayed. Defaults to 60 frames, must be at least 10. - **oneTurnDuration** (int) - Optional - The playback interval between two sequences of sprites (in frames). Defaults to 90 frames, must be at least 1.5 * duration. - **sfxDepthTest** (bool) - Optional - Whether depth testing is enabled for sprites. Defaults to False. ### Returns - **int** - Returns 0 for normal navigation start, -1 if the player is too far from the ground or blocked, 1 for invalid parameters, 2 if the player's chunk is not loaded, 3 if the destination is a solid block and cannot be navigated. ### Remarks - Similar to `GetNavPath`, `maxIteration` affects pathfinding accuracy and performance. - Navigation in water is performance-intensive. - The `callback` function receives a boolean: `True` indicates the player is near the destination (navigation may continue if player moves away), `False` indicates the player has deviated or cannot reach the destination, automatically terminating navigation. - Calling `StartNavTo` again before the previous navigation ends will overwrite the previous one. ``` -------------------------------- ### Start Client Performance Profile Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts client-side script performance profiling. Call StopProfile to generate a flame graph. Only supported on PC. ```python import mod.client.extraClientApi as clientApi clientApi.StartProfile() modfunc()# 处理对应的逻辑 # 之后通过计时器或者其他触发方式调用StopProfile clientApi.StopProfile() ``` -------------------------------- ### StartMemProfile (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/索引.md Starts server script memory profiling on the server. After starting, calling StopMemProfile will generate a function memory flame graph at the specified fileName. This interface only supports PC. ```APIDOC ## StartMemProfile Server ### Description Starts server script memory profiling on the server. After starting, calling StopMemProfile will generate a function memory flame graph at the specified fileName. This interface only supports PC. ### Method StartMemProfile ### Endpoint Server ### Parameters None explicitly defined in source. ### Request Example None explicitly defined in source. ### Response None explicitly defined in source. ``` -------------------------------- ### Button Mapping Example for Input Control Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/NeteaseGuide/mcguide/18-界面与交互/30-UI说明文档.md This example demonstrates how to use `button_mappings` to associate input button IDs with output actions. The `mapping_type` specifies when the mapping is active. ```json { "sample_button@common.button": { "$pressed_button_name": "button_id", "button_mappings": [ { "from_button_id": "button.menu_ok", "to_button_id": "$pressed_button_name", "mapping_type": "focused" }, { "from_button_id": "button.menu_select", "to_button_id": "$pressed_button_name", "mapping_type": "pressed" } ] } } ``` -------------------------------- ### Install CppJieba Source: https://github.com/github-zero123/mcdk-assistant/blob/main/libs/cppjieba/README.md Steps to clone the repository, initialize submodules, and build the project using CMake. ```sh git clone https://github.com/yanyiwu/cppjieba.git cd cppjieba git submodule init git submodule update mkdir build cd build cmake .. make make test ``` -------------------------------- ### Start Server Packet Recording Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts recording engine packet transmission between server and client. Call StopRecordPacket to get statistics. Only supported on leased servers and Apollo network servers. ```python import mod.server.extraServerApi as serverApi suc = serverApi.StartRecordPacket() # 之后通过计时器或者其他触发方式调用StopRecordPacket result = serverApi.StopRecordPacket() for packetName, data in result.iteritems(): print "packet[{}] send={} sendSize={} recv={} recvSize={}".format(packetName, data`["send_num"]`, data`["send_size"]`, data`["recv_num"]`, data`["recv_size"]`) ``` -------------------------------- ### Initialize QuMod Project Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/modMain.md Import all functionalities from QuModLibs.QuMod and create an EasyMod instance for convenient MOD building. Register server and client components. ```python from .QuModLibs.QuMod import * myMod = EasyMod() # 服务端与客户端注册 myMod.Server("Server") myMod.Client("Client") ``` -------------------------------- ### Start Server Event Recording Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts recording script event transmission between server and client. Call StopRecordEvent to get statistics. Only supported on leased servers and Apollo network servers. ```python import mod.server.extraServerApi as serverApi suc = serverApi.StartRecordEvent() # 之后通过计时器或者其他触发方式调用StopRecordEvent result = serverApi.StopRecordEvent() for eventName, data in result.iteritems(): print "event[{}] send={} sendSize={} recv={} recvSize={}".format(eventName, data`["send_num"]`, data`["send_size"]`, data`["recv_num"]`, data`["recv_size"]`) ``` -------------------------------- ### Get Fog Range Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/世界/渲染.md Retrieves the fog's start and end range as a tuple of two floats. This function is part of the FogCompClient component. ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateFog(levelId) start,end = comp.GetFogLength() ``` -------------------------------- ### Hybrid Project Implementation (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/HybridProject/NeteaseLoader.md Demonstrates how to create a hybrid server system that integrates QuMod components. This example shows registering a custom server system that listens for player attack events and binds a QuMod component to the victim entity. ```python from .QuModLibs.Server import * from .QuModLibs.Modules.EntityComps.Server import QBaseEntityComp ServerSystem = serverApi.GetServerSystemCls() # 由于和QuMod相关业务放在同一个文件 只需要注册一次System即可加载整个文件的其他业务 class MyServer(ServerSystem): def __init__(self, namespace, systemName): ServerSystem.__init__(self, namespace, systemName) mcNamespace, mcSystemName = serverApi.GetEngineNamespace(), serverApi.GetEngineSystemName() self.ListenForEvent(mcNamespace, mcSystemName, "PlayerAttackEntityEvent", self, self.PlayerAttackEntityEvent) def PlayerAttackEntityEvent(self, args={}): playerId = args["playerId"] victimId = args["victimId"] TEST_COMP().bind(victimId) # 为命中实体绑定QuMod组件 实现持续造成伤害 class TEST_COMP(QBaseEntityComp): def onBind(self): QBaseEntityComp.onBind(self) # 0.5s后自动解除组件 self.addTimer(QBaseEntityComp.Timer(lambda: self.unBind(), time=0.5)) def update(self): QBaseEntityComp.update(self) # 持续造成伤害 comp = serverApi.GetEngineCompFactory().CreateHurt(self.entityId) comp.Hurt(1, serverApi.GetMinecraftEnum().ActorDamageCause.EntityAttack, None, None, False) ``` -------------------------------- ### Get Block Entity Extra Uniforms (Client) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/方块/渲染.md Retrieves the values of custom shader uniforms used in a custom block entity. This allows for dynamic visual effects controlled by shader parameters. Note that the example incorrectly uses SetBlockEntityExtraUniforms when intending to get values. ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateBlockInfo(levelId) # 获取坐标位于(100,66,100)的自定义方块实体的自定义变量EXTRA_ACTOR_UNIFORM2的值 print comp.GetBlockEntityExtraUniforms((100,66,100), 2) # 获取坐标位于(100,66,101)的自定义方块实体的自定义变量EXTRA_ACTOR_UNIFORM4的值 print comp.SetBlockEntityExtraUniforms((100,66,101), 4) ``` -------------------------------- ### Get Entity Links Tag (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/实体/属性.md Retrieves a dictionary of entities linked to the current entity. For example, if the entityId is a horse, this will return information about the rider. ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateEntityDefinitions(entityId) result = comp.GetEntityLinksTag() ``` -------------------------------- ### Manual Management (Non-RAII) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/Modules/UI/QGridBinder.md Demonstrates manual control over QGridBinder's lifecycle using start() and stop() methods. ```python # Create 中 self.gridBinder = QGridBinder(self).setGridData( QGridData("/panel/grid", bindFunc=self.onRender) ).start() # Destroy 中 self.gridBinder.stop() ``` -------------------------------- ### StartCoroutine 服务端协程执行(函数) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/工具.md 开启服务端协程,实现函数分段式执行。通过传入函数来执行,函数将从头开始执行。协程执行完后可调用回调函数。 ```python import server.extraServerApi as serverApi def callback(): print "callback" def coroutineTest(): for i in xrange(1000): print i yield #传入函数,函数将从头开始执行 serverApi.StartCoroutine(coroutineTest, callback) ``` -------------------------------- ### MoLang Script for Sheep Entity Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/NeteaseGuide/mcguide/20-玩法开发/15-自定义游戏内容/3-自定义生物/01-自定义基础生物.md Example MoLang script for a sheep entity, defining animation states like 'setup', 'look_at_target', 'move', and 'baby_transform'. ```json "scripts": { "animate": [ "setup", "look_at_target", "move", { "baby_transform": "query.is_baby" } ] } ``` -------------------------------- ### StartCoroutine 客户端协程执行(函数) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/工具.md 开启客户端协程,实现函数分段式执行。通过传入函数来执行,函数将从头开始执行。协程执行完后可调用回调函数。 ```python import client.extraClientApi as clientApi def callback(): print "callback" def coroutineTest(): for i in xrange(1000): print i yield #传入函数,函数将从头开始执行 clientApi.StartCoroutine(coroutineTest, callback) ``` -------------------------------- ### StartRecordPacket (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts recording engine packet transmission between server and client. Only available in Apollo network server environments. Call StopRecordPacket to get statistics. ```APIDOC ## StartRecordPacket (Server) ### Description Starts recording engine packet transmission between server and client. Only available in Apollo network server environments. Call StopRecordPacket to get statistics. Not supported in standalone mode. ### Method serverApi.StartRecordPacket() ### Parameters None ### Response #### Success Response (bool) - Returns true if packet recording started successfully. ### Request Example ```python import mod.server.extraServerApi as serverApi suc = serverApi.StartRecordPacket() # ... your code ... result = serverApi.StopRecordPacket() for packetName, data in result.iteritems(): print "packet[{}] send={} sendSize={} recv={} recvSize={}".format(packetName, data['send_num'], data['send_size'], data['recv_num'], data['recv_size']) ``` ``` -------------------------------- ### Import All Dependencies Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/Modules/MultiplayerLobby/QuickLobbyManager.md Import all necessary modules from the QuickLobbyManager library. This is typically done at the beginning of your script. ```python from .QuModLibs.Modules.MultiplayerLobby.Server import * ``` -------------------------------- ### StartRecordEvent (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts recording script event transmission between server and client. Only available in Apollo network server environments. Call StopRecordEvent to get statistics. ```APIDOC ## StartRecordEvent (Server) ### Description Starts recording script event transmission between server and client. Only available in Apollo network server environments. Call StopRecordEvent to get statistics. Not supported in standalone mode. ### Method serverApi.StartRecordEvent() ### Parameters None ### Response #### Success Response (bool) - Returns true if event recording started successfully. ### Request Example ```python import mod.server.extraServerApi as serverApi suc = serverApi.StartRecordEvent() # ... your code ... result = serverApi.StopRecordEvent() for eventName, data in result.iteritems(): print "event[{}] send={} sendSize={} recv={} recvSize={}".format(eventName, data['send_num'], data['send_size'], data['recv_num'], data['recv_size']) ``` ``` -------------------------------- ### Get Shape Position Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/渲染.md Retrieves the position of a shape. For line and arrow shapes, this is the start position. For other shapes, it's the center position. This method is called on a shape object. ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateDrawing(levelId) box = comp.AddBoxShape((-37, 100, 100),(5,5,5),(1,0,0)) box.GetPos() ``` -------------------------------- ### StartCoroutine 服务端协程执行(生成器) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/工具.md 开启服务端协程,实现函数分段式执行。通过传入带有yield的函数或生成器来执行。协程执行完后可调用回调函数。 ```python import server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGame(serverApi.GetLevelId()) def callback(): print "callback" def coroutineTest(): for i in xrange(1000): print i yield generator = serverApi.StartCoroutine(coroutineTest, callback) #执行1秒后停止协程 comp.AddTimer(1.0, serverApi.StopCoroutine, generator) #5秒后传入StartCoroutine返回的生成器,则函数将从停止位置继续执行 comp.AddTimer(5.0, serverApi.StartCoroutine, generator, callback) ``` -------------------------------- ### StartRecordPacket Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/Api索引表.md Apollo: Starts recording engine packet send/receive statistics between server and client. Call StopRecordPacket to get statistics. Only supported in leased server and Apollo network server environments. ```APIDOC ## StartRecordPacket ### Description Apollo: Starts recording engine packet send/receive statistics between server and client. Call StopRecordPacket to get statistics. Only supported in leased server and Apollo network server environments. ### Method POST ### Endpoint /api/apollo/StartRecordPacket ``` -------------------------------- ### StartCoroutine 客户端协程执行(生成器) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/工具.md 开启客户端协程,实现函数分段式执行。通过传入带有yield的函数或生成器来执行。协程执行完后可调用回调函数。 ```python import client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateGame(clientApi.GetLevelId()) def callback(): print "callback" def coroutineTest(): for i in xrange(1000): print i yield generator = clientApi.StartCoroutine(coroutineTest, callback) #执行1秒后停止协程 comp.AddTimer(1.0, clientApi.StopCoroutine, generator) #执行5秒后传入StartCoroutine返回的生成器,则函数将从停止位置继续执行 comp.AddTimer(5.0, clientApi.StartCoroutine, generator, callback) ``` -------------------------------- ### StartRecordEvent Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/Api索引表.md Apollo: Starts recording script event send/receive statistics between server and client. Call StopRecordEvent to get statistics. Only supported in leased server and Apollo network server environments. ```APIDOC ## StartRecordEvent ### Description Apollo: Starts recording script event send/receive statistics between server and client. Call StopRecordEvent to get statistics. Only supported in leased server and Apollo network server environments. ### Method POST ### Endpoint /api/apollo/StartRecordEvent ``` -------------------------------- ### StartNavTo - Guided Navigation System Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/玩家/导航.md Initiates a guided navigation system that uses visual cues (sfxPath) to lead the player. It automatically re-navigates if the player deviates. The callback function is invoked upon reaching the destination or if navigation becomes impossible. ```python extraClientApi.StartNavTo(pos, sfxPath, callback, sfxIntl=2, sfxMaxNum=16, sfxScale=(0.5, 0.5), maxIteration=800, isSwimmer=False, fps=20, playIntl=8, duration=60, oneTurnDuration=90, sfxDepthTest=False) ``` -------------------------------- ### QuMod Calling NeServer Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/HybridProject/NeteaseLoader.md Illustrates how to call functions or systems from another module (NeServer). It differentiates between accessing singleton system methods and directly importing defined functions or non-system classes. ```python from .QuModLibs.Server import * def TestFunc(): # 对于单例系统方法 需要Get后再访问 systemNode = serverApi.GetSystem(...) systemNode.xxx() def TestFunc2(): # 对于定义出来的函数/非系统类 可以直接import from NeServer import xxx xxx() ``` -------------------------------- ### Get Entity Calculated Node Value on Client Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/实体/molang.md Retrieve the value of a specific entity calculated node on the client. If the node does not exist, the default value registered during its creation will be returned. The variableName must start with 'query.mod.'. ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateQueryVariable(entityId) result = comp.Get('query.mod.state') ``` -------------------------------- ### Initialize QuickLobbyManager Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/Modules/MultiplayerLobby/QuickLobbyManager.md Create and initialize a QuickLobbyManager instance. This includes setting up local debug mode and defining initial player memory data and event handlers. ```python from .QuModLibs.Modules.MultiplayerLobby.Server import * if serverApi.GetPlatform() != -1: # 自动检测 启用DEBUG模式 可以在单机环境下模拟调试(也可以用AUTO_DEBUG_MODE函数处理) BaseLobbyManager.LOCAL_DEBUG_MODE = True # BaseLobbyManager.LOCAL_SAVE_LEVEL = False @QuickLobbyManager.Init class MyManager(QuickLobbyManager): def initMemoryMap(self): # 分配初始化玩家数据 以便后续缓存映射 (所有需要映射操作的数据都应该在此处声明) return { "money": 100, "money2": 0, } def onPlayerMmpUpdate(self, playerId): QuickLobbyManager.onPlayerMmpUpdate(self, playerId) playerData = self.getPlayerAllMMPData(playerId) print("玩家数据更新: {} -> {}".format(playerId, playerData)) # 若有需要 可在此事件下同步玩家数据到客户端(当mmp数据改变时触发该事件) Call(playerId, "syncSerData", playerData) ``` -------------------------------- ### Get Entities In Square Area (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/世界/地图.md Fetches entity IDs within a defined square area on the server. The area is defined by start and end coordinates. The `entityId` parameter is deprecated. Note that block coordinates differ from entity coordinates. ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGame(levelId) comp.GetEntitiesInSquareArea(None, (0,0,0), (100,100,100), 0) ``` -------------------------------- ### Get JSON UI Full Stack Reference Source: https://context7.com/github-zero123/mcdk-assistant/llms.txt Obtains a comprehensive reference manual for MC JSON UI. It covers control types, layout systems, inheritance, data binding, Python counterparts, Netease template variables, and minimal working examples. ```json { "name": "get_jsonui_reference", "arguments": {} } ``` ```json // 手册包含最小完整示例(JSON UI + Python 类),如: // { // "namespace": "MY_UI", // "main": { // "type": "screen", "size": ["100%","100%"], // "controls": [ // { "bg": { "type": "image", "texture": "textures/ui/bg32", "alpha": 0.6 } }, // { "closeBtn@common.button": { // "size": ["4%y+0px","4%y+0px"], // "$pressed_button_name": "button.close", // "anchor_from": "top_right", "anchor_to": "top_right" // }} // ] // } // } ``` -------------------------------- ### StartMemProfile (Client) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts client-side script memory profiling. This interface is only supported on PC. ```APIDOC ## StartMemProfile (Client) ### Description Starts client-side script memory profiling. After starting, calling `StopMemProfile` will generate a function memory flame graph at the specified `fileName` path. This interface is only supported on PC. The generated flame graph can be opened in a browser, Chrome is recommended. ### Method clientApi.StartMemProfile() ### Returns - **bool** - The result of the execution. ### Remarks - Since the analysis does not distinguish between server and client, you only need to call `StartMemProfile` and `StopMemProfile` on one side (either server or client) for analysis; both sides do not need to perform it simultaneously. - Hovering the mouse over a function block will display detailed information for the current function below. Refer to "Obtaining Performance Analysis Flame Graphs" for specific meanings. ### Example ```python import mod.client.extraClientApi as clientApi clientApi.StartMemProfile() modfunc() # Process the corresponding logic # Later, call StopMemProfile via a timer or other trigger clientApi.StopMemProfile(fileName) ``` ``` -------------------------------- ### Get Model Reference (get_model_reference) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/plans/bedrock-model-mcp-tool-design.md Retrieves a concise reference guide for the geometry.json syntax, covering format versions, description fields, bone systems, cubes, locators, and common errors. Useful for AI to quickly understand the structure and rules of Bedrock JSON models. ```text 一、文件格式版本 1.12.0 / 1.16.0 的差异(per-face UV 支持) format_version 选择建议(网易版兼容性) 二、description 字段速查 identifier 命名规则(geometry.xxx.yyy) texture_width / texture_height visible_bounds_width / height / offset 三、bones 骨骼系统 parent 层级关系(树形结构) pivot [x,y,z] — 旋转轴心 rotation [x,y,z] — 默认旋转 mirror — UV水平镜像 binding — 骨骼绑定(高级) 四、cubes 立方体 origin / size / inflate 简单UV vs per-face UV 完整对比 UV 边界计算公式 五、locators 定位点 用途:特效/骨骼挂接点 格式:{ "name": [x, y, z] } 六、网易版特殊注意事项 format_version 推荐 1.12.0(兼容性最高) 与 render_controller 的配合方式 骨骼 binding 与 ModelComp API 的关系 七、常见错误 骨骼循环引用 UV超出贴图边界 cube size 小于1导致贴图黑块 ``` -------------------------------- ### Inter-module Communication: NeServer.py Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/HybridProject/QuModLoader.md Demonstrates how a native server system (`NeServer.py`) can interact with QuMod modules by directly importing and calling their functions and components. This example shows listening for player events and applying a QuMod component. ```python import mod.server.extraServerApi as serverApi from QMServer import TEST_FUNC, TEST_COMP # 所有的QuMod模块都可以直接import访问 ServerSystem = serverApi.GetServerSystemCls() class MyServer(ServerSystem): def __init__(self, namespace, systemName): ServerSystem.__init__(self, namespace, systemName) mcNamespace, mcSystemName = serverApi.GetEngineNamespace(), serverApi.GetEngineSystemName() self.ListenForEvent(mcNamespace, mcSystemName, "PlayerAttackEntityEvent", self, self.PlayerAttackEntityEvent) def PlayerAttackEntityEvent(self, args={}): playerId = args["playerId"] victimId = args["victimId"] TEST_FUNC(playerId) # 调用QMServer.py中的TEST_FUNC TEST_COMP().bind(victimId) # 为命中实体绑定QuMod组件 实现持续造成伤害 ``` -------------------------------- ### StartMemProfile (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts server-side script memory profiling. This interface is only supported on PC. ```APIDOC ## StartMemProfile (Server) ### Description Starts server-side script memory profiling. After starting, calling `StopMemProfile` will generate a function memory flame graph at the specified `fileName` path. This interface is only supported on PC. The generated flame graph can be opened in a browser, Chrome is recommended. ### Method serverApi.StartMemProfile() ### Returns - **bool** - The result of the execution. ### Remarks - Since the analysis does not distinguish between server and client, you only need to call `StartMemProfile` and `StopMemProfile` on one side (either server or client) for analysis; both sides do not need to perform it simultaneously. - Hovering the mouse over a function block will display detailed information for the current function below. Refer to "Obtaining Performance Analysis Flame Graphs" for specific meanings. ### Example ```python import mod.server.extraServerApi as serverApi serverApi.StartMemProfile() modfunc() # Process the corresponding logic # Later, call StopMemProfile via a timer or other trigger serverApi.StopMemProfile(fileName) ``` ``` -------------------------------- ### Install Latest Stable API Modules Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/BedrockWiki/scripting/scripting-intro.md Install the latest stable versions of Minecraft Script API modules using npm. Ensure Node.js and npm are installed. ```bash npm i @minecraft/server npm i @minecraft/server-ui ``` -------------------------------- ### StartMultiProfile (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts performance profiling for both server and client scripts. This interface is only supported on PC. ```APIDOC ## StartMultiProfile (Server) ### Description Starts performance profiling for both server and client scripts. After starting, calling `StopMultiProfile` will generate a function performance flame graph at the specified `fileName` path. Data collected from both ends during dual-end collection has significant errors; it is recommended to prioritize the single-end version `StartProfile`. This interface is only supported on PC. ### Method serverApi.StartMultiProfile() ### Returns - **bool** - The result of the execution. ### Example ```python import mod.server.extraServerApi as serverApi serverApi.StartMultiProfile() modfunc() # Process the corresponding logic # Later, call StopMultiProfile via a timer or other trigger serverApi.StopMultiProfile() ``` ``` -------------------------------- ### Simplest Usage (RAII Auto-Management) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/Modules/UI/QGridBinder.md Example of the simplest way to use QGridBinder with RAII for automatic lifecycle management. ```APIDOC ## Simplest Usage (RAII Auto-Management) ```python @ScreenNodeWrapper.autoRegister("myui.main") class MyUI(ScreenNodeWrapper): def __init__(self, namespace, name, param): ScreenNodeWrapper.__init__(self, namespace, name, param) self.dataList = ["A", "B", "C"] self.gridBinder = QGridBinder(self, QGridData( "/panel/grid", bindFunc=self.onRender )) def onRender(self, viewPath, index): # type: (str, int) -> None content = self.GetBaseUIControl(viewPath + "/content") if index < len(self.dataList): content.SetVisible(True, False) # Second parameter False! self.GetBaseUIControl(viewPath + "/content/label").asLabel().SetText( self.dataList[index] ) # Button bindings must be redone each time (reuse mechanism) self.gridBinder.setButtonClickHandler( viewPath + "/content/btn", lambda: self.onClick(index) ) else: content.SetVisible(False, False) # Hide excess cells def onClick(self, index): print("Clicked {}".format(index)) def Create(self): ScreenNodeWrapper.Create(self) # Auto start self.gridBinder.setGridDimension((1, len(self.dataList))) def Destroy(self): ScreenNodeWrapper.Destroy(self) # Auto stop ``` ``` -------------------------------- ### Part-of-Speech Tagging Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/libs/cppjieba/README.md Example of part-of-speech tagging for a given sentence. ```text 我是蓝翔技工拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上总经理,出任CEO,迎娶白富美,走上人生巅峰。 ["我:r", "是:v", "拖拉机:n", "学院:n", "手扶拖拉机:n", "专业:n", "的:uj", "。:x", "不用:v", "多久:m", ",:x", "我:r", "就:d", "会:v", "升职:v", "加薪:nr", ",:x", "当上:t", "CEO:eng", ",:x", "走上:v", "人生:n", "巅峰:n", "。:x"] ``` -------------------------------- ### Keyword Extraction Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/libs/cppjieba/README.md Example of keyword extraction from a given text. ```text 我是拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上CEO,走上人生巅峰。 ["CEO:11.7392", "升职:10.8562", "加薪:10.6426", "手扶拖拉机:10.0089", "巅峰:9.49396"] ``` -------------------------------- ### Example Material Configuration Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/NeteaseGuide/mcguide/16-美术/7-材质与着色器/3-材质配置说明.md Configuration for a material, specifying shader paths, enabled defines, sampler states, and rendering states like blending. ```json "mat_example": { "vertexShader": "shaders/glsl/mat_example.vertex", "fragmentShader": "shaders/glsl/mat_example.fragment", "+defines": [ "USE_SKINNING", "USE_OVERLAY", "NETEASE_SKINNING" ], "+samplerStates": [ { "samplerIndex": 0, "textureFilter": "Point" } ], "states": [ "Blending", "DisableDepthWrite" ] } ``` -------------------------------- ### HMMSegment Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/libs/cppjieba/README.md Example output of the HMMSegment word segmentation method. ```text 我来到北京清华大学 我来/到/北京/清华大学 他来到了网易杭研大厦 他来/到/了/网易/杭/研大厦 小明硕士毕业于中国科学院计算所,后在日本京都大学深造 小明/硕士/毕业于/中国/科学院/计算所/,/后/在/日/本/京/都/大/学/深/造 ``` -------------------------------- ### MPSegment Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/libs/cppjieba/README.md Example output of the MPSegment word segmentation method. ```text 我来到北京清华大学 我/来到/北京/清华大学 他来到了网易杭研大厦 他/来到/了/网易/杭/研/大厦 小明硕士毕业于中国科学院计算所,后在日本京都大学深造 小/明/硕士/毕业/于/中国科学院/计算所/,/后/在/日本京都大学/深造 ``` -------------------------------- ### StartMemProfile (Client) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/Api索引表.md Client-side: Starts profiling script memory. Call StopMemProfile to generate a flame graph. Only supported on PC. ```APIDOC ## StartMemProfile (Client) ### Description Client-side: Starts profiling script memory. Call StopMemProfile to generate a flame graph. Only supported on PC. ### Method POST ### Endpoint /api/client/StartMemProfile ### Parameters #### Request Body - **fileName** (string) - Required - The path to save the flame graph. ``` -------------------------------- ### FullSegment Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/libs/cppjieba/README.md Example output of the FullSegment word segmentation method, which segments all dictionary words. ```text 我来到北京清华大学 我/来到/北京/清华/清华大学/华大/大学 他来到了网易杭研大厦 他/来到/了/网易/杭/研/大厦 小明硕士毕业于中国科学院计算所,后在日本京都大学深造 小/明/硕士/毕业/于/中国/中国科学院/科学/科学院/学院/计算/计算所/,/后/在/日本/日本京都大学/京都/京都大学/大学/深造 ``` -------------------------------- ### StartMemProfile (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/Api索引表.md Server-side: Starts profiling script memory. Call StopMemProfile to generate a flame graph. Only supported on PC. ```APIDOC ## StartMemProfile (Server) ### Description Server-side: Starts profiling script memory. Call StopMemProfile to generate a flame graph. Only supported on PC. ### Method POST ### Endpoint /api/server/StartMemProfile ### Parameters #### Request Body - **fileName** (string) - Required - The path to save the flame graph. ``` -------------------------------- ### Minimal Usage with RAII Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/Modules/UI/QGridBinder.md Demonstrates the simplest way to use QGridBinder with automatic resource management via ScreenNodeWrapper.autoRegister. ```python @ScreenNodeWrapper.autoRegister("myui.main") class MyUI(ScreenNodeWrapper): def __init__(self, namespace, name, param): ScreenNodeWrapper.__init__(self, namespace, name, param) self.dataList = ["A", "B", "C"] self.gridBinder = QGridBinder(self, QGridData( "/panel/grid", bindFunc=self.onRender )) def onRender(self, viewPath, index): # type: (str, int) -> None content = self.GetBaseUIControl(viewPath + "/content") if index < len(self.dataList): content.SetVisible(True, False) # 第二参数 False! self.GetBaseUIControl(viewPath + "/content/label").asLabel().SetText( self.dataList[index] ) # 按钮绑定必须每次重做(复用机制) self.gridBinder.setButtonClickHandler( viewPath + "/content/btn", lambda: self.onClick(index) ) else: content.SetVisible(False, False) # 隐藏多余格子 def onClick(self, index): print("点击 {}".format(index)) def Create(self): ScreenNodeWrapper.Create(self) # 自动 start self.gridBinder.setGridDimension((1, len(self.dataList))) def Destroy(self): ScreenNodeWrapper.Destroy(self) # 自动 stop ``` -------------------------------- ### MixSegment Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/libs/cppjieba/README.md Example output of the MixSegment word segmentation method, which combines MP and HMM. ```text 我来到北京清华大学 我/来到/北京/清华大学 他来到了网易杭研大厦 他/来到/了/网易/杭研/大厦 小明硕士毕业于中国科学院计算所,后在日本京都大学深造 小明/硕士/毕业/于/中国科学院/计算所/,/后/在/日本京都大学/深造 ``` -------------------------------- ### QuerySegment Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/libs/cppjieba/README.md Example output of the QuerySegment word segmentation method, using Mix followed by Full for longer words. ```text 我来到北京清华大学 我/来到/北京/清华/清华大学/华大/大学 他来到了网易杭研大厦 他/来到/了/网易/杭研/大厦 小明硕士毕业于中国科学院计算所,后在日本京都大学深造 小明/硕士/毕业/于/中国/中国科学院/科学/科学院/学院/计算所/,/后/在/中国/中国科学院/科学/科学院/学院/日本/日本京都大学/京都/京都大学/大学/深造 ``` -------------------------------- ### StartMultiProfile (Client) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/通用/调试.md Starts performance profiling for both server and client scripts. This interface is only supported on PC. ```APIDOC ## StartMultiProfile (Client) ### Description Starts performance profiling for both server and client scripts. After starting, calling `StopMultiProfile` will generate a function performance flame graph at the specified `fileName` path. Data collected from both ends during dual-end collection has significant errors; it is recommended to prioritize the single-end version `StartProfile`. This interface is only supported on PC. ### Method clientApi.StartMultiProfile() ### Returns - **bool** - The result of the execution. ### Example ```python import mod.client.extraClientApi as clientApi clientApi.StartMultiProfile() modfunc() # Process the corresponding logic # Later, call StopMultiProfile via a timer or other trigger clientApi.StopMultiProfile() ``` ``` -------------------------------- ### Create a Standard UI Interface Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/自定义UI/通用.md Creates a standard UI interface. This example demonstrates registering a UI and then creating it with the isHud parameter set to 1, suitable for HUD elements. It also shows how to retrieve the created UI node. ```python import mod.client.extraClientApi as clientApi from mod_log import logger as logger # 监听引擎初始化完成事件,在这个事件后创建我们的战斗UI def OnUIInitFinished(self, args): logger.info("OnUIInitFinished : %s" % args) # 注册UI 详细解释参照《UI API》 clientApi.RegisterUI(modConfig.ModName, modConfig.FpsBattleUIName, modConfig.FpsBattleUIPyClsPath, modConfig.FpsBattleUIScreenDef) # 创建普通UI界面 clientApi.CreateUI(modConfig.ModName, modConfig.FpsBattleUIName, {"isHud" : 1}) # 获取创建的UI界面 self.mFpsBattleUINode = clientApi.GetUI(modConfig.ModName, modConfig.FpsBattleUIName) if self.mFpsBattleUINode: self.mFpsBattleUINode.Init() ``` -------------------------------- ### Get Camera Pitch Limit Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/ModAPI/接口/玩家/摄像机.md Gets the limits for the camera's vertical (pitch) angle. Returns a tuple of (min_pitch, max_pitch). ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateCamera(levelId) comp.GetCameraPitchLimit() ``` -------------------------------- ### Inter-Module Communication Example (Server) Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/QuModDocs/QuModLibs/HybridProject/NeteaseLoader.md Shows how to define a server-side component (TEST_COMP) that binds to an entity and performs actions like applying damage over time. It also includes a placeholder function TEST_FUNC. ```python from .QuModLibs.Server import * from .QuModLibs.Modules.EntityComps.Server import QBaseEntityComp def TEST_FUNC(entityId): print("这是个空函数: {}".format(entityId)) class TEST_COMP(QBaseEntityComp): def onBind(self): QBaseEntityComp.onBind(self) # 0.5s后自动解除组件 self.addTimer(QBaseEntityComp.Timer(lambda: self.unBind(), time=0.5)) def update(self): QBaseEntityComp.update(self) # 持续造成伤害 comp = serverApi.GetEngineCompFactory().CreateHurt(self.entityId) comp.Hurt(1, serverApi.GetMinecraftEnum().ActorDamageCause.EntityAttack, None, None, False) ``` -------------------------------- ### Python Binding Function Example Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/NeteaseGuide/mcguide/18-界面与交互/70-UI数据绑定.md Example of a Python binding function decorated with '@ViewBinder.binding'. It returns a string and is associated with the binding name '#my_python_binding'. ```python @ViewBinder.binding(ViewBinder.BF_BindString, '#my_python_binding') def ReturnMyStr(self): return self.someText ``` -------------------------------- ### Set Delayed Start for Playback Source: https://github.com/github-zero123/mcdk-assistant/blob/main/knowledge/NeteaseGuide/mcguide/16-美术/9-特效/70-中国版特效属性详细说明.md Controls the delay in seconds before a sequence frame effect starts playing. Defaults to 0.0 for immediate playback. ```json { "delay": 10.0 } ```