LLM_Translator

在游戏内使用大语言模型进行翻译。支持翻译玩家对话,游戏内木牌文字,讲台上的书籍内容。

tool
information

Installation command

!!MCDR plugin install llm_translator

Author

Synced at

...

Last update

...

Latest version

Total downloads

373

Back to catalogue

LLM-Translator

The development inspiration for this plugin comes from the MCDR plugin SimpleTranslator - Plugin Repository - MCDReforged

Uses Large Language Models to provide in-game translation for player chat messages, sign text, and book content. The plugin uses the deepseek-chat large language model for translation by default.

Installation

  1. Install MCDReforged (Python 3.8+).

  2. Install the Python dependencies in the Python environment MCDR runs on:

    python -m pip install openai nbtlib
    
    • The requirements.txt inside the .mcdr archive is only used for a version check at load time; MCDR does not install it automatically. When deploying from source you can run python -m pip install -r requirements.txt.
    • Use the Python interpreter that runs MCDR (the bundled Python for the all-in-one Windows build).
    • On Python 3.8, use python -m pip install "openai<2" nbtlib if the install fails.
  3. Install the required plugin MinecraftDataAPI (plugin id minecraft_data_api, version >= 1.4.0). Run !!MCDR plugin install minecraft_data_api in the console, or download it from the plugin catalogue into the plugins directory.

  4. Put llm-translator-1.6.1.mcdr into the plugins directory, then run !!MCDR plugin load llm-translator-1.6.1.mcdr or restart MCDR.

If loading fails, check the log:

LogCause and fix
Unsatisfied Python library requirement ... required package 'openai' not installedDependencies missing in MCDR's Python environment; do step 2
Dependency minecraft_data_api not foundRequired plugin missing; do step 3

Introduction

When players speak different languages on the server, this plugin can significantly improve communication. Supports synchronized forwarding of translated player chat messages across multiple servers. Using LLM translation offers higher accuracy and better adaptability compared to traditional machine translation. Supports translating the following in-game:

  • Player chat messages
  • Text on Signs
  • Book content on Lecterns
  • The sign or lectern book you are looking at (no coordinates needed)

Configuration

  1. After the plugin is successfully loaded for the first time, a configuration file will be generated in the /config/llm-translator/ folder.

  2. The configuration file uses the deepseek-chat model for Chinese-English translation by default. If this meets your needs, simply enter your API key in the api_key field. Otherwise, please modify the configuration file as described below.

    {
    "first_language": "zh_cn",
    "secondary_language": "en_us",
    "base_url": "https://api.deepseek.com",
    "model": "deepseek-chat",
    "api_key": "enter-your-api-key",
    "enable_system_prompt": true,
    "look_translate_max_distance": 6.0,
    "is_proxy_to_other_servers": false,
    "proxy_servers": [
        {
            "address": "127.0.0.1",
            "port": 25575,
            "password": ""
        },
        {
            "address": "127.0.0.1",
            "port": 25576,
            "password": ""
        }
    ]
    }
    
Field NameData TypeDefault ValueDescription
first_languagestring"zh_cn"The primary language, usually the user's native or main language.
secondary_languagestring"en_us"The secondary language, the target language for translation.
base_urlstring"https://api.deepseek.com"The base request URL for the API.
modelstring"deepseek-chat"The name of the language model to use.
api_keystringNo defaultThe API access key.
enable_system_promptbooleantrueWhether to enable system prompt.
system_promptstringBuilt-inCustom system prompt, supports {first_language} and {secondary_language} placeholders. When omitted, the built-in Minecraft/TMC SOP prompt is used.
look_translate_max_distancefloat6.0Maximum raycast distance (blocks) for crosshair translation. Requires RCON.
is_proxy_to_other_serversbooleanfalseWhether to forward translated chat messages to other servers.
proxy_serverslist[dict][]List of target server configurations for forwarding. Requires RCON.

proxy_servers RCON server configuration:

Field NameData TypeDefault ValueDescription
addressstring"127.0.0.1"The address of the target server.
portintNo defaultThe RCON port of the target server.
passwordstring""The RCON password for the target server (if required).

Configuration Notes

  1. Basic Setup: Just fill in the api_key to use the default DeepSeek model for Chinese-English player chat translation.

  2. Other Language Pairs: Modify first_language and secondary_language to support other language pairs.

  3. Multiple Model Support: Change base_url and model to switch to other LLM providers.

  4. System Prompt Customization: Use enable_system_prompt to control whether to use system prompts, and system_prompt to customize translation prompts. {first_language} and {secondary_language} are expanded to a readable language name plus code (e.g. Chinese (Simplified) (zh_cn)). The built-in prompt is concise and states the translation direction explicitly. On first load, an unmodified legacy built-in prompt in config.json is replaced automatically; custom prompts are left untouched.

  5. Chat Message Forwarding: To forward translated player messages to other servers (typically used in setups like Velocity with multiple backend servers and pre-configured chat forwarding), set is_proxy_to_other_servers to true and configure the proxy_servers list.

Usage

In-game operation notices are in English; !!help entries are bilingual (Chinese / English).

Player Chat Translation

In the game chat, prefix your message with t and a space to translate it.

image

Sign and Book Translation

Book Content: The book must be placed on a Lectern to be translated.

Use the command !!tr <x> <y> <z> to translate (the parameters are the coordinates of the sign or the book on a lectern; you can use ~ to represent the current player's coordinates).

You can also look at a sign or a lectern book and run !!tr without parameters. The plugin raycasts along your line of sight and translates the target it finds. This requires RCON to be enabled in the MCDR configuration (matching enable-rcon, rcon.port and rcon.password in the server's server.properties). The maximum detection distance is controlled by look_translate_max_distance.

imageimage image

Other

This is my first time developing a plugin, so there might be imperfections or areas for improvement. If you encounter bugs or have suggestions while using it, please feel free to submit an Issue on the plugin's Github repository.

Introduction source: README_EN.md