Skip to content

VincentZyuApps/lcon

 
 

Repository files navigation

๐Ÿ“– English ๐Ÿ“– ไธญๆ–‡

GitHub Gitee

lcon

๐ŸŽฎ LCon โ€” WebSocket remote control for Minecraft client

๐Ÿงฉ A Forge mod that runs a WebSocket server on the Minecraft client (single-player / LAN), allowing external applications to execute commands and interact with the game in real time.

LCon logo

๐Ÿ’ก How it works โ€” When you play single-player or open to LAN, your client runs an integrated server underneath โ€” the same command engine, world ticking, and gameplay loop as a dedicated server.

โ˜๏ธ๐Ÿค“ In Minecraft, "single-player", "multiplayer", "LAN", and "server" all run the same server code โ€” there's no essential difference. LCon taps into this integrated server and starts a WebSocket server alongside it, so external tools can control the game without needing a separate dedicated server.

Forge 1.20.1 Java 17 Gradle 8.1.1

Python TUI Client

Last Commit CI Status

๐Ÿงฉ What it does

LCon starts a WebSocket server inside your Minecraft client when you're in a world (single-player or LAN). You can connect to it from any WebSocket client โ€” a Python script ๐Ÿค–, a chatbot ๐Ÿ’ฌ, a web dashboard ๐Ÿ“Š โ€” and:

๐Ÿท๏ธ Prefix โšก Action
[chat]<message> Send a chat message as the player
[message]<message> Display a message to the player only
[system]<message> Display a system message in chat
[client]/<command> Execute a client-side command
[server]/<command> Execute a server-side command

โœ… No Mixin, no coremod, no overwrites โ€” purely event-driven, safe for any modpack.

๐Ÿ”Œ How to connect

๐Ÿ“ฆ Mod Installation

  1. Download the latest .jar from Releases
  2. Place it in your client's mods/ folder
  3. Launch Minecraft โ€” lcon-ws-server.toml is auto-generated in config/ on first load

โš ๏ธ mods/ and config/ must be at the same directory level.
Typical structure: .minecraft/mods/lcon-*.jar + .minecraft/config/lcon-ws-server.toml

๐Ÿ Using Python (uv)

uv venv --python 3.13
uv pip install websocket-client
uv run python -c "
import websocket; ws = websocket.create_connection('ws://localhost:58115?token=your_secret_token')
while True:
  msg = ws.recv(); print(msg)
  if 'โœ…' in msg or 'ready' in msg: break
ws.send('[server]/say awa!'); print(ws.recv()); ws.close()
"

Python uv CLI WebSocket client

๐Ÿชข Using wscat via npx

npx wscat -c ws://localhost:58115?token=your_secret_token

Once connected, you'll receive welcome messages from the server:

< ๐ŸŽ‰ 200:Welcome to LCon! Have fun! Don't forget to use prefixes with every message you send to me.
< ๐Ÿ“‹ 200:Valid prefixes:
< ๐Ÿ’ฌ 200:[chat] - send message to Minecraft chat.
< ๐Ÿ“ฉ 200:[message] - display message for player only.
< ๐Ÿ”” 200:[system] - display system message in chat (for player only).
< ๐Ÿ–ฅ๏ธ 200:[client] - execute client-side command.
< ๐Ÿ–ง 200:[server] - execute server-side command.
< โœ… 201:ready.

npx wscat CLI WebSocket client

Then send commands with prefixes (> is what you type, < is the server response):

> [server]/say Hello everyone!
# (command executed โ€” no response text, but the chat message appears in-game)

> [chat]Hello!
# (message sent as the player in chat)

> [server]/give @s diamond 64
# (command executed โ€” diamonds appear in your inventory)

> unknown-qwq
< โŒ 400:Error! Send message prefix first! [chat], [message], [system], [client], [server] are valid prefixes.

๐Ÿ Python Client (TUI)

A Textual-based terminal UI with tabbed interface (Console, Commands, Settings, About).

LCon Python TUI Client Preview

๐Ÿš€ Quick Start

git clone https://github.com/VincentZyuApps/lcon.git
cd lcon

uv venv --python 3.13
uv pip install textual websocket-client

uv run python ./client/main.py

๐ŸŒ Environment Variables

๐Ÿท๏ธ Variable ๐Ÿ“„ Default ๐Ÿ“ Description
LCON_HOST localhost WebSocket server address
LCON_PORT 58115 WebSocket server port
LCON_TOKEN your_secret_token Authentication token
LCON_SOFT_WRAP true Enable soft word wrap in console log (true/false)
LCON_LOG_BUFFER 1000 Maximum lines to keep in console log buffer
LCON_AUTO_MODE true Auto-prepend prefix before sending messages (true/false)

