ryzemcbe / bedrock-protocol
An implementation of the Minecraft: Bedrock Edition protocol in PHP
Requires
- php: ^8.1
- ext-encoding: ~1.0.0
- ext-json: *
- pocketmine/binaryutils: ^0.2.0
- pocketmine/color: ^0.2.0 || ^0.3.0
- pocketmine/math: ^0.3.0 || ^0.4.0 || ^1.0.0
- pocketmine/nbt: ^1.0.0
- ramsey/uuid: ^4.1
Requires (Dev)
- phpstan/phpstan: 2.1.0
- phpstan/phpstan-phpunit: ^2.0.0
- phpstan/phpstan-strict-rules: ^2.0.0
- phpunit/phpunit: ^9.5 || ^10.0 || ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-30 18:09:07 UTC
README
An implementation of the Minecraft: Bedrock Edition protocol in PHP
This library implements all of the packets in the Minecraft: Bedrock Edition protocol, as well as a few extra things needed to support them.
Install with Composer
Published package: ryzemcbe/bedrock-protocol.
composer require ryzemcbe/bedrock-protocol:1.0.0-beta.1
In a clone of this repository, run composer install to install development dependencies before running the tests. PHP namespaces remain pocketmine\\network\\mcpe\\protocol\\ for compatibility with existing consumers. Future releases are versioned using Git tags and synchronized with Packagist (enable the Packagist GitHub hook if not already connected).
However, at the time of writing, it does not include the following:
- Anything related to JWT handling/verification
- Anything related to encryption
- Anything related to compression
Decoding packets
Assuming you've decrypted and decompressed a Minecraft packet successfully, you're next going to want to decode it.
With this library, that's currently done using PacketBatch, like so:
use pocketmine\network\mcpe\protocol\serializer\PacketBatch; use pocketmine\network\mcpe\protocol\PacketPool; use pmmp\encoding\ByteBufferReader; foreach(PacketBatch::decodePackets(new ByteBufferReader($payload), PacketPool::getInstance()) as $packetObject){ var_dump($packetObject); //tada }
Encoding packets
This is easy:
use pocketmine\network\mcpe\protocol\serializer\PacketBatch; use pmmp\encoding\ByteBufferWriter; /** @var Packet[] $packets */ $stream = new ByteBufferWriter(); PacketBatch::encodePackets($stream, $packets); $batchPayload = $stream->getData();
Footnotes
This library is a little rough around the edges, since it's only ever been intended for PocketMine-MP usage. It's only recently that this mess has been separated from the core to allow it to be used by other things. This means that API changes might be in order, and your feedback would be nice to drive them. If you want to improve BedrockProtocol, please open issues with suggestions, or better, make pull requests.
RyzeMCBE project stewardship
This repository is maintained by RyzeCompany as a dependency of RyzeMP. The original upstream contributors, source licenses, and compatibility-oriented PHP namespaces remain acknowledged and unchanged.