Server Replay

repository·26.2·Indexed 41 days ago

https://github.com/senseiwells/serverreplay

A server-side implementation of Replay Mod and Flashback that allows administrators to record players and chunks without requiring client-side mods. It supports multi-POV player recording, customizable static chunk recording, and server-side playback. Compatible with Replay Mod and Flashback formats, it features automated recording via predicates and configurable chunk recording strategies.

Tokens
8.8K
Snippets
31
Records
39
Agent score
50%

What's inside Server Replay

  1. Overview of Server Replay

    26.2

    Server Replay is a server-side implementation of the Replay Mod and Flashback. It allows server administrators to record multiple online players or specific chunk areas directly on the server. The resulting replay files are compatible with the Replay Mod or Flashback for rendering.

    Key Capabilities

    Chunk Recording

    • Customizable Size: Record static chunks with exact sizes, independent of the server's view distance.
    • Stability: Recorded chunks are not affected by unloading, preventing chunk flickering.
    • Efficiency: Chunks are not loaded by the recorder itself (unlike PCRC).
    • Control: Recorders can be paused or resumed based on player presence or chunk loading status.

    Player Recording

    • No Client Requirements: Players do not need to have Replay Mod or Flashback installed.
    • Multi-POV: Record all player points-of-view simultaneously.
    • Automation: Recordings can be automated via configuration.
    • On-demand: Operators (or authorized users) can start recordings at any time.

    Limitations and Considerations

    • Feature Gaps: Some features, such as custom boss bars, are not captured in chunk recordings.
    • Consistency: Player recordings might not perfectly match the client-side Replay Mod or Flashback experience.
    • Mod Compatibility: Not designed for heavily modded environments. Complex mods that implement custom packets may cause compatibility issues.
  2. Advantages of Server-Side Recording

    26.2

    Recording on the server side instead of the client side offers several benefits:

    Chunk Recording

    • Fixed Chunk Sizes: You can specify exact chunk sizes regardless of the server's view distance.
    • Stable Unloading: Recorded chunks can be unloaded without causing flickering (which occurs during chunk loading/unloading) and without being re-loaded by the recorder (unlike PCRC).
    • Smart Pausing: The recorder can be paused or resumed based on whether chunks are loaded or if players are present within them.

    Player Recording

    • No Client Requirements: Players do not need to have Replay Mod or Flashback installed.
    • Multi-Perspective: You can record all player perspectives at once.
    • Automation: Recording can be automated via configuration.

    Administrative Control

    • On-Demand: Administrators (or authorized users) can start recordings at any time.
  3. Record players on the server

    26.2

    You can record a player's perspective by following them. The recording is bound to the player and follows the server's render distance. If the player leaves or the server stops, the recording is automatically saved.

    Commands:

    • /replay start players <player>: Start recording a specific player (e.g., /replay start players senseiwells, /replay start players @a).
    • /replay stop players <player> <save?>: Manually stop recording. Use false to cancel saving (e.g., /replay stop players senseiwells false).

    Storage: Files are saved to the directory specified by player_recording_path under a folder named after the player's UUID. Default path: ./recordings/players/<uuid>/<date-and-time>.mcpr.

    Viewing: Move the .mcpr file to your client's ./replay_recordings folder to open it with Replay Mod.

    # Example: Start recording a specific player
    /replay start players senseiwells
    
    # Example: Stop and save recording
    /replay stop players senseiwells
    
    # Example: Stop without saving
    /replay stop players senseiwells false
  4. Record chunks on the server

    26.2

    Chunk recording captures a fixed area of the world. These recordings are stationary and do not move.

    Important Note on Visibility: Minecraft clients do not render the outermost chunks of a recorded area. To ensure a visible area is fully captured, you must select one extra chunk beyond the desired boundary (e.g., to record from -5,-5 to 5,5, record from -6,-6 to 6,6).

    Commands:

    • /replay start chunks from <chunkFromX> <chunkFromZ> to <chunkToX> <chunkToZ> in <dimension> named <name>: Record a rectangular area.
    • /replay start chunks around <chunkX> <chunkZ> radius <radius> in <dimension> named <name>: Record an area around a center chunk.
    • /replay stop chunks named <name> <save?>: Stop a specific chunk recording by its name.

    Behavior: When recording starts, the specified chunks are loaded (and generated if necessary). After that, the recorder will not manually load them unless they fall within the chunk_recorder_load_radius configured in config.json.

    Storage: Files are saved to the directory specified by chunk_recording_path under a folder named after the recording's name. Default path: ./recordings/chunks/<name>/<date-and-time>.mcpr.

    # Example: Record a rectangular area
    /replay start chunks from -5 -5 to 5 5 in minecraft:overworld named MyChunkRecording
    
    # Example: Record around a center with radius
    /replay start chunks around 0 0 radius 5
    
    # Example: Stop a named recording
    /replay stop chunks named "Perimeter Recorder" false
  5. View replays server-side

    26.2

    You can view replays directly on the server. When viewing, the player is treated as offline and is moved to a separate asynchronous 'server' that sends packets to the client, minimizing performance impact.

    To view a replay, click the green text in chat after a recording finishes, or use the following commands:

    • /replay view chunks <name> <date-time>
    • /replay view players <uuid> <date-time>

    Playback Controls:

    • /replay view pause / /replay view unpause
    • /replay view speed <multiplier>
    • /replay view restart
    • /replay view close (returns you to the main server)
    • /replay view progress <hide|show> (toggles the progress bossbar)
    /replay view player "d4fca8c4-e083-4300-9a73-bf438847861c" "2024-05-11--19-19-55"
    /replay view chunks "Chunks (183, 166) to (203, 186)" "2024-05-11--19-19-55"
  6. View recordings on the server

    26.2

    You can watch recordings directly on the server. When viewing, you are treated as an offline player and are temporarily removed from the actual server. This runs on a separate asynchronous process with minimal performance impact.

    Commands to start viewing:

    • /replay view chunks <name> <date-time>
    • /replay view players <uuid> <date-time>

    Commands available while viewing:

    • /replay view pause: Pause playback.
    • /replay view unpause: Resume playback.
    • /replay view speed <multiplier>: Set playback speed.
    • /replay view restart: Restart the recording.
    • /replay view close: Stop viewing and return to the server.
    • /replay view progress <hide|show>: Toggle the progress Boss bar.
    # Example: View a player recording
    /replay view player "d4fca8c4-e083-4300-9a73-bf438847861c" "2024-05-11--19-19-55"
    
    # Example: View a chunk recording
    /replay view chunks "MyChunkRecording" "2024-05-11--19-19-55"
  7. Record static chunk areas

    26.2

    To record a specific area of chunks, you can use either a coordinate range or a radius around a center chunk.

    Important: To ensure the outermost chunks are visible in the replay, you must add one chunk to your border (e.g., to record a visible area from -5 to 5, record from -6 to 6).

    Chunk Loading: When a recorder starts, it loads the specified chunks (and generates them if needed). After the initial load, it does not continuously load them unless configured via chunk_recorder_load_radius or chunk_recording_strategy.

    Manual Stop: Use /replay stop chunks named <name> <save?> to stop a named recorder.

    Storage: Files are saved to the location defined by chunk_recording_path. By default, this is ./recordings/chunks/<name>/<date-and-time>.mcpr.

    # By coordinate range
    /replay start chunks from -5 -5 to 5 5 in minecraft:overworld named MyChunkRecording
    
    # By radius around a chunk
    /replay start chunks around 0 0 radius 5
    
    # Stop by name
    /replay stop chunks named "Perimeter Recorder" false
  8. Configure replay encoding (Flashback vs Replay Mod)

    26.2

    ServerReplay supports both flashback and replay_mod formats. By default, it uses replay_mod. You can change the default encoding for all new recordings using the /replay encoding default set <encoding-type> command.

    Note: You can record a player's perspective using both formats simultaneously by starting one recording with the default set to flashback, then changing the default to replay_mod and starting a second recording.

    /replay encoding default set flashback
    /replay encoding default set replay_mod
  9. Download replays from the server

    26.2

    If allow_downloading_replays is enabled in the config and replay_server_ip is correctly set, users can retrieve a download URL for a replay.

    Use the /replay download command followed by the player UUID/name or chunk name and the date-time string. The command will provide a clickable link in chat.

    /replay download players d4fca8c4-e083-4300-9a73-bf438847861c "2024-05-11--19-19-55"
    /replay download chunks "Chunks (183, 166) to (203, 186)" "2024-05-11--19-19-55"
  10. Optimize replay file size

    26.2

    To reduce the storage footprint of your replays, consider using the following optimization settings:

    • ignore_sound_packets: Set to true if you are recording time-lapses where audio is unnecessary.
    • ignore_light_packets: Set to true since light is calculated on the client.
    • ignore_chat_packets, ignore_action_bar_packets, or ignore_scoreboard_packets: Set to true if these UI elements are not needed for the replay.
    • optimize_explosion_packets: Set to true to send only particles and sounds instead of full explosion data.
    • optimize_entity_packets: Set to true to let the client handle logic for entities like TNT or projectiles (note: may cause minor inconsistencies).
    • include_resource_packs: Set to false to avoid including large resource packs (requires users to download them from the server manually).
  11. Configure automatic player recording with player_predicate

    26.2

    The player_predicate setting allows you to define rules for which players are automatically recorded. You can filter by name, UUID, operator status, or team membership. You can also use logical operators like and, or, and not to create complex rules.

    Note: After updating the configuration, run /replay reload in-game. Players must re-login for the new rules to take effect.

    // Record all players
    {
      "player_predicate": { "type": "all" }
    }
    
    // Record specific names
    {
      "player_predicate": {
        "type": "has_name",
        "names": ["senseiwells", "foobar"]
      }
    }
    
    // Record specific UUIDs
    {
      "player_predicate": {
        "type": "has_uuid",
        "uuids": ["41048400-886d-497d-9d97-9fe7c9b63afa"]
      }
    }
    
    // Record operators (admins) with a specific level
    {
      "player_predicate": {
        "type": "has_op",
        "level": 4
      }
    }
    
    // Record players in specific teams
    {
      "player_predicate": {
        "type": "in_team",
        "teams": ["Red", "Blue"]
      }
    }
    
    // Complex logic: Not an admin AND (not named 'senseiwells' AND not in 'Red' team)
    {
      "player_predicate": {
        "type": "and",
        "predicates": [
          { "type": "not", "predicate": { "type": "has_op", "level": 4 } },
          { "type": "not", "predicate": {
              "type": "or",
              "predicates": [
                { "type": "has_name", "names": ["senseiwells"] },
                { "type": "in_team", "teams": ["Red"] }
              ]
            }
          }
        ]
      }
    }
    
    // Exclude fake players (Carpet Mod)
    {
      "player_predicate": {
        "type": "not",
        "predicate": { "type": "is_fake" }
      }
    }