A neat Minecraft in-game chat interacting API with server-side l10n support, suitable for chatbots.
- Minecraft 1.7.10 with Forge: Unimixins (CurseForge)
- Minecraft 1.12.2 with Forge: MixinBooter (CurseForge)
- Other version: no dependencies
- Download the mod and put it into your
modsfolder. - Restart your Minecraft server.
- Run the command
/realitylink downloadto download vanilla language assets from Mojang. - Check and alter the config file
config/realitylink/server.toml. For details, see Configuration. - Run the command
/realitylink startto start the WebSocket server.
This mod runs on a Minecraft server and establishes a WebSocket server at ws://host:port/minecraft-chat. The server
sends in-game chat messages as text frame
{"json": "${raw JSON text format}", "translatedText": "${sever-side translated text}"}
to clients. (Raw JSON text format)
Send {"type": "literal", "text": "${your message}"}
to broadcast a literal message in the game.
Send {"type": "json", "json": "${raw JSON text format}"}
to broadcast a rich message in the game.
Query a player's statistic:
GET http://host:port/stats/{uuid}/{statName}
Returns int | null.
For example:
GET http://host:port/stats/00000000-0000-0000-0000-000000000000/minecraft.custom:minecraft.play_time
See Wiki: Statistics, Wiki: Statistics for Minecraft below 1.13
Minecraft server don't hold redundant l10n resources which are thought to be at client-side. If you have some resource
packs or mods' jar files inside which language resources (files like /assets/{namespace}/lang/{locale_code}.json)
exists, create a folder and copy all these packs into it.
Under normal circumstances, minecraft server don't have language files for vanilla contents. It is required to download
Minecraft's language resources
assets/minecraft/lang/*.json, create a zip file of the assets folder and then the zip archive is virtually a
resource pack (without metadata pack.mcmeta. It doesn't matter.)
All these steps above can be done by a single command /realitylink download
result in serverlang/vanilla.zip.
Those language files' extension is .lang instead of .json.
create a toml file config/realitylink/server.toml:
host = "0.0.0.0"
port = 39244
localeCode = "en_us"
resourcePackDirs = ["mods", "serverlang"]
autoStart = falseport: The port server listenslocaleCode: See wikiresourcePacksDirs: Folders where resource packs are stored. Absolute path, or relative to the Minecraft game's root path (commonly the parent ofmods,config, etc.). It is recommended to includemodsandserverlangfolder so that language files in mods and vanilla Minecraft can be loaded.autoStart: Start the API server automatically when Minecraft server starting.
localeCode is in the format of en_US, not en_us.
Start the Minecraft server, and then use the command /realitylink start to launch the API server.
The server will be launched automatically if autoStart = true in
server.toml.
The shared code is written in Scala 3 under realitylink/. Each version has a package.mill and a standalone Gradle
project under platform/ that fetches the Minecraft and mod loader things and handles remapping, mixins and dev runs.
For IDE support, enable BSP by adding the module name to
.enableBsp. For example, create .enableBsp file with
neo1_21_1
forge1_7_10
which enables IDE support for neo1_21_1 and forge1_7_10.
Build the mod jar with
./mill forge1_20_1.jarYou can replace forge1_20_1 with: forge1_7_10,
forge1_12_2, forge1_16_5, forge1_18_2, forge1_19_2,
forge1_20_1 or neo1_21_1.
./mill forge1_20_1.runClient
./mill forge1_20_1.runServer