Skip to content

Fallen-Breath/PCRC

Repository files navigation

PCRC

English | 中文

PyCraft based Replay Client

A Minecraft client that can record a replay file (*.mcpr) which can be recognized by Replay Mod

Great thanks to SARC for the replay logic stuffs and pyCraft for the minecraft client stuffs

Environment

Python version should be python3 and at least it works on Python 3.6 and Python 3.8

Python modules

  • cryptography
  • requests
  • pynbt
  • redbaron
  • colorlog
  • ruamel.yaml

The requirements are also stored in requirements.txt

Minecraft server

PCRC currently supports connecting to vanilla Minecraft server. Supported versions:

  • 1.12 / 1.12.2
  • 1.14.4
  • 1.15.2
  • 1.16.1 ~ 1.16.5
  • 1.17.1
  • 1.18 ~ 1.18.2

Advantage

  • Can be hosted server side for 24/7 recording
  • Has way less performance usage than a regular Minecraft client
  • It can be set to record only when the player is nearby
  • Multiple options can be set for custom recording
  • Restart after raw file size reaches 2048MB or recording time reaches 5 hours to prevent oversize recording
  • Since the virtual player (bot) doesn't move, the recording file will not include unnecessary packets related to chunk loading, which can significantly reduce recording file size

Usage

Direct Launch

  1. Download and unzip the latest PCRC in Release page
  2. Run python PCRC.pyz or PCRC.exe
  • On first start, PCRC will generate default config file and exit. Fill in the config file on demand before launch it again
  1. Input start in the console to start PCRC
  2. (Recommand) Set the gamemode of the PCRC bot to spectator
  3. Use console or chat in game to control PCRC

As a MCDR plugin

Requires MCDReforged >= 2.0

Put the PCRC.pyz downloaded from Release into the plugin folder of MCDR and that's it

NOTE: Unloading the plugin will cause PCRC to stop recording and exit the game

Config

The config file is config.json. All settings can be changed in it. Those which are similar to ABC inside it are just comments, don't need to modify them

When used as a plugin for MCDR, the path to the configuration file will be config/pcrc/config.json, and config/pcrc/mcdr_config.json store the configuration related to MCDR

Base

language: The language that the PCRC bot will speak in the game. Language file should be in folder lang/

recording_temp_file_directory: Path to the directory where PCRC will store its temporary recording files in

recording_storage_directory: Path to the directory where PCRC will save its finished recording files

debug_mode: Whether outputs debug info or not

Account and Server

authenticate_type: The way for PCRC to login your account. It can be offline, mojang or microsoft, respectively corresponding to offline account, Mojang account login and Microsoft account login

If you use Microsoft account login, when you connect to the server for the first time after startup, you need to log in with your Microsoft account according to the console output

username: The username for offline mode login, or the email address of the Minecraft account if you are using mojang type online mode login

password: The password of the Minecraft account if you are using mojang type online mode login

store_token: When set to true and the authenticate_type is microsoft, the microsoft login token will be saved to file token.json. When launching PCRC the stored token will be loaded and used if it's not expired. Noted: The login token will be stored in plaintext

Examples for those account related config entries:

// Log in with offline mode
{
    "authenticate_type": "offline",
    "username": "MyPlayerName",  // the player name you want to use
    "password": "",  // This entry will not be used and will be ignored
}
// Log in with mojang account
{
    "authenticate_type": "mojang",
    "username": "MyEmail@mail.com",  // your mojang account email address
    "password": "mypassword",  // your mojang account password
}
// Log in with microsoft account
{
    "authenticate_type": "microsoft",
    "username": "",  // This entry will not be used and will be ignored
    "password": "",  // This entry will not be used and will be ignored
}

address: IP Address of the Minecraft server

port: Port of the Minecraft server

server_name: The server name showed in replay viewer

initial_version: The preferred Minecraft version that used to connect to bungeecord like server

PCRC Control

file_size_limit_mb: The limit of size of the .tmcpr file. Every time it is reached, PCRC will restart. Default: 2048

file_buffer_size_mb: The limit of size of file buffer. Every time it is reached, PCRC will flush all content in the buffer into .tmcpr file. Default: 8

