Work in progress. This project is still under active development. You can join, place/break blocks in creative, and spawn some entities, but entities do not work properly yet (interaction, AI, riding, and breeding are incomplete or buggy). Expect breaking changes.
Plugin-first Minecraft Java Edition server in Python. Primary target: 26.2 (protocol 776). Also supports 1.21.11 (774) and 1.21.4 (769). Offline mode by default.
pip install -e ".[dev]"
python -m pysrvstg --config config/server.tomlConnect with Minecraft 26.2, 1.21.11, or 1.21.4 to localhost:25565 (offline mode). The server picks encoders from the client handshake protocol version. See config/server.toml for the pinned version.
Drop a .py file in plugins/. The server calls on_load() once and on_tick() every game tick (20 TPS).
from pysrvstg import hotbar, players
from pysrvstg.events import PlayerJoinEvent, ChatEvent
def on_tick():
if PlayerJoinEvent:
hotbar.broadcast(f"Welcome! {players.count} online")
if ChatEvent:
if ChatEvent.message.startswith("!hello"):
ChatEvent.reply("Hi!")For a script-style loop in a background thread:
import threading
from pysrvstg import server, hotbar, players
from pysrvstg.events import PlayerJoinEvent
def on_load():
threading.Thread(target=_loop, daemon=True).start()
def _loop():
while server.loop():
if PlayerJoinEvent:
hotbar.broadcast(f"{players.count} online")if PlayerJoinEvent: works because events are boolean latches for the current tick (EventSignal.__bool__).
- Server list ping (MOTD, player count)
- Login (offline), configuration, play state (26.2 / 1.21.11 / 1.21.4)
- Flat overworld spawn, tab list, loading terrain
- Creative block place/break (server-tracked), basic water/lava flow
- Entity spawn from eggs and some placeables (experimental)
- Action bar (
hotbar.send/hotbar.broadcast) - Chat events (
ChatEvent,reply()) - Plugin load errors disable only that plugin
Not included or incomplete: online-mode auth, survival gameplay, proper entity AI and interaction, world save, permissions, redstone, inventories.
- Copy
src/pysrvstg/net/protocol/versions/v769.pytovXXX.pyusing packet IDs from minecraft-datapc/<version>/protocol.json. - Implement the
VersionProtocolmethods (join, chunks, chat, action bar). - Register in
src/pysrvstg/net/protocol/registry.py(seev774.pyas a template) and add aserver.tomlalias.
Plugins stay unchanged; only the protocol module differs.
pytest