df-replay
all projectsA Go library for recording and replaying Minecraft Bedrock gameplay on Dragonfly servers.
Recording and replaying Minecraft gameplay
df-replay is an open-source Go library for recording actions on Dragonfly Minecraft Bedrock servers and replaying them in a game world. It captures player and entity activity, block changes, sounds, and particles, with controls for pausing, rewinding, fast-forwarding, and changing playback speed.
Get started
Add the library to a Go project:
go get github.com/akmalfairuz/df-replay
The repository includes recording and playback examples. The recording example saves an action stream to a file; the playback example loads it and provides in-game replay controls.
Technical implementation
The library uses Dragonfly handlers and packet interception to capture gameplay as a timeline of actions indexed by server tick. Recorded actions cover player movement and appearance, entity lifecycle changes, block updates, and audiovisual events.
Movement and state changes have dedicated action types, including delta movement records. Playback reconstructs recorded players and entities and applies the corresponding updates to the replay world.
Action streams use Gophertunnel's binary protocol reader and writer, with Zstandard compression for storage. The recorder saves the tick-indexed stream, and the data loader decompresses it and rebuilds the action timeline.
Playback applies actions through Dragonfly world transactions. Reverse handlers restore earlier state for rewind and reverse playback, while pause, resume, seeking, and speed controls let a viewer inspect a recorded session at different points in time.
Source
Explore the source code and examples. df-replay is available under the MIT license.