๐Ÿ“„ .env File (optional)

Copy the example and edit:

cp config/.env.example config/.env

Priority: environment variable โ†’ config/.env โ†’ hardcoded default.

bash (Linux / macOS / WSL / Git Bash):

LCON_HOST=192.168.1.100 LCON_PORT=58115 LCON_TOKEN=your_secret_token
uv run python client/main.py

PowerShell (Windows):

$env:LCON_HOST="192.168.1.100"; $env:LCON_PORT="58115"; $env:LCON_TOKEN="your_secret_token"
uv run python client/main.py

CMD (Windows):

set LCON_HOST=192.168.1.100 && set LCON_PORT=58115 && set LCON_TOKEN=your_secret_token
uv run python client/main.py

โš™๏ธ Configuration

File: .minecraft/config/lcon-ws-server.toml

โš™๏ธ Option ๐Ÿท๏ธ Type ๐Ÿ“„ Default ๐Ÿ“ Description
enable_mod boolean true Enable the WebSocket server
port int 58115 WebSocket server port
token string your_secret_token Auth token. Clients pass ?token=xxx on connect
command_permission_level int 4 OP level for [server] commands (0-4). 4 = full access without enabling cheats
serializer_mode string json Component serialization: json (recommended for Python TUI) or tostring
enable_message_emoji boolean true Master switch for message emoji
emoji_* string various 13 per-message emoji settings (e.g. emoji_welcome, emoji_chat)
msg_* string various 13 per-message text settings (e.g. msg_welcome, msg_chat)
[mclistener].enable boolean true Enable the mclistener JSON WebSocket server on port 60626
[mclistener].host string 0.0.0.0 Listen address for the mclistener server
[mclistener].port int 60626 Port for the mclistener server
[mclistener].token string "" Auth token for mclistener. Empty = no auth
[mclistener].enable_player_join_broadcast boolean true Broadcast player_join events to mclistener clients
[mclistener].enable_player_leave_broadcast boolean true Broadcast player_leave events to mclistener clients
[mclistener].enable_player_chat_broadcast boolean true Broadcast player_chat events to mclistener clients
[mclistener].player_chat_capture_mode string event Player chat capture mode: event (recommended), text, or both
[mclistener].enable_receive_group_message boolean true Accept chat_platform_to_server messages and relay them in-game
[mclistener].group_message_format string ยง6ยงl[{group_name}]ยงr ยง7({group_id})ยงr ยงaยงo{nickname}ยงrยงf: {message} In-game format for relayed group messages
[mclistener].exec_command_mode string disabled Remote command execution mode: disabled or client
[mclistener].command_tracking_mode string single Command tracking mode: single (recommended) or parallel (experimental, may be unstable or produce mixed results)

๐Ÿ’ก When using the Python TUI client, set serializer_mode = "json" in lcon-ws-server.toml for best compatibility.

๐Ÿ’ก For mclistener command execution, keep command_tracking_mode = "single" unless you explicitly want best-effort parallel tracking.

๐Ÿ— Build

๐Ÿ› ๏ธ Local

./gradlew build

๐Ÿ“ฆ Output: build/libs/lcon-*.jar

๐Ÿค– GitHub Actions CI

Push to any branch with specific keywords in the commit message:

Commit message contains What happens
build action Build + upload artifact
build release Build + create GitHub Release
git commit -m "fix: something; build action"
git commit -m "feat: something; build release"

๐Ÿ“ฆ Tech Stack

๐Ÿ–ฅ๏ธ Server (Forge Mod)

Dependency Version Description
Java 17 17 Runtime
Forge 1.20.1 47.2.19 Mod loader
Gradle 8.1.1 Build tool
Shadow 7.1.0 Fat-jar plugin
Java-WebSocket 1.5.6 WebSocket server (fat-jarred)
GitHub Actions โ€” GitHub CI/CD

๐Ÿ Client (Python TUI)

Dependency Version Description
Python 3.13 Runtime
textual โ‰ฅ8.2 TUI framework
websocket-client โ‰ฅ1.9 WebSocket client

About

๐ŸŽฎ WebSocket remote control for Minecraft client โ€” execute commands and control chat remotely, bundled with a Python TUI client ๐Ÿ

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Java 71.0%
  • Python 27.3%
  • CSS 1.7%