time_recorded_limit_hour: The limit of actual recording time. Every time it is reached, PCRC will restart. Default: 12

delay_before_afk_second: The time delay between every player leaving and PCRC pausing recording. Default: 15

afk_ignore_spectator: If set to true, PCRC will ignore all packets from spectator players when determining if it should pause recording due to all players have left. Default: true

record_packets_when_afk: If set to false, PCRC will ignore almost every incoming packets when PCRC pauses recording (SARC's behavior). This can decrease the replay file size a lot but might cause block / entity desync if there will be something happening after player leaves. Default: true

auto_relogin: If this option is enabled, and the client gets disconnected, PCRC will automatically try to reconnect

auto_relogin_attempts: The maximum amount of relogin attempts before login success . Default: 5

chat_spam_protect: Automatically delay between sending chat messages if necessary to prevent being kicked for spamming

command_prefix: Any chat message starts with command_prefix will be recognize as a command to control PCRC. Default: !!PCRC

PCRC Features

daytime: Sets the daytime once to the defined time in the recording and ignores all further changes from the server. If set to -1 the normal day/night cycle is recorded

weather: Turns weather in the recording on or off

with_player_only: If set to true, PCRC only record packets if there are players nearby

remove_items: If set to true, all dropped items wont be recorded

remove_bats: If set to true, bats won't be recorded

remove_phantoms: If set to true, phantoms won't be recorded

on_joined_commands: A string list storing the commands that the PCRC bot will enter in sequence after it joins the game. You might need this if the server has some kind of login plugin etc.

// on_joined_commands example
{
    "on_joined_commands": [
        "/login myPassword",
        "/server myServer"
    ],
}

PCRC Whitelist

enabled: Whether to enable whitelist

whitelist: Whitelist player list

Command

Command prefix !!PCRC can be customized in the config file

Console Command

Available if launched directly

help: Show the list of console command

start: Start PCRC and start recording

stop: Stop PCRC and stop recording

restart: Restart PCRC

exit: Exit the program

reload: Reload the config file. Notes that not all config entries support hot-reload, e.g. authenticate_type is not hot-reload-able

auth: Authenticate with minecraft again. Used when the previous authentication failed

say <text>: Send text <text> to the server as a chat message

set <option> <value> Set option to value of PCRC and in the config file

whitelist [on|off] Switch the whitelist switch

whitelist [add|del] <player> Add or delete a player to(from) the whitelist

whitelist status To view the status of the whitelist and the whitelisted player(s)

status: Show the status of PCRC

list: Show the player list in the server if connected

MCDR Plugin command

Available if used as a MCDR plugin

!!PCRC start: start PCRC and start recording

!!PCRC stop: stop PCRC and stop recording. Only works with console command input

!!PCRC reload: Reload the config for PCRC and the config file for MCDR. Notes that not all PCRC config entries support hot-reload

!!PCRC set_redirect_url <url>: Input the url used in microsoft logging in

Requires permission level 1 to use these commands. The minimum required permission level can be set in the config file for MCDR

In Game Command

Using normal in game chatting to trigger

!!PCRC: show help

!!PCRC status: show status

!!PCRC here: emit a "!!here" command

!!PCRC pos: show position, might not be 100% accurate

!!PCRC spec: use the teleport ability in spectator mode to teleport to the player who sent this command

!!PCRC stop: stop PCRC

!!PCRC restart: restart PCRC

!!PCRC set: print all settable option

!!PCRC set <option> <value>: set the value of <option> to <value> which won't write to config file

!!PCRC name <filename>: set recording file name to <filename>

!!PCRC respawn: let PCRC bot try to respawn

Notes

  • There's not any code for processing game content in PCRC so if you want to move the PCRC bot you can only use teleport command like !!PCRC spec or /tp. You can not use stuffs like piston to move the bot otherwise some wired behaviors like the bot become invisible may occur
  • The file size that PCRC shows when recording is the size of .tmcpr file, the uncompressed raw packet file size. It's not the size of the final recording file .mcpr. The final file size is about 10% to 40% of the original packet file size, depending on the situation