Metadata-Version: 2.4
Name: pybedrock-net
Version: 1.3.1
Summary: Pure Python Minecraft Bedrock & RakNet protocol engine, bot framework, and server discovery tool.
Home-page: https://github.com/zenkai/pybedrock-net
Author: zenkai
Author-email: zenkai <zenkai.developer@gmail.com>
Maintainer: zenkai
Maintainer-email: zenkai.developer@gmail.com
License: MIT License
        
        Copyright (c) 2026 zenkai
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/zenkai/pybedrock-net
Project-URL: Developer, https://github.com/zenkai
Project-URL: TikTok, https://www.tiktok.com/@s_xwn
Project-URL: Bug Tracker, https://github.com/zenkai/pybedrock-net/issues
Project-URL: Documentation, https://github.com/zenkai/pybedrock-net#readme
Project-URL: Changelog, https://github.com/zenkai/pybedrock-net/blob/main/CHANGELOG.md
Keywords: minecraft,bedrock,raknet,mcpe,bot,protocol,networking,pure-python
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Games/Entertainment
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=41.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Requires-Dist: build>=1.0.0; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: maintainer
Dynamic: maintainer-email
Dynamic: requires-python

# pybedrock-net ⛏️🚀

[![PyPI version](https://img.shields.io/pypi/v/pybedrock-net.svg)](https://pypi.org/project/pybedrock-net/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-brightgreen.svg)](https://www.python.org/downloads/)
[![Platform](https://img.shields.io/badge/platform-Linux%20%7C%20Windows%20%7C%20macOS-lightgrey.svg)]()

> **The 100% Pure Python, Non-Native Engine for Minecraft Bedrock (MCPE) & RakNet Networking.**  
> Developed and maintained by **zenkai**.

---

## ⚡ Why pybedrock-net?

If you have ever attempted to build or run a Minecraft Bedrock bot in Docker, Linux containers, or cloud servers, you likely encountered the infamous compilation nightmare:
```
Error: Could not locate the bindings file. Tried: .../node-raknet.node
ERR! C++ Compiler toolset is not available.
```

**`pybedrock-net` solves this completely.**
It is built from the ground up using **pure asynchronous Python UDP networking**, meaning:
- **Zero C++ Compilers Required**: No `gcc`, no `cmake`, no native binary bindings that crash across different Node or Python ABI versions.
- **Runs Everywhere**: Works on Linux, Windows, macOS, Docker, Cloud Run, Raspberry Pi, and Android Termux out of the box.
- **Production-Tested In-World Protocol**: Handles the entire Bedrock connection lifecycle—RakNet MTU negotiation, login tokens, multi-phase resource pack verification, game spawn, real-time coordinate tracking, and automated keepalive.

---

## 🚀 Installation

Install the latest release from PyPI:

```bash
pip install pybedrock-net
```

Or install directly from the source repository:

```bash
git clone https://github.com/zenkai/pybedrock-net.git
cd pybedrock-net
pip install -e .
```

---

## 💻 CLI Usage (`pybedrock-bot`)

`pybedrock-net` comes bundled with a full-featured terminal CLI client:

```bash
# Ping a Bedrock server
pybedrock-bot --ping --host play.example.com --port 19132

# Connect a bot to a server with Anti-AFK enabled
pybedrock-bot --host play.example.com --port 19132 --username ZENKAI_Bot --anti-afk
```

### CLI Arguments

| Argument | Description | Default |
|---|---|---|
| `--host` | Target Bedrock server hostname or IP | Required |
| `--port` | Target UDP port | `19132` |
| `--username` | Bot gamer tag | `ZENKAI_Bot` |
| `--ping` | Ping server and display MOTD without logging in | `False` |
| `--anti-afk` | Automatically swing arm & move to prevent idle kicks | `True` |
| `--view-distance` | Chunk radius requested from server | `10` |

---

## 🐍 Python API Examples

### 1. Ping and Query Server Status

```python
import asyncio
from pybedrock_net import BedrockServerPing

async def main():
    info = await BedrockServerPing.query("play.example.com", port=19132, timeout=3.0)
    if info.online:
        print(f"MOTD: {info.motd}")
        print(f"Version: {info.version} (Protocol {info.protocol})")
        print(f"Players: {info.players_online}/{info.players_max}")
        print(f"Latency: {info.latency}ms")
    else:
        print("Server is offline or unreachable.")

asyncio.run(main())
```

### 2. Spawning a Bot into the World

```python
import asyncio
from pybedrock_net import BedrockClient

async def main():
    bot = BedrockClient(
        host="play.example.com",
        port=19132,
        username="ZENKAI_Agent",
        anti_afk=True
    )

    @bot.on("connect")
    async def on_connect():
        print("Connected to RakNet UDP layer!")

    @bot.on("login")
    async def on_login():
        print("Authentication succeeded! Negotiating resource packs...")

    @bot.on("spawn")
    async def on_spawn(data):
        print(f"Bot spawned into the world! Dimension: {data.dimension}")
        print(f"Position: X={data.position.x}, Y={data.position.y}, Z={data.position.z}")
        # Send a greeting into the server chat
        await bot.send_chat("Hello everyone! Powered by pybedrock-net.")

    @bot.on("chat")
    async def on_chat(sender, message):
        print(f"[{sender}] {message}")
        if message == "!ping":
            await bot.send_chat("Pong!")

    await bot.start()

asyncio.run(main())
```

---

## 🏛️ Architecture & Protocol Stack

```
┌───────────────────────────────────���──────────┐
│           High-Level Bot API                 │
│      (Events, Chat, Actions, Anti-AFK)       │
├──────────────────────────────────────────────┤
│         Bedrock Protocol Layer (v1.20+)      │
│  (Login, Packs, StartGame, TickSync, Latency)│
├──────────────────────────────────────────────┤
│           Pure Python RakNet Engine          │
│    (MTU Discovery, Encapsulation, ACK/NACK)  │
├──────────────────────────────────────────────┤
│           Asyncio Datagram Socket (UDP)      │
└──────────────────────────────────────────────┘
```

---

## 📦 Publishing to PyPI

To build and publish new distributions to PyPI:

```bash
# 1. Install build dependencies
python -m pip install --upgrade build twine

# 2. Build distribution archives
python -m build

# 3. Upload to PyPI
twine upload dist/*
```

---

## 👨‍💻 Author & Community

`pybedrock-net` was created and is actively maintained by **zenkai**.

[![GitHub](https://img.shields.io/badge/GitHub-zenkai-181717?style=flat&logo=github)](https://github.com/zenkai)
[![TikTok](https://img.shields.io/badge/TikTok-%40s__xwn-000000?style=flat&logo=tiktok)](https://www.tiktok.com/@s_xwn)
[![Repository](https://img.shields.io/badge/Source-pybedrock--net-blue?style=flat&logo=github)](https://github.com/zenkai/pybedrock-net)
[![Email](https://img.shields.io/badge/Email-zenkai.developer%40gmail.com-EA4335?style=flat&logo=gmail)](mailto:zenkai.developer@gmail.com)

- **Lead Developer**: **zenkai**
- **TikTok**: [@s_xwn](https://www.tiktok.com/@s_xwn)
- **Official Repository**: [https://github.com/zenkai/pybedrock-net](https://github.com/zenkai/pybedrock-net)
- **Contact & Inquiries**: `zenkai.developer@gmail.com`
- **Issue Tracker & Discussions**: [GitHub Issues](https://github.com/zenkai/pybedrock-net/issues)

Feel free to submit pull requests, open issues, or reach out for custom Minecraft Bedrock network integrations and bot solutions.

---

## 📄 License

Distributed under the MIT License. See [LICENSE](LICENSE) for details.

Developed with precision by **zenkai**.
