Files
netease-bedrock-wiki/mcguide/27-手机网络游戏/课程8:性能优化/第3节:快速切服.md
2025-07-31 17:53:14 +08:00

84 lines
3.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

---
front:
hard: 进阶
time: 20分钟
---
# 快速切服
### 应用场景
不同服务器之间跳转时,需要消耗一段等待时间。对于需要频繁切服的游戏类型(例如小游戏),快速切服具有重要的意义。
Apollo为以下两类跳转提供了快速切服方案。
### 跳转的服务器具有相同的mod
应用场景举例假设该游戏具有两类game服gameA、gameB部署了相同的插件。需要实现gameA到gameA或gameA到gameB之间的快速切服。
详见接口介绍:
<a href="../../../mcdocs/1-ModAPI/接口/通用/调试.html#setkeepresourcewhentransfer" rel="noopenner"> SetKeepResourceWhenTransfer </a>
<a href="../../../mcdocs/1-ModAPI/接口/通用/调试.html#getkeepresourcewhentransfer" rel="noopenner"> GetKeepResourceWhenTransfer </a>
### 跳转的服务器具有不同的mod
#### 方案1使用SetResourceFastload
设置资源快速加载,在进入游戏时快速加载资源,没有不同服资源一致的前提限制,但是速度没有使用`SetKeepResourceWhenTransfer`那么快
应用前提物品和方块的自定义贴图需要定义在item_texture.json和terrain_texture.json中
详见接口介绍:
<a href="../../../mcdocs/1-ModAPI/接口/通用/调试.html#setresourcefastload" rel="noopenner"> SetResourceFastload </a>
<a href="../../../mcdocs/1-ModAPI/接口/通用/调试.html#getresourcefastload" rel="noopenner"> GetResourceFastload </a>
#### 方案2使用SetKeepResourceWhenTransfer
合并不同服的资源,并把合并后的资源包部署到所有服,使得不同服的资源包一致,达到`SetKeepResourceWhenTransfer`的前提条件
应用前提:不同服务器之间,对原版资源的修改保持一致。(例如原生界面调整,自定义天空盒、太阳、月亮)
应用场景举例假设该游戏具有两类game服gameA部署了官方neteaseGuild插件gameB部署了官方neteaseAppear插件大厅服没有加载插件。需要实现三者之间的快速切服。
- 步骤1右键点击需要快速切服功能的服务器弹出菜单后选择“应用快速切服”
#### ![](./images/quick04.png)
- 步骤2选择应用快切之后的服务器命名将点击“应用快速切服”将生成快切网络。
![](./images/quick01.png)
- 步骤3新生成的快切网络服中大厅服、游戏服将额外生成一个commonRes的Mod并自动勾选。
![](./images/quick03_1.png)
![](./images/quick03_2.png)
![](./images/quick03_3.png)
- 步骤4调用接口<a href="../../../mcdocs/1-ModAPI/接口/通用/调试.html#setkeepresourcewhentransfer" rel="noopenner"> SetKeepResourceWhenTransfer </a>,完成快速切服设置。
- 步骤5部署完成后该网络服将拥有快速切服功能。
特别说明:
- 此方案应用的快速切服将改变原有网络服的mod结构建议在新生成的mod上完成开发调试。
- 应用快速切服实质上是对原有的mod的资源包进行合并。举例说明合并规则modA的资源包路径为modA/resource_packs/modAResmodB资源包路径为modB/resource_packs/modBRes这两部分合并到commonRes/resource_packs目录下。
- 合并过程中如果存在相对路径一样的文件如modA/resource_packs/modARes/textures/blocks/a.jpg和modB/resource_packs/modBRes/textures/blocks/a.jpg这部分资源将合并失败并在日志窗口进行报错提示。