Replay FPS
这其实应该叫“Replay FPV”,但我当时是在想第一人称射击游戏(FPS)
简介
Replay Mod 是 Minecraft: Java Edition 的一款流行模组,允许你录制游戏过程以供后续回放。虽然 Replay Mod 功能强大,但在第一人称视角的回放方面存在严重不足。
默认情况下,当你以玩家的第一人称视角渲染回放时,画面会显得极其卡顿。这是因为 Minecraft 每秒仅更新玩家位置 10 次,因此游戏必须对缺失的数据进行插值处理。
本插件旨在解决这一问题。
通过将客户端摄像机数据与主要回放数据一起存储,可以更详细地捕捉本地客户端的移动轨迹,从而带来更好的第一人称回放体验。
使用方法
除了正常的 Replay Mod 功能外,本插件没有提供任何面向用户的其他操作。只需将其与 Replay Mod 一起安装并正常使用即可。但请注意,本插件提供的增强效果仅适用于录制回放的玩家,且该玩家在录制时必须已安装此插件。
注意:在当前版本(0.2.0)中,必须安装 Mod Menu 才能访问配置菜单。
技术细节
客户端捕获
通常情况下第一人称移动看起来如此糟糕的原因是,Replay Mod 仅记录服务器和客户端之间通信的游戏数据包。在大多数情况下,这与实时观察游戏的效果相同。然而,在涉及第一人称视角时,服务器发送的数据不足以准确还原原始移动轨迹。事实上,这也是为什么在原版游戏中观战其他玩家会导致同样的卡顿现象的原因。
解决方案是在数据包流旁边存储一个额外的数据流。该数据流由一系列通道组成,每个通道都以恒定的采样率保存连续的值。这些通道在捕获时由客户端直接写入,完全绕过了服务器-客户端数据包系统。这不仅允许以比数据包更高的速率捕获样本,还使得能够捕获原本不会与服务器同步的数据。
为了以合理的方式存储这些数据量较大的信息,我们开发了一种自定义的二进制格式。当使用此插件录制回放时,会在回放存档中插入一个“客户端捕获”(ccap)文件,与数据包数据并存。该文件的规范可在本仓库中找到。
数据包
然而,并非所有数据都适合存储在连续流中。离散形式的数据(例如快捷栏内容的变化)被存储为自定义数据包,并注入到回放数据包流中。这些所谓的“伪造数据包”在录制时被序列化为 PacketByteBuf,但并未发送给服务器,而是保存在本地的回放文件中。在回放过程中,Replay Mod 会将这些伪造数据包作为普通数据包返回给 Minecraft,由自定义处理器解析并将其应用到世界中。
除了伪造数据包之外,还可以注册“数据包重定向器”来覆盖原版数据包在回放期间的应用方式。这使得许多通常在回放中无法使用的数据包得以解析并应用于重建原始客户端体验。
构建项目
与大多数模组一样,要构建此项目,只需打开控制台进入根目录并输入 ./gradlew build。但是,由于缺少名为 'CraftFX' 的依赖项,构建可能会失败。这是 ccap_viewer 子项目的依赖项,目前该项目与主项目一起构建。要解决此问题,请克隆并构建 CraftFX,并将其发布到 Maven Local。
Replay FPS
Which should really be called "Replay FPV" but I was thinking of first-person shooters at the time
About
The Replay Mod is a popular modification for Minecraft: Java Edition which allows you to capture gameplay for subsequent playback. While the Replay Mod is very powerful, it's severely lacking when it comes to first-person gameplay.
By default, when you render a replay from the first-person perspective of a player, the view appears extremely sluggish. This is due to the fact that Minecraft only properly updates player positions 10 times per second, so the game must interpolate the missing data.
This addon aims to fix this.
By storing client-side camera data alongside the primary replay data, the movements of the local client can be captured in greater detail, leading to a much better first-person playback experience.
Usage
This addon doesn't contain any user-facing usage beyond the normal Replay Mod stuff. Simply install it alongside the replay mod and use it as normal. Keep in mind, however, that the enhancements provided by this addon will only ever apply to the player that recorded the replay, and only if that player had this addon installed while recording.
Note: In the current build (0.2.0), Mod Menu must be installed to access the config menu.
Technical
Client-Capture
The reason that first-person movement looks so bad normally is that the Replay Mod only records the game packets communicated between the server and client. In most cases, this looks identical to observing the game in real-time. However, when it comes to first-person views, the server doesn't send enough data to accurately recreate the original movement. In fact, this is why spectating another player in Vanilla results in the same type of slushiness.
The solution is store an additional stream of data alongside the packet stream. This stream is comprised of a series of channels, each holding a continuous value at a constant sample rate. These channels are written to directly by the client at capture time, bypassing the server-client packet system entirely. Not only does this allow for samples to be captured at a much higher rate than would be possible with packets, but it also enables data to be captured that isn't normally synced with the server in the first place.
In order to store this sizeable data in a realistic way, a custom binary format was developed. When a replay is captured using this addon, a "client-capture" (ccap) file is inserted into the replay archive alongside the packet data. The specification of this file can be found in this repo.
Packets
Some data, however, doesn't make sense to store in a continuous stream. Discrete forms of data, as changes to the hotbar contents, are stored as custom packets that are injected into the replay packet stream. These so called "fake packets" get serialized to a PacketByteBuf at recording time, but instead of being sent to the server, they get saved into the replay file locally. During playback, the Replay Mod then serves these fake packets back to Minecraft as a normal packet, where a custom handler can parse and apply them to the world.
In addition to fake packets, "packet redirectors" can be registered to override how a vanilla packet gets applied during playback. This allows numerous packets, which are normally unusable during a replay, to be parsed and applied towards reconstructing the original client experience.
Building
Like most mods, to build this project, simply open a console to the root directory and enter ./gradlew build. However, it's possible that the build will fail due to a missing dependency called 'CraftFX'. This is a dependency of the ccap_viewer subproject which, as of now, is built alongside the main project. To fix this, clone and build CraftFX, and publish it to Maven Local.
评论 0
登录后参与评分
还没有评论,来抢沙发吧