2.6
This commit is contained in:
@@ -919,6 +919,50 @@ 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>
|
||||
|
||||
Reference in New Issue
Block a user