What is Bob?

Bob is the first Replay Editor for the ReplayMod, a Minecraft mod to create videos such as timelapses or cinematics.
As Bob features it's own specialized and custom scripting language, only the sky is the limit.

So far, Bob is only available as a Lite version, as the custom scripting language hasn't been implemented yet.
This Lite version works on all Minecraft versions supported by the ReplayMod and can:

GitHub Repository

History:

Bob started out as an experiment. I wanted to see if it was possible to change a username in a Replay.
It turned out to be possible, but I wanted to do more.
Replays are just a dump of the entire communication between the server and the client.
The ReplayMod then emulated a Minecraft server to replay the communication, so we can see what happened.

How it works:

As I previously said, Replays are just a dump of the client-server communication.
What Bob edits is those network packets directly.

Let's use a real example so you know how it works, so let's change the time on a 1.18.2 Replay.
To understand how to change the time, we have to understand how the time is sent to the client.
As it turns out, the server is sending a Time Packet. Here is its format:

        +-----------------------------------------+
        |       Packet ID: 0x59 (89 decimal)      |
        +-------------+------+--------------------+
        |     Name    | Type |     Description    |
        +-------------+------+--------------------+
        | World Age   | Long | World age in ticks |
        +-------------+------+--------------------+
        | Time of Day | Long | The time in ticks  |
        +-------------+------+--------------------+
                
The time of day is exactly what we want to edit, and we know how much bytes it takes (a long is stored on 8 bytes, and it's also defined in the Data Types section of wiki.vg)
Those Time Update packets are sent every 20 ticks.

Let's look at it's data in a hex editor:


With ImHex, I can highlight certain block of data to make reading hexadecimal data easier:


Let's see what those values mean.
When highlighting the first 8 bytes (the world age) and telling ImHex to treat the data as big endian, we get this:


A long is 64 bits, so the value we get from uint64_t is 112800 (uint64_t stands for "unsigned 64 bit integer type"). 112800 ticks corresponds to 94 mins.
Now let's check the second set of 8 bytes (the time of day in ticks), we get this:


This value has to be treated as a signed number, so we have to look at int64_t. Its value is -18000 ticks.
As we can see, this value is negative. This means the sky won't automatically move for 20 ticks.
This is used when the doDaylightCycle gamerule is set to false.

Now, if you tell Bob to edit the time in a Replay, the steps it'll follow are as followed: Instead of hardcoding those steps, I created a structure language, to tell Bob how to read and write packets.
This is the structure of the time update packet:
        packet "time_update" {
            long "world_age";
            long "time_of_day";
        }
                
This Packet Structure Language file (neatly called PSL) is fed into a Lexer that will generate a list of Token while doing some error checking.

After that, the list of token is fed into a Validator that will do further error checking such as type checking and variable scope analysis.

If the validator found no issues, the list of tokens is then fed into a PacketDefinitionFactory that will convert the list of tokens into a parse tree (a PacketDefinition in my code). The Validator and the PacketDefinitionFactory form what's called a Parser.

This definition is an intermediary between the PSL file and the values Bob will edit. The definition will be used in the PacketDeserializer to turn the bytes to a format Bob can understand and edit, and in the PacketSerializer to write the bytes from the format Bob can understand.

With this, if you tell Bob to edit the "time_of_day" value of a "time_update" packet, it'll know what to edit, and how.
With this technique, it's also very easy to update Bob to a new Minecraft protocol when a new version releases. Everything is hand-made and no libraries are used.