Metadata-Version: 2.1
Name: pybedrock-net
Version: 1.3.4
Summary: PyBedrock Net is a Python Minecraft Bedrock networking toolkit for RakNet transport, protocol packets, authentication, world data, entities, inventory, chat, commands, events, and bot automation.
Home-page: https://pypi.org/project/pybedrock-net/
Author: ZENKAI
Author-email: zenkai.developer@gmail.com
License: MIT
Project-URL: Homepage, https://pypi.org/project/pybedrock-net/
Project-URL: Repository, https://github.com/pybedrock-net/pybedrock-net
Project-URL: TikTok, https://www.tiktok.com/@s_xwn?_r=1&_t=ZS-994W6rldVjQ
Project-URL: YouTube, https://www.youtube.com/@szewq
Project-URL: Telegram, https://t.me/s_xwn
Keywords: bedrock,game-bot,minecraft,raknet,udp
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Games/Entertainment
Requires-Python: >=3.10
Requires-Dist: cryptography>=41.0.0
Description-Content-Type: text/markdown

# PyBedrock Net

**PyBedrock Net** is a Python networking toolkit for building Minecraft Bedrock Edition clients, bots, server tools, and protocol experiments. It is created and maintained by **ZENKAI** with a focus on a clean API, simple scripts, and protocol code that can grow without becoming difficult to use.

The project is organized around the complete Bedrock client journey:
- **Client and sessions** — simple client configuration, connection lifecycle, and reusable sessions.
- **RakNet and transport** — UDP transport, connection handling, reliability, fragmentation, compression, and packet flow.
- **Protocol and packets** — codecs, VarInts, readers, writers, registries, version resolution, handshakes, login, gameplay, movement, chat, commands, inventory, player, and world packets.
- **Authentication** — offline mode plus the foundations for Microsoft/Xbox account sessions and token management.
- **World data** — chunks, subchunks, palettes, blocks, cache, and world state.
- **Entities and players** — entity models, metadata, tracking, and player state.
- **Bots and automation** — movement, navigation, actions, and controllers.
- **Events and discovery** — event dispatching, server ping, and protocol detection.

The package is intentionally built in tested layers: low-level binary primitives first, then transport and protocol packets, then high-level client and bot APIs. This makes it useful for both a quick server script and a larger Bedrock automation project.

---

## ⚡ 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 of native C++ bindings:
```
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.

---

## 🆕 What's New in v1.3.4 (Latest Production Release)

- ⚔️ **Extended Combat AI & Reactive Self-Defense**:
  - `client.attack(entity_id)` and reactive counter-attack loop.
  - Automatic target lock-on: strikes attacker until eliminated, then immediately halts (`Stop on Kill`).
  - Creative God-Mode resilience: ignores damage knockback and maintains offensive priority.

- 👀 **Eye-Contact Detection & Respectful Greeting**:
  - Bot automatically calculates pitch/yaw to detect when a player is directly looking at it.
  - Automatically faces the player and performs a courteous bow (`client.sneak(True)`).

- 🌐 **Global Multi-Server Player Tracker**:
  - Track any player across Bedrock & Java public networks worldwide.
  - Resolves player presence, server coordinates (when co-located), join time, UUID, and server details.

- 🕹️ **Interactive Telegram Bot Controller**:
  - Full inline interactive button matrix for remote bot actions:
    - 📷 **Live POV Camera Snapshot**
    - 👥 **List Online Players**
    - 🔍 **Global Player Tracker**
    - ⚔️ **PvP Combat Retaliation**
    - 🙇 **Respectful Bow Greeting**
    - 🛡️ **Creative God-Mode Toggle**
    - 🏃 **Anti-AFK Jump & Roam**

- 📡 **Extended Protocol 776 (Minecraft Bedrock 1.21.60+)**:
  - Support for Bedrock protocols from 685 (1.20.80) through 776 (1.21.60) with automated protocol negotiation fallback.

---

## 🚀 Installation

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

The package is published on PyPI at <https://pypi.org/project/pybedrock-net/>.

To create a signed login payload:

```python
from pybedrock_net.auth import LoginChainBuilder

login = LoginChainBuilder().build(
    server_address="play.example.com:19132",
    display_name="PyBot",
)
session.begin_login(2169, login.payload())
```

## 🤖 Offline bot

For an offline-mode server, the username is selected locally and no Microsoft account is used:

```python
from pybedrock_net.bot import BedrockBot

bot = BedrockBot("127.0.0.1", 19132, "AnyName")
bot.login(protocol=776) # Bedrock 1.21.60
bot.chat("hello world")
bot.command("/say hello")

# Combat & Interaction
bot.sneak(True) # Bow greeting
bot.attack(target_id=123)
```

## 📱 Telegram controller

The package includes a dependency-free Telegram long-polling controller with rich inline buttons:

```bash
export TELEGRAM_BOT_TOKEN="your_telegram_bot_token"
export TELEGRAM_ALLOWED_CHAT_IDS="123456789"
bedrock-telegram
```

Send `/server HOST PORT USERNAME` in Telegram, then use the interactive button keyboard to view live camera snapshots, list online players, track users globally, attack, bow, or disconnect.

## 💻 Command line

```bash
bedrock-ping play.example.com
bedrock-ping play.example.com --port 19132 --timeout 5
```

## 🐍 Python Client

```python
from pybedrock_net import BedrockClient

client = BedrockClient("play.example.com", 19132)
status = client.ping()
print(status.description, status.players_online, "/", status.players_max)
```

Discovery ping is available through `client.ping()`, but connection setup skips it by default because some proxies and firewalls block unconnected RakNet pings. To require discovery before the RakNet handshake:

```python
client = BedrockClient("play.example.com", skip_ping=False)
session = client.connect()
```

The current release provides a real RakNet unconnected ping/pong flow, a reusable UDP transport, binary codecs, server status parsing, connected RakNet batch send/receive, Microsoft/Xbox device-code authentication, and client/bot session foundations.

---

## 👤 Author & Links

**ZENKAI**
- **TikTok**: <https://www.tiktok.com/@s_xwn?_r=1&_t=ZS-994W6rldVjQ>
- **YouTube**: <https://www.youtube.com/@szewq>
- **Telegram**: <https://t.me/s_xwn>
- **PyPI**: <https://pypi.org/project/pybedrock-net/>
- **GitHub**: <https://github.com/pybedrock-net/pybedrock-net>

## 📄 License
MIT License - Copyright (c) 2026 PyBedrock Net contributors.

