Mineflex
Mineflex is a production-quality, native Python Minecraft bot framework inspired by and behaviorally compatible with PrismarineJS's Mineflayer.
It is written 100% in native Python using modern asyncio, dataclasses, type hints, and structured event dispatching. It does not use any Node.js runtime, subprocess wrappers, or RPC bridges.
Minimal Example
import asyncio
from mineflex import create_bot
async def main():
bot = create_bot(
host="localhost",
port=25565,
username="PythonBot",
auth="offline",
)
@bot.on("spawn")
async def on_spawn():
print(f"Spawned at {bot.position}!")
await bot.chat("Hello from native Python!")
@bot.on("chat")
async def on_chat(username, message, *args):
if username != bot.username:
if message == "!ping":
await bot.chat("pong!")
await bot.run()
if __name__ == "__main__":
asyncio.run(main())
Architectural Highlights
- Asyncio-Native Architecture: Clean separation between awaitable network commands (
bot.chat(),bot.dig(),bot.place_block(),bot.attack()) and synchronous instant state queries (bot.position,bot.health,bot.inventory,bot.block_at()). - Deterministic 20 Hz Physics Engine: Independent physics engine with exact Minecraft constants for gravity (-0.08), air drag (0.98), ground friction (0.6 * 0.91), jumping (+0.42), sprinting, sneaking, auto-stepping over 0.6 block height obstacles, and AABB collision resolution.
- Paletted Chunks & World State: Full 1.20+ chunk section paletted bit array decoding (single-value, indirect palette, and direct palette) with fast spatial lookups (
find_blocks,find_block). - Server-Authoritative Inventory: Complete 46-slot player inventory model and container window abstractions (chests, furnaces, crafting tables) supporting slot click transactions.
- Rich Chat & Component Trees: Parses vanilla JSON chat component trees, translation templates, color formatting, and legacy
§section formatting. - Modular Internal Plugins: Functionality is structured into modular internal plugins (
chat,health,game,time,blocks,entities,physics,inventory,actions), keepingBotclean and maintainable. - Extensible Custom Plugins: Supports both class-based
Pluginand callable function plugins.
Documentation
- Getting Started
- Architecture Guide
- API Reference
- Protocol Codecs & Framing
- Physics Simulation
- Plugin System
- Authentication
- Compatibility Matrix
- Migration from Mineflayer
- Troubleshooting
Running Tests
Run the complete test suite including unit tests and end-to-end mock server integration tests:
python -m pytest
License
This project is licensed under the MIT License.
Release files for mineflex 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mineflex-0.1.1.tar.gz | 73.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mineflex-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 160.4 kB
Release files / mineflex-0.1.1.tar.gz
| Download URL | mineflex-0.1.1.tar.gz |
|---|---|
| Size | 73.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
219ff6b50c0281c77205c3bb8459a0332e00f0a1c4c0d0be7ce97d1f43d82e31
|
|
BLAKE2b-256 checksum How to use checksums |
87134bc6cde489c99463916dea48d7942c294b2d7af1a6a4192993fd061c6923
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / mineflex-0.1.1-py3-none-any.whl
| Download URL | mineflex-0.1.1-py3-none-any.whl |
|---|---|
| Size | 86.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b6c906419e9b6b0f6bfbcdf4c203286781903cb4f2c5d818984a5682eadd93e
|
|
BLAKE2b-256 checksum How to use checksums |
6f26d73a839ee5a467b611fc13d3d33b2b45b3fe1f9df191dfca8fd8a6122ba4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|