Metadata-Version: 2.1
Name: pybedrock-net
Version: 1.3.3
Summary: Pure Python Minecraft Bedrock & RakNet protocol engine, bot framework, combat system, and player tracking radar.
Home-page: https://github.com/zenkai/pybedrock-net
Author: zenkai
Author-email: zenkai.developer@gmail.com
Maintainer: zenkai
Maintainer-email: zenkai.developer@gmail.com
License: MIT
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: Source Code, https://github.com/zenkai/pybedrock-net
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: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Games/Entertainment
Requires-Python: >=3.9
Requires-Dist: cryptography>=41.0.0
Description-Content-Type: text/markdown

# 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**.

